summaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-09-10 23:42:42 +0000
committerChris Lattner <sabre@nondot.org>2007-09-10 23:42:42 +0000
commita0ef5ed742a81b134ac4438c3a4adc0c9a151b64 (patch)
treefeb83388f4e2240bccbcc78f4f71aef5b0972655 /lib/VMCore/ConstantFold.cpp
parent0c0f7c935bc4c6de74bd4025ceca7278e128f48d (diff)
downloadllvm-a0ef5ed742a81b134ac4438c3a4adc0c9a151b64.tar.gz
llvm-a0ef5ed742a81b134ac4438c3a4adc0c9a151b64.tar.bz2
llvm-a0ef5ed742a81b134ac4438c3a4adc0c9a151b64.tar.xz
Fix a buggy constant folding transformation when handling aliases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 5686a0e35f..4dc1340f90 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -23,6 +23,7 @@
#include "llvm/Instructions.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
+#include "llvm/GlobalAlias.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
@@ -951,12 +952,14 @@ static ICmpInst::Predicate evaluateICmpRelation(const Constant *V1,
// Now we know that the RHS is a GlobalValue or simple constant,
// which (since the types must match) means that it's a ConstantPointerNull.
if (const GlobalValue *CPR2 = dyn_cast<GlobalValue>(V2)) {
- if (!CPR1->hasExternalWeakLinkage() || !CPR2->hasExternalWeakLinkage())
- return ICmpInst::ICMP_NE;
+ // Don't try to decide equality of aliases.
+ if (!isa<GlobalAlias>(CPR1) && !isa<GlobalAlias>(CPR2))
+ if (!CPR1->hasExternalWeakLinkage() || !CPR2->hasExternalWeakLinkage())
+ return ICmpInst::ICMP_NE;
} else {
- // GlobalVals can never be null.
assert(isa<ConstantPointerNull>(V2) && "Canonicalization guarantee!");
- if (!CPR1->hasExternalWeakLinkage())
+ // GlobalVals can never be null. Don't try to evaluate aliases.
+ if (!CPR1->hasExternalWeakLinkage() && !isa<GlobalAlias>(CPR1))
return ICmpInst::ICMP_NE;
}
} else {