Hello,<br><br>I'd appreciate it if anyone can tell me what the error message means and point out what I am doing wrong.<br>Thank you.<br>
<br><br>I am trying to use the result of the DominatorTree analysis in my ModulePass class as explained in the section "Writing an LLVM Pass".<br><a href="http://llvm.org/docs/WritingAnLLVMPass.html#interaction">http://llvm.org/docs/WritingAnLLVMPass.html#interaction</a><br>
I called the method "addRequired<DominatorTree>()" in the method "getAnalysisUsage(AnalysisUsage&)", but I get the following error message.<br><br>opt: /usr/local/llvm/llvm/include/llvm/PassAnalysisSupport.h:193:
AnalysisType& llvm::Pass::getAnalysisID(const llvm::PassInfo*)
const [with AnalysisType = llvm::DominatorTree]: Assertion `ResultPass
&& "getAnalysis*() called on an analysis that was not "
"'required' by pass!"' failed.<br>
<br>The following is the command I typed in:<br>opt -load /usr/local/llvm/install/lib/mymodulepass.so -mymodulepass <idct.bc > /dev/null<br><br>Here are the header and implementation files of my class with just the bare minimum that produces the error messages.<br>
(MyModulePass.h)<br>#ifndef MYMODULEPASS_H<br>#define MYMODULEPASS_H<br>#include "llvm/Pass.h"<br><br>namespace llvm {<br> class MyModulePass : public ModulePass {<br> public:<br> static char ID; // Pass identification, replacement for typeid<br>
MyModulePass();<br> virtual bool runOnModule(Module &M);<br> virtual void getAnalysisUsage(AnalysisUsage &Info) const;<br><br> };<br><br> extern RegisterPass<MyModulePass> X_MyModulePass;<br>
}<br><br>#endif<br><br>(MyModulePass.cpp)<br>#include <iostream><br>#include "MyModulePass.h"<br>#include "llvm/Module.h"<br>#include "llvm/Function.h"<br>#include "llvm/BasicBlock.h"<br>
#include "llvm/Analysis/Dominators.h"<br>#include "llvm/Analysis/AliasAnalysis.h"<br><br>using namespace llvm;<br><br>
// ID, register<br>char llvm::MyModulePass::ID = 0;<br>RegisterPass<llvm::MyModulePass> llvm::X_MyModulePass("mymodulepass", "My Module Pass");<br><br>MyModulePass::MyModulePass() : ModulePass((intptr_t)&MyModulePass::ID) {<br>
}<br><br>bool MyModulePass::runOnModule(Module &m) {<br> for (Module::const_iterator f = m.begin(); f != m.end(); ++f)<br> DominatorTree &dt = getAnalysis<DominatorTree>();<br><br> return false;<br>
}<br><br>void MyModulePass::getAnalysisUsage(AnalysisUsage &info) const {<br> info.addRequired<DominatorTree>();<br>}<br><br>