[LLVMdev] Incorrect result in LLVM Alias Analysis

johnso87 at crhc.illinois.edu johnso87 at crhc.illinois.edu
Fri Apr 6 00:46:23 PDT 2012


> I want to check if the values a and b in the program alias.
>
> int main() {
> int *a,*b;
> a=(int *)malloc(sizeof(int));
> b=(int *)malloc(sizeof(int));
> *a=10;
> *b=8;
> return 0;
> }
>

Silly question: did you '#include <stdlib.h>' in your test program?
Does your malloc() declaration include '__attribute__ ((malloc))'?
If malloc() is seen as an implicit def or does not have the special malloc
attribute attached to it (which tells the compiler "non-NULL pointers
returned from this function will not alias any other pointer that's valid
at the time of the call"), the compiler cannot tell out-of-hand that a and
b do not alias.

> I use the below code for this (getAnalysisUsage method has been defined)
>
> AliasAnalysis::Location loc1=AliasAnalysis::Location(k1); //a
> AliasAnalysis::Location loc2=AliasAnalysis::Location(k2); //b
> AliasAnalysis::AliasResult ar=AA.alias(loc1,loc2);
>
> But I get ar=1 i.e May Alias result. Where am I going wrong? I have
> included -basicaa option in the opt command for running this.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>





More information about the llvm-dev mailing list