Fix a debug location handling bug in GVN.
[oota-llvm.git] / lib / Transforms / Scalar / GVN.cpp
index f256af81fc86e2647338702948f022df6c8e0830..d898b1796b6942ff6c9d0ac4b961c5942c244ef9 100644 (file)
@@ -1744,7 +1744,8 @@ bool GVN::processNonLocalLoad(LoadInst *LI) {
     if (isa<PHINode>(V))
       V->takeName(LI);
     if (Instruction *I = dyn_cast<Instruction>(V))
-      I->setDebugLoc(LI->getDebugLoc());
+      if (LI->getDebugLoc())
+        I->setDebugLoc(LI->getDebugLoc());
     if (V->getType()->getScalarType()->isPointerTy())
       MD->invalidateCachedPointerInfo(V);
     markInstructionForDeletion(LI);