aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/SCCP.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-24 00:21:50 +0000
committerChris Lattner <sabre@nondot.org>2008-04-24 00:21:50 +0000
commiteb5f4092d9fab33c10a27549a80edd3ac25de68f (patch)
treee7429e7f2cea44663b2fb50e92304a49e50e6702 /lib/Transforms/Scalar/SCCP.cpp
parent7cb22ecf226842f04f2ee4b8ed040ea503332499 (diff)
downloadexternal_llvm-eb5f4092d9fab33c10a27549a80edd3ac25de68f.zip
external_llvm-eb5f4092d9fab33c10a27549a80edd3ac25de68f.tar.gz
external_llvm-eb5f4092d9fab33c10a27549a80edd3ac25de68f.tar.bz2
code restructuring, not functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp46
1 files changed, 24 insertions, 22 deletions
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index e849b2d..1ca29a8 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -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;
}
}