aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-11-08 22:06:31 +0000
committerChris Lattner <sabre@nondot.org>2001-11-08 22:06:31 +0000
commit0bf7bad0c31194beaf743007b6f5dabb1ddca0c7 (patch)
treeeb733ab65b88ba86322ce994a7b455e7e32b5861 /lib/Transforms
parent00d91c6cd8ecf8ec4c112bda8df3e57a45f59c33 (diff)
downloadexternal_llvm-0bf7bad0c31194beaf743007b6f5dabb1ddca0c7.zip
external_llvm-0bf7bad0c31194beaf743007b6f5dabb1ddca0c7.tar.gz
external_llvm-0bf7bad0c31194beaf743007b6f5dabb1ddca0c7.tar.bz2
* Add better caching of data to avoid silly recusions
* Only check to see if uses of instructions can be converted for expressions... so we don't look at all of the uses of a constant. This was making the code unnecessarily conservative git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 3b0f3d2..f6fdb7e 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -77,9 +77,11 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
// have this value converted. This makes use of the map to avoid infinite
// recursion.
//
- for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I)
- if (!OperandConvertableToType(*I, V, Ty, CTMap))
- return false;
+ if (isa<Instruction>(V)) {
+ for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I)
+ if (!OperandConvertableToType(*I, V, Ty, CTMap))
+ return false;
+ }
Instruction *I = dyn_cast<Instruction>(V);
if (I == 0) {
@@ -336,6 +338,8 @@ bool RetValConvertableToType(Value *V, const Type *Ty,
if (I != ConvertedTypes.end()) return I->second == Ty;
ConvertedTypes[V] = Ty;
+ assert(isa<Instruction>(V) && "Can't convert ret val of non instruction");
+
// It is safe to convert the specified value to the specified type IFF all of
// the uses of the value can be converted to accept the new typed value.
//
@@ -389,6 +393,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
}
// FALLTHROUGH
case Instruction::Sub: {
+ CTMap[I] = Ty;
Value *OtherOp = I->getOperand((V == I->getOperand(0)) ? 1 : 0);
return RetValConvertableToType(I, Ty, CTMap) &&
ExpressionConvertableToType(OtherOp, Ty, CTMap);
@@ -403,6 +408,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// FALL THROUGH
case Instruction::Shl:
assert(I->getOperand(0) == V);
+ CTMap[I] = Ty;
return RetValConvertableToType(I, Ty, CTMap);
case Instruction::Load:
@@ -427,6 +433,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
if (TD.getTypeSize(Ty) != TD.getTypeSize(LI->getType()))
return false;
+ CTMap[LI] = Ty;
return RetValConvertableToType(LI, Ty, CTMap);
}
return false;
@@ -435,6 +442,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
if (TD.getTypeSize(PVTy) != TD.getTypeSize(LI->getType()))
return false;
+ CTMap[LI] = PVTy;
return RetValConvertableToType(LI, PVTy, CTMap);
}
return false;
@@ -465,6 +473,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
}
case Instruction::PHINode: {
+ CTMap[I] = Ty;
PHINode *PN = cast<PHINode>(I);
for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i)
if (!ExpressionConvertableToType(PN->getIncomingValue(i), Ty, CTMap))