Chris.Dewhurst via llvm-dev
2016-Apr-27 22:49 UTC
[llvm-dev] [Sparc] Undefined temporary symbol
Hi, I'm trying to work out what to do to eliminate an "Undefined temporary symbol", which has appeared after I had thought I'd cleared up the last problems trying to implement __builtin_setjmp. I know that the symbol it's referring to is "sinkMBB" in the two BuildMI instructions in the code fragment below, as the problem goes away if I remove these lines temporarily (although the algorithm doesn't work then). What must I do to eliminate the Undefined Temporary Symbol error, later in the compilation process (raised at ElfObjectWriter.cpp:803)? Chris Dewhurst, Lero, University of Limerick + const BasicBlock *BB = MBB->getBasicBlock(); + MachineFunction::iterator It = ++MBB->getIterator(); + MachineBasicBlock *thisMBB = MBB; + const BasicBlock* mainBB = BasicBlock::Create(BB->getContext(), "setjmp.main"); + MachineBasicBlock *mainMBB = MF->CreateMachineBasicBlock(mainBB); + mainMBB->setHasAddressTaken(); + const BasicBlock* sinkBB = BasicBlock::Create(BB->getContext(), "setjmp.sink"); + MachineBasicBlock *sinkMBB = MF->CreateMachineBasicBlock(sinkBB); + sinkMBB->setHasAddressTaken(); + + MF->insert(It, mainMBB); + MF->insert(It, sinkMBB); + + // Transfer the remainder of BB and its successor edges to sinkMBB. + sinkMBB->splice(sinkMBB->begin(), MBB, + std::next(MachineBasicBlock::iterator(MI)), + MBB->end()); + sinkMBB->transferSuccessorsAndUpdatePHIs(MBB); + + MachineInstrBuilder MIB; + + unsigned LabelReg = MRI.createVirtualRegister(&SP::IntRegsRegClass); + unsigned BufReg = MI->getOperand(1).getReg(); + + MIB = BuildMI(*thisMBB, MI, DL, TII->get(SP::SETHIi)) + .addReg(LabelReg, RegState::Define) + .addMBB(sinkMBB, SparcMCExpr::VK_Sparc_HI); + MIB.setMemRefs(MMOBegin, MMOEnd); + + MIB = BuildMI(*thisMBB, MI, DL, TII->get(SP::ADDri)) + .addReg(LabelReg) + .addReg(LabelReg) + .addMBB(sinkMBB, SparcMCExpr::VK_Sparc_LO); + MIB.setMemRefs(MMOBegin, MMOEnd); + -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160427/fa5f6c4f/attachment.html>
Reid Kleckner via llvm-dev
2016-Apr-27 22:58 UTC
[llvm-dev] [Sparc] Undefined temporary symbol
Sounds like you haven't updated the machine CFG to keep the basic block containing the label alive. See how addSuccessor is used in the X86 lowering. On Wed, Apr 27, 2016 at 3:49 PM, Chris.Dewhurst via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > > I'm trying to work out what to do to eliminate an "Undefined temporary > symbol", which has appeared after I had thought I'd cleared up the last > problems trying to implement __builtin_setjmp. > > I know that the symbol it's referring to is "sinkMBB" in the two BuildMI > instructions in the code fragment below, as the problem goes away if I > remove these lines temporarily (although the algorithm doesn't work then). > > What must I do to eliminate the Undefined Temporary Symbol error, later in > the compilation process (raised at ElfObjectWriter.cpp:803)? > > Chris Dewhurst, Lero, University of Limerick > > + const BasicBlock *BB = MBB->getBasicBlock(); > + MachineFunction::iterator It = ++MBB->getIterator(); > + MachineBasicBlock *thisMBB = MBB; > + const BasicBlock* mainBB = BasicBlock::Create(BB->getContext(), > "setjmp.main"); > + MachineBasicBlock *mainMBB = MF->CreateMachineBasicBlock(mainBB); > + mainMBB->setHasAddressTaken(); > + const BasicBlock* sinkBB = BasicBlock::Create(BB->getContext(), > "setjmp.sink"); > + MachineBasicBlock *sinkMBB = MF->CreateMachineBasicBlock(sinkBB); > + sinkMBB->setHasAddressTaken(); > + > + MF->insert(It, mainMBB); > + MF->insert(It, sinkMBB); > + > + // Transfer the remainder of BB and its successor edges to sinkMBB. > + sinkMBB->splice(sinkMBB->begin(), MBB, > + std::next(MachineBasicBlock::iterator(MI)), > + MBB->end()); > + sinkMBB->transferSuccessorsAndUpdatePHIs(MBB); > + > + MachineInstrBuilder MIB; > + > + unsigned LabelReg = MRI.createVirtualRegister(&SP::IntRegsRegClass); > + unsigned BufReg = MI->getOperand(1).getReg(); > + > + MIB = BuildMI(*thisMBB, MI, DL, TII->get(SP::SETHIi)) > + .addReg(LabelReg, RegState::Define) > + .addMBB(sinkMBB, SparcMCExpr::VK_Sparc_HI); > + MIB.setMemRefs(MMOBegin, MMOEnd); > + > + MIB = BuildMI(*thisMBB, MI, DL, TII->get(SP::ADDri)) > + .addReg(LabelReg) > + .addReg(LabelReg) > + .addMBB(sinkMBB, SparcMCExpr::VK_Sparc_LO); > + MIB.setMemRefs(MMOBegin, MMOEnd); > + > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160427/3658e979/attachment.html>