Fix a bug in the code which re-inserts DBG_VALUE nodes after scheduling;
authorDan Gohman <gohman@apple.com>
Sat, 10 Jul 2010 22:42:31 +0000 (22:42 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 10 Jul 2010 22:42:31 +0000 (22:42 +0000)
if a block is split (by a custom inserter), the insert point may be in a
different block than it was originally. This fixes 32-bit llvm-gcc
bootstrap builds, and I haven't been able to reproduce it otherwise.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108060 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp

index 2673eba3f3eaa6b8a7865825d8745f4bb944a972..06cf0530875504f54c8597a4b95a15e20629ab11 100644 (file)
@@ -642,8 +642,10 @@ MachineBasicBlock *ScheduleDAGSDNodes::EmitSchedule() {
             // Insert to start of the BB (after PHIs).
             BB->insert(BBBegin, DbgMI);
           else {
+            // Insert at the instruction, which may be in a different
+            // block, if the block was split by a custom inserter.
             MachineBasicBlock::iterator Pos = MI;
-            BB->insert(llvm::next(Pos), DbgMI);
+            MI->getParent()->insert(llvm::next(Pos), DbgMI);
           }
         }
       }