From 1774832b294d96d59d6274200f11b5b5d9f20c67 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 5 Sep 2014 17:10:10 +0000 Subject: [PATCH] Set the parent pointer of cloned DBG_VALUE instructions correctly. Fixes PR20523. When spilling variables onto the stack, spillVirtReg() is setting the parent pointer of the cloned DBG_VALUE intrinsic for the stack location to the parent pointer of the original intrinsic. MachineInstr parent pointers should however always point to the parent basic block. MBB is shadowing the MBB member variable. The instruction still ends up being inserted into the right basic block, because it's inserted after MI which serves as the iterator. I failed at constructing a reliable testcase for this, see http://llvm.org/bugs/show_bug.cgi?id=20523 for a large testcases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217260 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/RegAllocFast.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CodeGen/RegAllocFast.cpp b/lib/CodeGen/RegAllocFast.cpp index 4727f2437f7..6e7e2c7e8ca 100644 --- a/lib/CodeGen/RegAllocFast.cpp +++ b/lib/CodeGen/RegAllocFast.cpp @@ -309,10 +309,10 @@ void RAFast::spillVirtReg(MachineBasicBlock::iterator MI, DL = (--EI)->getDebugLoc(); } else DL = MI->getDebugLoc(); - MachineBasicBlock *MBB = DBG->getParent(); MachineInstr *NewDV = BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::DBG_VALUE)) .addFrameIndex(FI).addImm(Offset).addMetadata(MDPtr); + assert(NewDV->getParent() == MBB && "dangling parent pointer"); (void)NewDV; DEBUG(dbgs() << "Inserting debug info due to spill:" << "\n" << *NewDV); } -- 2.11.0