summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantHandling.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-04-25 02:52:06 +0000
committerChris Lattner <sabre@nondot.org>2003-04-25 02:52:06 +0000
commite17c1c5ad84036ec62a793949ba59a265bdb2023 (patch)
tree52a8c0c9087ec54de08514715870acc8bb6e231b /llvm/lib/VMCore/ConstantHandling.cpp
parenta2f7d23e9a0fb4f2766484d896739722cdf0ab97 (diff)
downloadbcm5719-llvm-e17c1c5ad84036ec62a793949ba59a265bdb2023.tar.gz
bcm5719-llvm-e17c1c5ad84036ec62a793949ba59a265bdb2023.zip
** CORRECTLY, conservatively handle constant expressions
llvm-svn: 5924
Diffstat (limited to 'llvm/lib/VMCore/ConstantHandling.cpp')
-rw-r--r--llvm/lib/VMCore/ConstantHandling.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstantHandling.cpp b/llvm/lib/VMCore/ConstantHandling.cpp
index 057d2c90c31..36cc13cf550 100644
--- a/llvm/lib/VMCore/ConstantHandling.cpp
+++ b/llvm/lib/VMCore/ConstantHandling.cpp
@@ -47,7 +47,7 @@ Constant *ConstantFoldInstruction(Instruction *I) {
switch (I->getOpcode()) {
case Instruction::Cast:
- return ConstRules::get(*Op0)->castTo(Op0, I->getType());
+ return ConstRules::get(*Op0, *Op0)->castTo(Op0, I->getType());
case Instruction::Add: return *Op0 + *Op1;
case Instruction::Sub: return *Op0 - *Op1;
case Instruction::Mul: return *Op0 * *Op1;
@@ -107,7 +107,7 @@ Constant *ConstantFoldCastInstruction(const Constant *V, const Type *DestTy) {
}
}
- return ConstRules::get(*V)->castTo(V, DestTy);
+ return ConstRules::get(*V, *V)->castTo(V, DestTy);
}
Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1,
@@ -555,3 +555,8 @@ Annotation *ConstRules::find(AnnotationID AID, const Annotable *TyA, void *) {
return new EmptyRules();
}
}
+
+ConstRules *ConstRules::getConstantExprRules() {
+ static EmptyRules CERules;
+ return &CERules;
+}
OpenPOWER on IntegriCloud