Antony Yu
2013-Jun-22 14:36 UTC
[LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX
I write my pass in a mix way of NVPTXAllocaHoisting, NVPTXSplitBBatBar and transforms/Hello. The following is part of the codes: in NVPTXTargetMachine.cpp bool NVPTXPassConfig::addPreEmitPass() { addPass(createTest()); return false; } in NVPTXTest.h namespace llvm{ class NVPTXTest : public ModulePass { void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } }; extern ModulePass *createTest(); } in NVPTXTest.cpp namespace llvm { char NVPTXTest::ID = 0; static RegisterPass<NVPTXTest> X("test", "Test Module Pass"); ModulePass *createTest() { return new NVPTXTest(); } } Thanks Antony Yu -- View this message in context: http://llvm.1065342.n5.nabble.com/About-writing-a-modulePass-in-addPreEmitPass-for-NVPTX-tp58701p58752.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Antony Yu
2013-Jun-24 15:20 UTC
[LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX
I try to use INITIALIZE_PASS instead of RegisterPass<> to register my pass, though I don't understand what's their difference and how it works because its documents doesn't exist. But it still doesn't work. Parts of my codes is as follows: in NVPTXTest.h namespace llvm { void initializeNVPTXTestPass(PassRegistry &r); class NVPTXTest : public ModulePass { public: NVPTXTest() : ModulePass(ID){ initializeNVPTXTestPass(*PassRegistry::getPassRegistry()); } void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); ModulePass::getAnalysisUsage(AU); } }; in NVPTXTest.cpp #include "NVPTXTest.h" namespace llvm { //static RegisterPass<NVPTXTest> X("test", "Test Module Pass"); char NVPTXTest::ID = 0; ModulePass *createTest() { return new NVPTXTest(); } } using namespace llvm; INITIALIZE_PASS(NVPTXTest, "test", "TestModule Pass", true, true); ===When I use the same way to write a CallGraphSCCPass, it still doesn't work, but this time it tells me that my CallGraphSCCPass is not initialized instead of 'NVPTX Assembly Printer'. It's really weird... -- View this message in context: http://llvm.1065342.n5.nabble.com/About-writing-a-modulePass-in-addPreEmitPass-for-NVPTX-tp58701p58770.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Justin Holewinski
2013-Jun-24 18:15 UTC
[LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX
Sorry for the delay. Yeah, that error message is a bit confusing. What's happening is that your pass sequence is invalid. Once the IR has been lowered to machine code, its too late to run LLVM IR passes (ModulePass, FunctionPass, CallGraphSCCPass, etc.). At that point, you need to run a Machine*Pass, e.g. MachineFunctionPass. If you need to run an IR level pass, you need to use addIRPasses(). On Mon, Jun 24, 2013 at 11:20 AM, Antony Yu <swpenim at gmail.com> wrote:> I try to use INITIALIZE_PASS instead of RegisterPass<> to register my pass, > though I don't understand what's their difference and how it works because > its documents doesn't exist. But it still doesn't work. > > Parts of my codes is as follows: > > in NVPTXTest.h > > namespace llvm { > > void initializeNVPTXTestPass(PassRegistry &r); > > class NVPTXTest : public ModulePass > { > public: > > NVPTXTest() : ModulePass(ID){ > initializeNVPTXTestPass(*PassRegistry::getPassRegistry()); > } > void getAnalysisUsage(AnalysisUsage &AU) const { > AU.setPreservesAll(); > ModulePass::getAnalysisUsage(AU); > } > > }; > > in NVPTXTest.cpp > > #include "NVPTXTest.h" > > namespace llvm > { > //static RegisterPass<NVPTXTest> X("test", "Test Module Pass"); > char NVPTXTest::ID = 0; > ModulePass *createTest() > { > return new NVPTXTest(); > } > } > using namespace llvm; > > INITIALIZE_PASS(NVPTXTest, "test", "TestModule Pass", true, true); > ===> When I use the same way to write a CallGraphSCCPass, it still doesn't work, > but this time it tells me that my CallGraphSCCPass is not initialized > instead of 'NVPTX Assembly Printer'. > It's really weird... > > > > > -- > View this message in context: > http://llvm.1065342.n5.nabble.com/About-writing-a-modulePass-in-addPreEmitPass-for-NVPTX-tp58701p58770.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130624/b3ee415a/attachment.html>
Possibly Parallel Threads
- [LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX
- [LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX
- [LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX
- [LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX
- [LLVMdev] About writing a modulePass in addPreEmitPass() for NVPTX