Delete stoppoints that occur for the same source line.
authorChris Lattner <sabre@nondot.org>
Thu, 18 Nov 2004 21:41:39 +0000 (21:41 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Nov 2004 21:41:39 +0000 (21:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17970 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index f336722dd739ba89035920a4aa79958dc505b780..b279d9201ae8892c4e88633bdf5d59263b2c28ee 100644 (file)
@@ -182,7 +182,7 @@ namespace {
       assert(I.use_empty() && "Cannot erase instruction that is used!");
       AddUsesToWorkList(I);
       removeFromWorkList(&I);
-      I.getParent()->getInstList().erase(&I);
+      I.eraseFromParent();
       return 0;  // Don't do anything with FI
     }
 
@@ -3217,6 +3217,16 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
         }
 
     if (Changed) return &CI;
+  } else if (DbgStopPointInst *SPI = dyn_cast<DbgStopPointInst>(&CI)) {
+    // If this stoppoint is at the same source location as the previous
+    // stoppoint in the chain, it is not needed.
+    if (DbgStopPointInst *PrevSPI =
+        dyn_cast<DbgStopPointInst>(SPI->getChain()))
+      if (SPI->getLineNo() == PrevSPI->getLineNo() &&
+          SPI->getColNo() == PrevSPI->getColNo()) {
+        SPI->replaceAllUsesWith(PrevSPI);
+        return EraseInstFromFunction(CI);
+      }
   }
 
   return visitCallSite(&CI);