CFLAndersAliasAnalysis print implementation

Hello all,

I’m having trouble getting this analysis to print out it’s graph of aliases. I am processing an example C file into llvm ir, like this:

int main(void) {
int x=1, y=2, z=3;
int *p;
int **p1, *p2;
if (x==z) { //0x100000f40
p=&x;
p1=&p;
x
=2;
*p1+=z;
}

}

clang -S -emit-llvm example.c -o example.ll

Then, I am trying to run the Andersen alias analysis on it:

opt -analyze --cfl-anders-aa -aa example.ll

I wrote a new print function for the anders alias analysis, and the print function parameter Module *M and the Result calculated each indicate that there are no aliases. I’m certain I’m missing something, but I don’t know what. To be absolutely clear, a Result is calculated of type:

std::unique_ptr Result;

And CFLAndersAAResult contains member fields:

DenseMap<const Function *, Optional> Cache;

std::forward_list<cflaa::FunctionHandle> Handles;

The DenseMap Cache is empty, and so is Handles.

I can do -print-alias-sets, and that prints something, but I don’t think it’s the result of the Andersen analysis. Because when I do commands with --cfl-anders-aa taken out, I still get the same alias sets.

Can anybody help me get the Andersen alias results?

Ok, the command necessary to get past this is:

opt ./example.ll -disable-basicaa -cfl-anders-aa -aa-eval -disable-output -print-alias-sets

It was non-intuitive, because I thought turning on cfl-anders-aa would also enable printing the alias sets automatically. It also helps to add this flag: -mem2reg