how to let memory dependency analysis use globalsmodref

Hi there,

I am doing:

opt -print-memdeps ./test.bc -analyze -globalsmodref-aa

by adding globalsmodref-aa, I am hoping that globalsmodref alias analysis will be used. However, it does not turn out to be so. I found this out by adding some "errs() << " into the source code for that alias analysis.

So my question is what should I do to let memory dependency analysis use globalsmodref alias analysis.

I have tried other alias analysis and found out that if basic-aa and tbaa can be utilized, but not -libcall-aa -globalsmodref-aa.

I also found out that -libcall-aa -globalsmodref-aa has member function runOnFunction and runOnModule respectively, but basic-aa and tbaa do not.

Again, my question is what should I do to let memory dependency analysis use globalsmodref alias analysis.

Thanks,
Guoliang

Jin Guoliang wrote:

Hi there,

I am doing:

opt -print-memdeps ./test.bc -analyze -globalsmodref-aa

by adding globalsmodref-aa, I am hoping that globalsmodref alias
analysis will be used. However, it does not turn out to be so. I found
this out by adding some "errs() << " into the source code for that alias
analysis.

opt is sensitive to the order of its arguments. Use -debug-pass=Structure to see how the passes are being scheduled"

$ opt -print-memdeps test.bc -analyze -globalsmodref-aa -debug-pass=Structure
Pass Arguments: -targetlibinfo -no-aa -memdep -print-memdeps -basiccg -globalsmodref-aa -preverify -domtree -verify
Target Library Information
No Alias Analysis (always returns 'may' alias)
   ModulePass Manager
     FunctionPass Manager
       Memory Dependence Analysis
       Print MemDeps of function
       FunctionPass Printer: Print MemDeps of function
     Basic CallGraph Construction
     Simple mod/ref analysis for globals
     ModulePass Printer: Simple mod/ref analysis for globals
     FunctionPass Manager
       Preliminary module verification
       Dominator Tree Construction
       Module Verifier

As you see, "print memdeps of function" happened before "simple mod/ref analysis for globals" was ever started. 'opt -analyze -globalsmodref-aa -print-memdeps test.bc' should do what you want:

$ opt -globalsmodref-aa -print-memdeps test.bc -analyze -debug-pass=Structure
Pass Arguments: -targetlibinfo -no-aa -basiccg -globalsmodref-aa -memdep -print-memdeps -preverify -domtree -verify
Target Library Information
No Alias Analysis (always returns 'may' alias)
   ModulePass Manager
     Basic CallGraph Construction
     Simple mod/ref analysis for globals
     ModulePass Printer: Simple mod/ref analysis for globals
     FunctionPass Manager
       Memory Dependence Analysis
       Print MemDeps of function
       FunctionPass Printer: Print MemDeps of function
       Preliminary module verification
       Dominator Tree Construction
       Module Verifier

though you may want to combine -globalsmodref-aa with -basicaa.

Nick