Hi I am completely new to LLVM, and I am trying to explore the alias analysis part of it. It seems to me that -basicaa is the most simple alias analysis pass in LLVM. So I would like to try and make it work (to see some alias analysis results of some sample bit code). What I have done is that I ---make lib/Analysis/BasicAliasAnalysis.cpp into a .so file ---write a sample c program, hello.c, with the following code #include<stdio.h> int main() { int a; int *p; p = &a; a = 10; printf("Hello World"); return 0; } ---compile the c program into bit code by doing clang -c -emit-llvm hello.c -o hello.bc ---run the bit code through basicaa pass opt -load lib/AliasAnalysis.so -basicaa < hello.bc > result.bc ---display the resulted bit code llvm-dis result.bc -o - However, the resulted bit code result.bc is exactly the same as the original bit code hello.bc. That is no alias analysis information is printed on the screen or recorded in the resulting result.bc file. Could someone explain what I should do to get some results from basicaa alias analysis pass? Thank you very much. Your help is much appreciated! Sheng-Hsiu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150121/0f9d400e/attachment.html>
Hi Sheng-Hsiu, On Wed, Jan 21, 2015 at 8:09 AM, Sheng-Hsiu Lin <shl311 at lehigh.edu> wrote:> Hi > > I am completely new to LLVM, and I am trying to explore the alias analysis > part of it. It seems to me that -basicaa is the most simple alias analysis > pass in LLVM. So I would like to try and make it work (to see some alias > analysis results of some sample bit code). > > What I have done is that I > > ---make lib/Analysis/BasicAliasAnalysis.cpp into a .so file > ---write a sample c program, hello.c, with the following code > > #include<stdio.h> > > int main() > { > int a; > int *p; > p = &a; > a = 10; > printf("Hello World"); > return 0; > } > > ---compile the c program into bit code by doing > clang -c -emit-llvm hello.c -o hello.bc > > ---run the bit code through basicaa pass > opt -load lib/AliasAnalysis.so -basicaa < hello.bc > result.bc > > ---display the resulted bit code > llvm-dis result.bc -o - > > However, the resulted bit code result.bc is exactly the same as the original > bit code hello.bc. That is no alias analysis information is printed on the > screen or recorded in the resulting result.bc file. > > Could someone explain what I should do to get some results from basicaa > alias analysis pass?Alias analyses (and for that matter, other kinds of analyses) don't do any transformation on their own, but merely provide the analysis result for other transformations to use. See the related documentation page (http://llvm.org/docs/AliasAnalysis.html) for more information. There are several tools to help evaluate alias analysis results, (in part) documented on that same page; a good starting point would be -aa-eval, and the associated options (-print-no-aliases, etc.. See lib/Analysis/AliasAnalysisEvaluator.cpp). -Ahmed> Thank you very much. Your help is much appreciated! > > Sheng-Hsiu > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hi, I think you're looking for the -print-alias-sets option in opt http://llvm.org/docs/AliasAnalysis.html#the-print-alias-sets-pass Also two other small remarks: 1) The alias analysis is a pass provided by LLVM itself so you won't have to load it as a library 2) Alias analysis only does analysis and this information gets used by other passes. Only running the alias analysis won't change the program. Opt has an option -disable-output, which disables the bitcode output (it will still print the debug output though). That would make your opt command: > opt -load lib/AliasAnalysis.so -basicaa < hello.bc > result.bc More like this: opt -basicaa -print-alias-sets -disable-output hello.bc Cheers, Roel On 21/01/15 17:09, Sheng-Hsiu Lin wrote:> Hi > > I am completely new to LLVM, and I am trying to explore the alias > analysis part of it. It seems to me that -basicaa is the most simple > alias analysis pass in LLVM. So I would like to try and make it work > (to see some alias analysis results of some sample bit code). > > What I have done is that I > > ---make lib/Analysis/BasicAliasAnalysis.cpp into a .so file > ---write a sample c program, hello.c, with the following code > > #include<stdio.h> > > int main() > { > int a; > int *p; > p = &a; > a = 10; > printf("Hello World"); > return 0; > } > > ---compile the c program into bit code by doing > clang -c -emit-llvm hello.c -o hello.bc > > ---run the bit code through basicaa pass > opt -load lib/AliasAnalysis.so -basicaa < hello.bc > result.bc > > ---display the resulted bit code > llvm-dis result.bc -o - > > However, the resulted bit code result.bc is exactly the same as the > original bit code hello.bc. That is no alias analysis information is > printed on the screen or recorded in the resulting result.bc file. > > Could someone explain what I should do to get some results from basicaa > alias analysis pass? > > Thank you very much. Your help is much appreciated! > > Sheng-Hsiu > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Specifying -basicaa only tells opt to run the basic alias analysis pass. However, since this is not a transformation pass, but, rather, an analysis that is meant to be used by transformations, you will not see any change in the bitcode. If you want to see the results in a human-readable form, you can try something like: opt -basicaa -aa-eval -print-all-alias-modref-info < hello.bc Michael From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Sheng-Hsiu Lin Sent: Wednesday, January 21, 2015 18:10 To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] Using basicaa alias analysis pass Hi I am completely new to LLVM, and I am trying to explore the alias analysis part of it. It seems to me that -basicaa is the most simple alias analysis pass in LLVM. So I would like to try and make it work (to see some alias analysis results of some sample bit code). What I have done is that I ---make lib/Analysis/BasicAliasAnalysis.cpp into a .so file ---write a sample c program, hello.c, with the following code #include<stdio.h> int main() { int a; int *p; p = &a; a = 10; printf("Hello World"); return 0; } ---compile the c program into bit code by doing clang -c -emit-llvm hello.c -o hello.bc ---run the bit code through basicaa pass opt -load lib/AliasAnalysis.so -basicaa < hello.bc > result.bc ---display the resulted bit code llvm-dis result.bc -o - However, the resulted bit code result.bc is exactly the same as the original bit code hello.bc. That is no alias analysis information is printed on the screen or recorded in the resulting result.bc file. Could someone explain what I should do to get some results from basicaa alias analysis pass? Thank you very much. Your help is much appreciated! Sheng-Hsiu --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150121/065141c0/attachment.html>
Ahmed, Roel and Michael, Thank you so much for clarifying this for me. Now if I want to use the result of basicaa pass to do some transformation, I suppose I will need write a pass, correct? Is there a good document on this (specifically on writing a pass to act on alias analysis results) that I could refer to? Thanks again! Sheng-Hsiu On Wed, Jan 21, 2015 at 11:58 AM, Kuperstein, Michael M < michael.m.kuperstein at intel.com> wrote:> Specifying -basicaa only tells opt to run the basic alias analysis pass. > > However, since this is not a transformation pass, but, rather, an analysis > that is meant to be used by transformations, you will not see any change in > the bitcode. > > > > If you want to see the results in a human-readable form, you can try > something like: > > opt -basicaa -aa-eval -print-all-alias-modref-info < hello.bc > > > > Michael > > > > *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] *On > Behalf Of *Sheng-Hsiu Lin > *Sent:* Wednesday, January 21, 2015 18:10 > *To:* llvmdev at cs.uiuc.edu > *Subject:* [LLVMdev] Using basicaa alias analysis pass > > > > Hi > > > > I am completely new to LLVM, and I am trying to explore the alias analysis > part of it. It seems to me that -basicaa is the most simple alias analysis > pass in LLVM. So I would like to try and make it work (to see some alias > analysis results of some sample bit code). > > > > What I have done is that I > > > > ---make lib/Analysis/BasicAliasAnalysis.cpp into a .so file > > ---write a sample c program, hello.c, with the following code > > > > #include<stdio.h> > > > > int main() > > { > > int a; > > int *p; > > p = &a; > > a = 10; > > printf("Hello World"); > > return 0; > > } > > > > ---compile the c program into bit code by doing > > clang -c -emit-llvm hello.c -o hello.bc > > > > ---run the bit code through basicaa pass > > opt -load lib/AliasAnalysis.so -basicaa < hello.bc > result.bc > > > > ---display the resulted bit code > > llvm-dis result.bc -o - > > > > However, the resulted bit code result.bc is exactly the same as the > original bit code hello.bc. That is no alias analysis information is > printed on the screen or recorded in the resulting result.bc file. > > > > Could someone explain what I should do to get some results from basicaa > alias analysis pass? > > > > Thank you very much. Your help is much appreciated! > > > > Sheng-Hsiu > > --------------------------------------------------------------------- > Intel Israel (74) Limited > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150121/417dd1c4/attachment.html>