[LLVMdev] code-altering Passes for llc
Artjom Kochtchi
artjom.kochtchi at googlemail.com
Sun Aug 2 07:09:03 PDT 2009
Greetinigs,
I am extending llc to include runtime checks for calls (in X86). So a call
'call target' is altered to look like this:
[some check]
jne error_function
call target
I've done this by implementing a MachineFunctionPass that is instantiated
and added to the PassManager in X86TargetMachine::addPreRegAlloc.
In order to create the jne-instruction I need some BasicBlock that contains
the error routine. So I tried to create a ModulePass to insert some basic
block e. g. in the beginning of the program, to use it for the
jne-instruction. Unfortunately, llc then produces the error
llc: PassManager.cpp:1597:
virtual void llvm::ModulePass::assignPassManager(llvm::PMStack&,
llvm::PassManagerType):
Assertion `!PMS.empty() && "Unable to find appropriate Pass Manager"'
failed.
Adding a MachineFunctionPass the same way works fine. I've read here on the
mailing list that some Pass dependencies cause this error, but I have no
dependencies specified.
How do I get the ModulePass to run? Is a ModulePass the right way to
accomplish my aim, altogether?
One more question concerning passes:
Clearly, inserting a jne-instruction changes control flow, so the CFG is not
up to date after the pass. Do I set AnalysisUsage in getAnalysisUsage to
preserve nothing? In that case, is the CFG updated automatically by LLVM or
do I need to apply the changes during the Pass not only the the
MachineFunction, but also the the CFG?
-Artjom
--
View this message in context: http://www.nabble.com/code-altering-Passes-for-llc-tp24778261p24778261.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
More information about the llvm-dev
mailing list