<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Apr 26, 2014 at 4:59 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="">Matthew O'Connor wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi,<br>
<br>
I'm attempting to do some alias analysis & other memory inspection. I've<br>
written a pointless AliasAnalysis pass (that says everything must alias)<br>
to attempt to verify that my pass is getting picked up & run by opt.<br>
<br>
I run opt with: opt -load ~/Applications/llvm/lib/<u></u>MustAA.so -must-aa<br>
-aa-eval -debug < trace0.ll<br>
<br>
I see my pass being initialized, but never being called (I see only may<br>
alias results).<br>
<br>
Any ideas as to what to do to debug this? Or what I'm missing? I've read<br>
through <a href="http://llvm.org/docs/AliasAnalysis.html" target="_blank">http://llvm.org/docs/<u></u>AliasAnalysis.html</a> and don't see anything<br>
that I'm missing.<br>
<br>
Thanks,<br>
Matthew<br>
<br>
P.S. Here's the full source code of my pass:<br>
<br>
#define DEBUG_TYPE "must-aa"<br>
#include "llvm/Pass.h"<br>
#include "llvm/Analysis/AliasAnalysis.<u></u>h"<br>
#include "llvm/Support/raw_ostream.h"<br>
#include "llvm/Support/Debug.h"<br>
using namespace llvm;<br>
<br>
namespace {<br>
struct EverythingMustAlias : public ImmutablePass, public AliasAnalysis {<br>
</blockquote>
<br></div>
Because you have multiple inheritance on a Pass, you'll need this:<br>
<br>
    /// getAdjustedAnalysisPointer - This method is used when a pass implements<br>
    /// an analysis interface through multiple inheritance.  If needed, it<br>
    /// should override this to adjust the this pointer as needed for the<br>
    /// specified pass info.<br>
    void *getAdjustedAnalysisPointer(<u></u>const void *ID) override {<br>
      if (ID == &AliasAnalysis::ID)<br>
        return (AliasAnalysis*)this;<br>
      return this;<br>
    }<br>
<br>
There may be another issue beyond that, I haven't tried it.<br>
<br>
Nick<br></blockquote><div><br></div><div>I overrode Pass's member function:<br>    virtual void *getAdjustedAnalysisPointer(AnalysisID ID);<br><br></div><div>I'm not seeing getAdjustedAnalysisPointer being called.<br>
<br>Any other ideas?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">
   static char ID;<br>
   EverythingMustAlias() : ImmutablePass(ID) {}<br>
<br>
   virtual void initializePass() {<br>
     DEBUG(dbgs() << "Initializing everything-must-alias\n");<br>
     InitializeAliasAnalysis(this);<br>
   }<br>
<br>
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br>
     AliasAnalysis::<u></u>getAnalysisUsage(AU);<br>
     AU.setPreservesAll();<br>
   }<br>
<br>
   virtual AliasResult alias(const Location &LocA, const Location &LocB) {<br>
     DEBUG(dbgs() << "Everything must alias!\n");<br>
     return AliasAnalysis::MustAlias;<br>
   }<br>
};<br>
}<br>
<br>
namespace llvm {<br>
void initializeEverythingMustAliasP<u></u>ass(PassRegistry &Registry);<br>
}<br>
<br>
char EverythingMustAlias::ID = 0;<br>
static RegisterPass<<u></u>EverythingMustAlias> A("must-aa", "Everything must<br>
alias");<br>
INITIALIZE_AG_PASS(<u></u>EverythingMustAlias, AliasAnalysis, "must-aa",<br>
"Everything must alias", false, true, false)<br>
<br>
<br>
<br></div>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote>
<br>
</blockquote></div><br></div></div>