aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/InlineSpiller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/InlineSpiller.cpp')
-rw-r--r--llvm/lib/CodeGen/InlineSpiller.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index 46fcc62..71d58b2 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -753,6 +753,35 @@ void InlineSpiller::reMaterializeAll() {
continue;
LLVM_DEBUG(dbgs() << "All defs dead: " << *MI);
DeadDefs.push_back(MI);
+ // If MI is a bundle header, also try removing copies inside the bundle,
+ // otherwise the verifier would complain "live range continues after dead
+ // def flag".
+ if (MI->isBundledWithSucc() && !MI->isBundledWithPred()) {
+ MachineBasicBlock::instr_iterator BeginIt = MI->getIterator(),
+ EndIt = MI->getParent()->instr_end();
+ ++BeginIt; // Skip MI that was already handled.
+
+ bool OnlyDeadCopies = true;
+ for (MachineBasicBlock::instr_iterator It = BeginIt;
+ It != EndIt && It->isBundledWithPred(); ++It) {
+
+ auto DestSrc = TII.isCopyInstr(*It);
+ bool IsCopyToDeadReg =
+ DestSrc && DestSrc->Destination->getReg() == Reg;
+ if (!IsCopyToDeadReg) {
+ OnlyDeadCopies = false;
+ break;
+ }
+ }
+ if (OnlyDeadCopies) {
+ for (MachineBasicBlock::instr_iterator It = BeginIt;
+ It != EndIt && It->isBundledWithPred(); ++It) {
+ It->addRegisterDead(Reg, &TRI);
+ LLVM_DEBUG(dbgs() << "All defs dead: " << *It);
+ DeadDefs.push_back(&*It);
+ }
+ }
+ }
}
}