using alias-analysis

Hi together,

i want to create a map containing a set of aliases for each value.

For example, for a code like:

int main() {

int i;
int *p1 = &i;
int *p2 = &i;

return 0;
}

the map should contain something like:

{i → (p1, p2),

}

For that, i do followings in my pass:

AliasAnalysis &AA = getAnalysis();
AliasSetTracker *tracker = new AliasSetTracker(AA);

for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
tracker->add(*BB);
}

using the print-method of AliasSetTracker, i see:

Alias Set Tracker: 4 alias sets for 4 pointer values.
AliasSet[0x8528d08,1] must alias, Mod Pointers: (i32** %p1, 4)
AliasSet[0x8528d48,1] must alias, Mod Pointers: (i32** %p2, 4)
AliasSet[0x8522d18,1] must alias, Mod/Ref Pointers: (i32* %0, 4)
AliasSet[0x8522d58,1] must alias, Mod/Ref Pointers: (i32* %retval, 4)

can i create this map using the info in AliasSetTracker?

Regards
Raad

Hi together,

i want to create a map containing a set of aliases for each value.

I’d suggest checking out the code in lib/Analysis/AliasAnalysisEvaluator.cpp. It does an all pairs query and prints out the result of each query. Try “opt -aa-eval -print-all-alias-modref-info foo.bc”.

AliasSetTracker *tracker = new AliasSetTracker(AA);

I’d recommend against using the AliasSetTracker class if you want good precision. It basically forces a unification approach on top of the underlying AA impl, which pessimizes the results when aliases are not transitive.

-Chris