summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2018-06-26 18:55:43 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2018-06-26 18:55:43 +0000
commit7e991d30c0fc2f2fb0510dfdd0a1e7053e64170e (patch)
tree280b16d28a6ab71f2fac6724e3534687d67b8135 /llvm/lib
parent78ff0f1b83d3ec6c8a446417570490207f4d7bc3 (diff)
downloadbcm5719-llvm-7e991d30c0fc2f2fb0510dfdd0a1e7053e64170e.tar.gz
bcm5719-llvm-7e991d30c0fc2f2fb0510dfdd0a1e7053e64170e.zip
ConstantFold: Don't fold global address vs. null for addrspace != 0
Not sure why this logic seems to be repeated in 2 different places, one called by the other. On AMDGPU addrspace(3) globals start allocating at 0, so these checks will be incorrect (not that real code actually tries to compare these addresses) llvm-svn: 335649
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index f36667ef24d..9da6075d677 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1500,7 +1500,8 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2,
assert(isa<ConstantPointerNull>(V2) && "Canonicalization guarantee!");
// GlobalVals can never be null unless they have external weak linkage.
// We don't try to evaluate aliases here.
- if (!GV->hasExternalWeakLinkage() && !isa<GlobalAlias>(GV))
+ if (!GV->hasExternalWeakLinkage() && !isa<GlobalAlias>(GV) &&
+ GV->getType()->getAddressSpace() == 0)
return ICmpInst::ICMP_NE;
}
} else if (const BlockAddress *BA = dyn_cast<BlockAddress>(V1)) {
@@ -1730,7 +1731,8 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
if (C1->isNullValue()) {
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C2))
// Don't try to evaluate aliases. External weak GV can be null.
- if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage()) {
+ if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage() &&
+ GV->getType()->getAddressSpace() == 0) {
if (pred == ICmpInst::ICMP_EQ)
return ConstantInt::getFalse(C1->getContext());
else if (pred == ICmpInst::ICMP_NE)
@@ -1740,7 +1742,8 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
} else if (C2->isNullValue()) {
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C1))
// Don't try to evaluate aliases. External weak GV can be null.
- if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage()) {
+ if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage() &&
+ GV->getType()->getAddressSpace() == 0) {
if (pred == ICmpInst::ICMP_EQ)
return ConstantInt::getFalse(C1->getContext());
else if (pred == ICmpInst::ICMP_NE)
OpenPOWER on IntegriCloud