aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-01-11 12:24:14 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-01-11 12:24:14 +0000
commit6b6b6ef1677fa71b1072c2911b4c1f9524a558c9 (patch)
tree480ecf010ac5facd1bc29ab57441253691bb42d6 /lib/Transforms/IPO/GlobalOpt.cpp
parent057809ac1c78c3456e8f1481330fa2bcd2b85029 (diff)
For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt. Remove ConstantIntegral and ConstantBool from LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index f25621eb78..c1944dbe95 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -711,7 +711,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
// keep track of whether the global was initialized yet or not.
GlobalVariable *InitBool =
new GlobalVariable(Type::BoolTy, false, GlobalValue::InternalLinkage,
- ConstantBool::getFalse(), GV->getName()+".init");
+ ConstantInt::getFalse(), GV->getName()+".init");
bool InitBoolUsed = false;
// Loop over all uses of GV, processing them in turn.
@@ -731,7 +731,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
default: assert(0 && "Unknown ICmp Predicate!");
case ICmpInst::ICMP_ULT:
case ICmpInst::ICMP_SLT:
- LV = ConstantBool::getFalse(); // X < null -> always false
+ LV = ConstantInt::getFalse(); // X < null -> always false
break;
case ICmpInst::ICMP_ULE:
case ICmpInst::ICMP_SLE:
@@ -753,7 +753,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
} else {
StoreInst *SI = cast<StoreInst>(GV->use_back());
// The global is initialized when the store to it occurs.
- new StoreInst(ConstantBool::getTrue(), InitBool, SI);
+ new StoreInst(ConstantInt::getTrue(), InitBool, SI);
SI->eraseFromParent();
}
@@ -1140,7 +1140,7 @@ static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
// Create the new global, initializing it to false.
GlobalVariable *NewGV = new GlobalVariable(Type::BoolTy, false,
- GlobalValue::InternalLinkage, ConstantBool::getFalse(),
+ GlobalValue::InternalLinkage, ConstantInt::getFalse(),
GV->getName()+".b");
GV->getParent()->getGlobalList().insert(GV, NewGV);
@@ -1161,7 +1161,7 @@ static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
// Only do this if we weren't storing a loaded value.
Value *StoreVal;
if (StoringOther || SI->getOperand(0) == InitVal)
- StoreVal = ConstantBool::get(StoringOther);
+ StoreVal = ConstantInt::get(StoringOther);
else {
// Otherwise, we are storing a previously loaded copy. To do this,
// change the copy from copying the original value to just copying the
@@ -1797,10 +1797,13 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
if (BI->isUnconditional()) {
NewBB = BI->getSuccessor(0);
} else {
- ConstantBool *Cond =
- dyn_cast<ConstantBool>(getVal(Values, BI->getCondition()));
- if (!Cond) return false; // Cannot determine.
- NewBB = BI->getSuccessor(!Cond->getValue());
+ ConstantInt *Cond =
+ dyn_cast<ConstantInt>(getVal(Values, BI->getCondition()));
+
+ // Cannot determine.
+ if (!Cond || Cond->getType() != Type::BoolTy)
+ return false;
+ NewBB = BI->getSuccessor(!Cond->getBoolValue());
}
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(CurInst)) {
ConstantInt *Val =