[LLVMdev] write a simple MachineFunctionPass
Alexandru Ionut Diaconescu
alexandruionutdiaconescu at gmail.com
Fri Mar 15 05:30:23 PDT 2013
Hello everyone,
I have written several complex passes till now, but I cannot write a
MachineFunctionPass pass. It just gives me segfault. Hence I reduced the
pass to the following form :
using namespace llvm;
namespace {
class CFGexplorator : public MachineFunctionPass {
public:
static char ID; // Pass identification, replacement for typeid
CFGexplorator() : MachineFunctionPass(ID) {
//initializeMemDepPrinterPass(*PassRegistry::getPassRegistry());
}
private:
virtual bool runOnMachineFunction(MachineFunction &MF);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
MachineFunctionPass::getAnalysisUsage(AU);
}
};
} // end anonymous namespace
char CFGexplorator::ID = 0;
static RegisterPass<CFGexplorator> Y("mycfg", "mycfg", false, false);
bool CFGexplorator::runOnMachineFunction(MachineFunction &MF) {
return false;
}
I get the error :
Pass 'mycfg' is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
opt: PassManager.cpp:638: void
llvm::PMTopLevelManager::schedulePass(llvm::Pass*): Assertion `PI &&
"Expected required passes to be initialized"' failed.
So I have to initialize the pass. But in my all other passes I did not any
initialization and I don't want to use INITIALIZE_PASS since I have to
recompile the llvm file that is keeping the pass registration... Is there a
way to keep using static RegisterPass for a MachineFunctionPass ? I mention
that if I change to FunctionPass, I have no problems and that is weird..
Thank you for any advice !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130315/3262431e/attachment.html>
More information about the llvm-dev
mailing list