Transfer debug location information from PHI nodes to resulting
authorDan Gohman <gohman@apple.com>
Fri, 7 May 2010 01:10:20 +0000 (01:10 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 7 May 2010 01:10:20 +0000 (01:10 +0000)
lowered copies.

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

lib/CodeGen/SelectionDAG/FastISel.cpp

index 2328ed034dd836b51394d633e3bb813cce621578..6107c8cb7a689576c90f9524f8be30af0fd5161e 100644 (file)
@@ -1082,6 +1082,7 @@ bool FastISel::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
     // emitted yet.
     for (BasicBlock::const_iterator I = SuccBB->begin();
          const PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+
       // Ignore dead phi's.
       if (PN->use_empty()) continue;
 
@@ -1104,12 +1105,19 @@ bool FastISel::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
 
       const Value *PHIOp = PN->getIncomingValueForBlock(LLVMBB);
 
+      // Set the DebugLoc for the copy. Prefer the location of the operand
+      // if there is one; use the location of the PHI otherwise.
+      DL = PN->getDebugLoc();
+      if (const Instruction *Inst = dyn_cast<Instruction>(PHIOp))
+        DL = Inst->getDebugLoc();
+
       unsigned Reg = getRegForValue(PHIOp);
       if (Reg == 0) {
         PHINodesToUpdate.resize(OrigNumPHINodesToUpdate);
         return false;
       }
       PHINodesToUpdate.push_back(std::make_pair(MBBI++, Reg));
+      DL = DebugLoc();
     }
   }