Hi
I have this simple c code for which I would like to use for alias analysis.
#include <stdio.h>
#include <stdlib.h>
static int (*fp) (void);
void ind_call (int (*compr)(void)){
fp = compr;
fp();
}
int hello(void){
return printf(“hello world\n”);
}
int main(){
ind_call(hello);
return 0;
}
So, I do the following:
bin/opt -basicaa -cfl-anders-aa -print-alias-sets bin/test/test.bc
I get the following result:
Alias sets for function ‘ind_call’:
Alias Set Tracker: 2 alias sets for 2 pointer values.
AliasSet[0x91a5820, 1] must alias, Mod/Ref Pointers: (i32 ()** %compr.addr, 8)
AliasSet[0x91a58c0, 2] may alias, Mod/Ref Pointers: (i32 ()** @fp, 8)
1 Unknown instructions: i32 %call
Alias sets for function ‘hello’:
Alias Set Tracker: 1 alias sets for 0 pointer values.
AliasSet[0x91a5910, 1] may alias, Mod/Ref
1 Unknown instructions: i32 %call
Alias sets for function ‘main’:
Alias Set Tracker: 2 alias sets for 1 pointer values.
AliasSet[0x91a5a50, 1] must alias, Mod Pointers: (i32* %retval, 4)
AliasSet[0x91a5aa0, 1] may alias, Mod/Ref
1 Unknown instructions: void
My question is from c code when we can notice that fp and compr target to same address (because of fp = compr), why they are not in the same alias set. As you can see, for function ind_call, the alias set that contain fp is along, while from my understanding there should be another alias compr.
For better understanding, I also include the LLVM IR here (generated by LLVM-7.0):