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; } 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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120406/a53dadea/attachment.html>
> 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 alias analysis might be not so powerful at this moment, I guess. Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj
johnso87 at crhc.illinois.edu
2012-Apr-06 07:46 UTC
[LLVMdev] Incorrect result in LLVM Alias Analysis
> 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 >
Hi Adarsh,> 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; > } > > 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?did you run a basic set of optimizers first? Alias analysis assumes that at least mem2reg has been run. Otherwise it returns conservatively correct but useless answers for everything. I have included> -basicaa option in the opt command for running this.Ciao, Duncan.
I have used the following command, opt -load LLVComMan.so -ComMan -memdep -tbaa -mem2reg maptest.ll -S What option other than -mem2reg should be included in this case to get the right results? Does the order in which I specify the optimizations to be run make a difference? Duncan Sands wrote:> > Hi Adarsh, > >> 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; >> } >> >> 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? > > did you run a basic set of optimizers first? Alias analysis assumes that > at least mem2reg has been run. Otherwise it returns conservatively > correct > but useless answers for everything. > > > I have included >> -basicaa option in the opt command for running this. > > Ciao, Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://old.nabble.com/Incorrect-result-in-LLVM-Alias-Analysis-tp33642041p33668700.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
I have used the follwing command, opt -load LLVComMan.so -ComMan -memdep -tbaa -mem2reg maptest.ll -S What option other than -mem2reg should be included in this case to get the right results? Does the order in which I specify the optimizations to be run make a difference? Duncan Sands wrote:> > Hi Adarsh, > >> 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; >> } >> >> 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? > > did you run a basic set of optimizers first? Alias analysis assumes that > at least mem2reg has been run. Otherwise it returns conservatively > correct > but useless answers for everything. > > > I have included >> -basicaa option in the opt command for running this. > > Ciao, Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://old.nabble.com/Incorrect-result-in-LLVM-Alias-Analysis-tp33642041p33668704.html Sent from the LLVM - Dev mailing list archive at Nabble.com.