aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-01 01:23:19 +0000
committerChris Lattner <sabre@nondot.org>2004-02-01 01:23:19 +0000
commitb97e2788ff303e83eab8d24960966bfde05e6a37 (patch)
treea2dfef60229121321ddf21c06219c25137002e9d /lib/VMCore
parent338733fdd2ba0d00ad2ace03836f3e0cbb3f8922 (diff)
downloadexternal_llvm-b97e2788ff303e83eab8d24960966bfde05e6a37.zip
external_llvm-b97e2788ff303e83eab8d24960966bfde05e6a37.tar.gz
external_llvm-b97e2788ff303e83eab8d24960966bfde05e6a37.tar.bz2
Fix a crasher bug in my constant folding rewrite
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11044 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/ConstantFold.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 094ec37..28d671b 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -625,11 +625,18 @@ static Instruction::BinaryOps evaluateRelation(const Constant *V1,
// If the first operand is simple, swap operands.
assert((isa<ConstantPointerRef>(V2) || isa<ConstantExpr>(V2)) &&
"Simple cases should have been handled by caller!");
- return SetCondInst::getSwappedCondition(evaluateRelation(V2, V1));
+ Instruction::BinaryOps SwappedRelation = evaluateRelation(V2, V1);
+ if (SwappedRelation != Instruction::BinaryOpsEnd)
+ return SetCondInst::getSwappedCondition(SwappedRelation);
} else if (const ConstantPointerRef *CPR1 = dyn_cast<ConstantPointerRef>(V1)){
- if (isa<ConstantExpr>(V2)) // Swap as necessary.
- return SetCondInst::getSwappedCondition(evaluateRelation(V2, V1));
+ if (isa<ConstantExpr>(V2)) { // Swap as necessary.
+ Instruction::BinaryOps SwappedRelation = evaluateRelation(V2, V1);
+ if (SwappedRelation != Instruction::BinaryOpsEnd)
+ return SetCondInst::getSwappedCondition(SwappedRelation);
+ else
+ return Instruction::BinaryOpsEnd;
+ }
// Now we know that the RHS is a ConstantPointerRef or simple constant,
// which (since the types must match) means that it's a ConstantPointerNull.