<div dir="ltr">We have discovered the issue with our code.  It seems that when the first call to doInitilization utilized one of the specified analyses, that analysis had never been properly added as required.  Using gdb, we can see that addRequired is getting called (seen below) but when doInitalization is finally called, it still responds as if the analysis was not required.<br>
<br>Is this a bug or is doInitialization not permitted to access other analyses?<br><br>Our code functions correctly as a function pass as well as on any program that has other functions prior to the main function.  It only fails in this manner when main is the first (or only) function in the source file.<br>
<br><br>Debugging information:<br><br>Breakpoint 2, getAnalysisUsage (this=0x88072c8, AU=@0xbfa352f8) at /home/pprabhu/llvm/llvm/lib/Transforms/Instrumentation/LAMPProfiling.cpp:93<br>93                AU.addRequired<LdStCallCounter>();<br>
(gdb) c<br>Continuing.<br><br>Breakpoint 2, getAnalysisUsage (this=0x88072c8, AU=@0xbfa350b4) at /home/pprabhu/llvm/llvm/lib/Transforms/Instrumentation/LAMPProfiling.cpp:93<br>93                AU.addRequired<LdStCallCounter>();<br>
(gdb) c<br>Continuing.<br><br>Breakpoint 2, getAnalysisUsage (this=0x88072c8, AU=@0xbfa35088) at /home/pprabhu/llvm/llvm/lib/Transforms/Instrumentation/LAMPProfiling.cpp:93<br>93                AU.addRequired<LdStCallCounter>();<br>
(gdb) c<br>Continuing.<br>32 30 5<br><br>Breakpoint 3, doInitialization (this=0x88072c8, F=@0x8807d90) at /home/pprabhu/llvm/llvm/lib/Transforms/Instrumentation/LAMPProfiling.cpp:135<br>135            const char* FnName = "LAMP_init";<br>
(gdb) n<br>137            if (lampFuncs[0] == NULL)<br>(gdb) n<br>139                Module* M = F.getParent();<br>(gdb) n<br>140                createLampDeclarations(M);<br>(gdb) n<br>143            if (F.getName() == "main") {<br>
(gdb) n<br>145                Module* M = F.getParent();<br>(gdb) n<br>146                LdStCallCounter& lscnts = getAnalysis<LdStCallCounter>();<br>(gdb) n<br>opt: /home/pprabhu/llvm/llvm/include/llvm/PassAnalysisSupport.h:193: AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*) const [with AnalysisType = <unnamed>::LdStCallCounter]: Assertion `ResultPass && "getAnalysis*() called on an analysis that was not " "'required' by pass!"' failed.<br>
<br><br><br><div class="gmail_quote">On Thu, Jul 17, 2008 at 3:55 PM, Thomas Mason <<a href="mailto:thomasr.mason@gmail.com">thomasr.mason@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">Hey all,<br><br>We have been working on a pass that uses another pass to count loads and stores prior to performing its own instrumentation.  The second pass adds the first as required via the usual getAnalysisUsage function.  On one machine, it has been tested and proven to function correctly.  On another machine, whenever the second pass is run, it consistently fails the assertion:<br>

<br>opt: /home/tmason/llvm/llvm/include/llvm/PassAnalysisSupport.h:193: AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*) const [with AnalysisType = <unnamed>::LdStCallCounter]: Assertion `ResultPass && "getAnalysis*() called on an analysis that was not " "'required' by pass!"' failed.<br>

<br>We have modified opt.cpp with the following lines:<br>  addPass(PM, createLdStCallCounter());         // tmason<br>  addPass(PM, createLAMPProfilerPass());         // tmason<br><br>We have modified Instrumentation.h with the following lines:<br>

ModulePass* createLdStCallCounter();<br>BasicBlockPass *createLAMPProfilerPass();<br><br>The .cpp file generating the error is attached.<br><br>Both machines run Ubuntu 8.0.4 with gcc <a href="http://4.2.3." target="_blank">4.2.3.</a>  Does anyone know what could be causing this error to occur on one machine but not another?<br>

<br><br>Thanks,<br>Thomas<br></div>
</blockquote></div><br></div>