code restructuring, not functionality change.
authorChris Lattner <sabre@nondot.org>
Thu, 24 Apr 2008 00:21:50 +0000 (00:21 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 24 Apr 2008 00:21:50 +0000 (00:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50203 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SCCP.cpp

index e849b2d876588893b87698b207a71a1be3240732..1ca29a8c032ee15c57f1d8628ca970406d031478 100644 (file)
@@ -1693,28 +1693,30 @@ bool IPSCCP::runOnModule(Module &M) {
       } else {
         for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) {
           Instruction *Inst = BI++;
-          if (Inst->getType() != Type::VoidTy &&
-              !isa<StructType>(Inst->getType())) {
-            LatticeVal &IV = Values[Inst];
-            if (IV.isConstant() ||
-                (IV.isUndefined() && !isa<TerminatorInst>(Inst))) {
-              Constant *Const = IV.isConstant()
-                ? IV.getConstant() : UndefValue::get(Inst->getType());
-              DOUT << "  Constant: " << *Const << " = " << *Inst;
-
-              // Replaces all of the uses of a variable with uses of the
-              // constant.
-              Inst->replaceAllUsesWith(Const);
-
-              // Delete the instruction.
-              if (!isa<TerminatorInst>(Inst) && !isa<CallInst>(Inst))
-                BB->getInstList().erase(Inst);
-
-              // Hey, we just changed something!
-              MadeChanges = true;
-              ++IPNumInstRemoved;
-            }
-          }
+          if (Inst->getType() == Type::VoidTy ||
+              isa<StructType>(Inst->getType()) ||
+              isa<TerminatorInst>(Inst))
+            continue;
+          
+          LatticeVal &IV = Values[Inst];
+          if (!IV.isConstant() && !IV.isUndefined())
+            continue;
+          
+          Constant *Const = IV.isConstant()
+            ? IV.getConstant() : UndefValue::get(Inst->getType());
+          DOUT << "  Constant: " << *Const << " = " << *Inst;
+
+          // Replaces all of the uses of a variable with uses of the
+          // constant.
+          Inst->replaceAllUsesWith(Const);
+          
+          // Delete the instruction.
+          if (!isa<CallInst>(Inst))
+            Inst->eraseFromParent();
+
+          // Hey, we just changed something!
+          MadeChanges = true;
+          ++IPNumInstRemoved;
         }
       }