<p dir="ltr"><br>
On Sep 5, 2014 10:22 AM, "Adrian Prantl" <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>> wrote:<br>
><br>
> Author: adrian<br>
> Date: Fri Sep 5 12:10:10 2014<br>
> New Revision: 217260<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217260&view=rev">http://llvm.org/viewvc/llvm-project?rev=217260&view=rev</a><br>
> Log:<br>
> Set the parent pointer of cloned DBG_VALUE instructions correctly.<br>
> Fixes PR20523.<br>
><br>
> When spilling variables onto the stack, spillVirtReg() is setting the<br>
> parent pointer of the cloned DBG_VALUE intrinsic for the stack location<br>
> to the parent pointer of the original intrinsic. MachineInstr parent<br>
> pointers should however always point to the parent basic block.<br>
><br>
> MBB is shadowing the MBB member variable. The instruction still ends up<br>
> being inserted into the right basic block, because it's inserted after MI<br>
> which serves as the iterator.</p>
<p dir="ltr">Perhaps we should assert that the iterator within the basic block?</p>
<p dir="ltr">> I failed at constructing a reliable testcase for this, see<br>
> <a href="http://llvm.org/bugs/show_bug.cgi?id=20523">http://llvm.org/bugs/show_bug.cgi?id=20523</a> for a large testcases.<br>
><br>
> Modified:<br>
> llvm/trunk/lib/CodeGen/RegAllocFast.cpp<br>
><br>
> Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=217260&r1=217259&r2=217260&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=217260&r1=217259&r2=217260&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Fri Sep 5 12:10:10 2014<br>
> @@ -309,10 +309,10 @@ void RAFast::spillVirtReg(MachineBasicBl<br>
> DL = (--EI)->getDebugLoc();<br>
> } else<br>
> DL = MI->getDebugLoc();<br>
> - MachineBasicBlock *MBB = DBG->getParent();<br>
> MachineInstr *NewDV =<br>
> BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::DBG_VALUE))<br>
> .addFrameIndex(FI).addImm(Offset).addMetadata(MDPtr);<br>
> + assert(NewDV->getParent() == MBB && "dangling parent pointer");</p>
<p dir="ltr">Maybe this assertion (in some form) could be moved into a more central location so this invariant (that BuildMI functions are passed an iterator into the same MBB - but maybe even below the build function, in the insertion itself)</p>
<p dir="ltr">> (void)NewDV;<br>
> DEBUG(dbgs() << "Inserting debug info due to spill:" << "\n" << *NewDV);<br>
> }<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</p>