diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 9 |
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) |