Tags:C/C++ pointer analysis, field-sensitive, positive weight cycle and static analysis
Abstract:
By distinguishing the fields of an object, Andersen's field-sensitive pointer analysis yields better precision than its field-insensitive counterpart. A typical field-sensitive solution to inclusion-based pointer analysis for C/C++ is to add positive weights to the edges in Andersen's constraint graph to model field access. However, the precise modeling is at the cost of introducing a new type of constraint cycles, called positive weight cycles (PWCs). A PWC, which contains at least one positive weight constraint, can cause infinite and redundant field derivations of an object unless the number of its fields is bounded by a pre-defined value. PWCs significantly affect analysis performance when analyzing large C/C++ programs with heavy use of structs and classes.
This paper presents DEA, a fast and precise approach to handling of PWCs that significantly accelerates existing field-sensitive pointer analyses by using a new field collapsing technique that captures the derivation equivalence of fields derived from the same object when resolving a PWC. Two fields are derivation equivalent in a PWC if they are always pointed to by the same variables (nodes) in this PWC. A stride-based field representation is proposed to identify and collapse derivation equivalent fields into one, avoiding redundant field derivations with significantly fewer field objects during points-to propagation. We have conducted experiments using 12 popular open-source C/C++ programs (8.2 million lines of LLVM instructions in total). The experimental results show that DEA is on average 7.1X faster than Pearce et al.'s field-sensitive analysis PKH, obtaining the best speedup of 14.1X while maintaining the same precision.
Fast and Precise Handling of Positive Weight Cycles for Field-sensitive Pointer Analysis