diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-07-02 19:54:40 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-07-02 19:54:40 +0000 |
commit | cf6c5c960f512ab1c5046b3a1c2dd8c503cc32fc (patch) | |
tree | 3139e72741860939b3b7c8ee87340fc8afdc43e7 /llvm/lib/CodeGen | |
parent | b6c9e103a103b24dc96917497a0bb9450d921a6b (diff) | |
download | bcm5719-llvm-cf6c5c960f512ab1c5046b3a1c2dd8c503cc32fc.tar.gz bcm5719-llvm-cf6c5c960f512ab1c5046b3a1c2dd8c503cc32fc.zip |
Properly handle debug values during inline spilling.
llvm-svn: 107503
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/InlineSpiller.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index 405ec258d5c..71305ed8636 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -245,20 +245,21 @@ void InlineSpiller::reMaterializeAll() { return; // Removing values may cause debug uses where li_ is not live. - for (MachineRegisterInfo::use_iterator - RI = mri_.use_begin(li_->reg), RE = mri_.use_end(); RI != RE;) { - MachineOperand &MO = RI.getOperand(); - MachineInstr *MI = MO.getParent(); - ++RI; - SlotIndex UseIdx = lis_.getInstructionIndex(MI).getUseIndex(); - DEBUG(dbgs() << "\tremaining use: " << UseIdx << '\t' << *MI); - if (li_->liveAt(UseIdx)) + for (MachineRegisterInfo::use_iterator RI = mri_.use_begin(li_->reg); + MachineInstr *MI = RI.skipInstruction();) { + if (!MI->isDebugValue()) continue; - assert(MI->isDebugValue() && "Remaining non-debug use after remat dead."); - if (li_->empty()) - MO.setIsUndef(); - else - MO.setReg(0); + // Try to preserve the debug value if li_ is live immediately after it. + MachineBasicBlock::iterator NextMI = MI; + ++NextMI; + if (NextMI != MI->getParent()->end() && !lis_.isNotInMIMap(NextMI)) { + SlotIndex NearIdx = lis_.getInstructionIndex(NextMI); + if (li_->liveAt(NearIdx)) + continue; + } + DEBUG(dbgs() << "Removing debug info due to remat:" << "\t" << *MI); + assert(&*RI != MI && "Multiple register operands on debug value"); + MI->eraseFromParent(); } } @@ -348,6 +349,24 @@ void InlineSpiller::spill(LiveInterval *li, for (MachineRegisterInfo::reg_iterator RI = mri_.reg_begin(li->reg); MachineInstr *MI = RI.skipInstruction();) { + // Debug values are not allowed to affect codegen. + if (MI->isDebugValue()) { + // Modify DBG_VALUE now that the value is in a spill slot. + uint64_t Offset = MI->getOperand(1).getImm(); + const MDNode *MDPtr = MI->getOperand(2).getMetadata(); + DebugLoc DL = MI->getDebugLoc(); + if (MachineInstr *NewDV = tii_.emitFrameIndexDebugValue(mf_, stackSlot_, + Offset, MDPtr, DL)) { + DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *MI); + MachineBasicBlock *MBB = MI->getParent(); + MBB->insert(MBB->erase(MI), NewDV); + } else { + DEBUG(dbgs() << "Removing debug info due to spill:" << "\t" << *MI); + MI->eraseFromParent(); + } + continue; + } + // Analyze instruction. bool Reads, Writes; SmallVector<unsigned, 8> Ops; |