[LLVMdev] writing an alias analysis pass?

Chen Li meloli87 at gmail.com
Mon Apr 28 21:46:48 PDT 2014


Hi Matthew,

Did you add your alias analysis pass initializeEverythingMustAliasPass() into llvm::initializeAnalysis(PassRegistry &Registry) {} ?
This will initialize it linked into the Analysis library.

thanks,
chen
 
On Apr 28, 2014, at 8:43 PM, Jingyue Wu <jingyue at google.com> wrote:

> 
> 
> 
> On Thu, Apr 24, 2014 at 4:38 PM, Matthew O'Connor <thegreendragon at gmail.com> wrote:
> Hi,
> 
> I'm attempting to do some alias analysis & other memory inspection. I've written a pointless AliasAnalysis pass (that says everything must alias) to attempt to verify that my pass is getting picked up & run by opt.
> 
> I run opt with: opt -load ~/Applications/llvm/lib/MustAA.so -must-aa -aa-eval -debug < trace0.ll
> 
> I see my pass being initialized, but never being called (I see only may alias results). 
> 
> Any ideas as to what to do to debug this? Or what I'm missing? I've read through http://llvm.org/docs/AliasAnalysis.html and don't see anything that I'm missing.
> 
> Thanks,
> Matthew
> 
> P.S. Here's the full source code of my pass:
> 
> #define DEBUG_TYPE "must-aa"
> #include "llvm/Pass.h"
> #include "llvm/Analysis/AliasAnalysis.h"
> #include "llvm/Support/raw_ostream.h"
> #include "llvm/Support/Debug.h"
> using namespace llvm;
> 
> namespace {
> struct EverythingMustAlias : public ImmutablePass, public AliasAnalysis {
>   static char ID;
>   EverythingMustAlias() : ImmutablePass(ID) {}
> 
>   virtual void initializePass() {
>     DEBUG(dbgs() << "Initializing everything-must-alias\n");
>     InitializeAliasAnalysis(this);
>   }
> 
>   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
>     AliasAnalysis::getAnalysisUsage(AU);
>     AU.setPreservesAll();
>   }
> 
>   virtual AliasResult alias(const Location &LocA, const Location &LocB) {
>     DEBUG(dbgs() << "Everything must alias!\n");
>     return AliasAnalysis::MustAlias;
>   }
> };
> }
> 
> namespace llvm {
> void initializeEverythingMustAliasPass(PassRegistry &Registry);
> }
> 
> char EverythingMustAlias::ID = 0;
> static RegisterPass<EverythingMustAlias> A("must-aa", "Everything must alias");
>  
> static RegisterPass<EverythingMustAlias> A("must-aa", "Everything must alias", false, true);
> 
> Can you try this? 
>  
> INITIALIZE_AG_PASS(EverythingMustAlias, AliasAnalysis, "must-aa",
>                    "Everything must alias", false, true, false)
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140428/afa22b80/attachment.html>


More information about the llvm-dev mailing list