Kenneth Uildriks wrote:> > Does the error function *have* to be auto-generated in your pass? > Perhaps the original code should use invokes, and your pass insert the > error check with a jne to the "unwind" block. >If I understand correctly, unwind is some kind of exception handling in LLVM IR? I'm not sure if this is the right thing. First, I include runtime checks inst programs that are already written during their compilation (with my modified version of LLVM). Second, the error handling is a (context independent) program termination, so it is of no use to replicate it at every call. So I was searching for a possibility to include an additional (Machine)BasicBlock (or rather a MachineFunction?) somewhere in the program that contains the program termination and that I can jump to on check failure. Can't I do that during a Pass in llc? -Artjom -- View this message in context: http://www.nabble.com/code-altering-Passes-for-llc-tp24778261p24845838.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On Aug 6, 2009, at 5:45 AM, Artjom Kochtchi wrote:> So I was searching for a possibility to include an additional > (Machine)BasicBlock (or rather a MachineFunction?) somewhere in the > program > that contains the program termination and that I can jump to on check > failure. Can't I do that during a Pass in llc?If you just have a magic block of instructions you want to stick somewhere, a module-level inline asm may be the easiest way. If you have higher-level language code you want to stick somewhere, you should probably create a new Function (and/or MachineFunction) that can be "called", so that it plays nicely with the rest of the compiler. Dan
I tried to insert a new MachineBasicBlock at the beginning of functions, but when I do that like MachineBasicBlock *entry = MF.begin(); const BasicBlock *block = entry->getBasicBlock(); MachineBasicBlock *newMBB = MF.CreateMachineBasicBlock(block); MachineInstrBuilder instr = BuildMI(labelBlock, TII->get(X86::NOOP)); newMBB->addSuccessor(entry); MF.push_front(newMBB); llc fails with the following error message. Can someone tell me what I am doing wrong? llc: MachineRegisterInfo.cpp:33: llvm::MachineRegisterInfo::~MachineRegisterInfo(): Assertion `!PhysRegUseDefLists[i] && "PhysRegUseDefLists has entries after all instructions are deleted"' failed. Apart from that llc fails when I run my modified version on larger test programs. The error message displayed is: lc: MachineBasicBlock.cpp:361: bool llvm::MachineBasicBlock::CorrectExtraCFGEdges(llvm::MachineBasicBlock*, llvm::MachineBasicBlock*, bool): Assertion `DestA == 0 && "MachineCFG is missing edges!"' failed. I did not overwrite getAnalysisUsage, therefore not guaranteeing to preserve anything. Clearly, the runtime check adds edges to the CFG. What may be the cause of this error and how can I fix it? -Artjom -- View this message in context: http://www.nabble.com/code-altering-Passes-for-llc-tp24778261p24988862.html Sent from the LLVM - Dev mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090815/55df5843/attachment.html>