]> granicus.if.org Git - llvm/commitdiff
** CORRECTLY, conservatively handle constant expressions
authorChris Lattner <sabre@nondot.org>
Fri, 25 Apr 2003 02:52:06 +0000 (02:52 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 25 Apr 2003 02:52:06 +0000 (02:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5924 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstantFold.cpp

index 057d2c90c318412536767be0e7cc7bb4e4bcd257..36cc13cf55024ff3f0247f03befc99723509782b 100644 (file)
@@ -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;
+}