From: Duncan Sands Date: Wed, 19 Sep 2007 10:16:17 +0000 (+0000) Subject: Partial fix for PR1678: correct some parts of constant X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=780164433250ebc6f42671f5fdd259db14d71c0e;p=oota-llvm.git Partial fix for PR1678: correct some parts of constant fold that were missed in the fix for PR1646. Probably this null/not-null logic should be factorized somewhere. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42131 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 5c80a377ba7..a61dd06ff1f 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1124,7 +1124,8 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, // icmp eq/ne(null,GV) -> false/true if (C1->isNullValue()) { if (const GlobalValue *GV = dyn_cast(C2)) - if (!GV->hasExternalWeakLinkage()) // External weak GV can be null + // Don't try to evaluate aliases. External weak GV can be null. + if (!isa(GV) && !GV->hasExternalWeakLinkage()) if (pred == ICmpInst::ICMP_EQ) return ConstantInt::getFalse(); else if (pred == ICmpInst::ICMP_NE) @@ -1132,7 +1133,8 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, // icmp eq/ne(GV,null) -> false/true } else if (C2->isNullValue()) { if (const GlobalValue *GV = dyn_cast(C1)) - if (!GV->hasExternalWeakLinkage()) // External weak GV can be null + // Don't try to evaluate aliases. External weak GV can be null. + if (!isa(GV) && !GV->hasExternalWeakLinkage()) if (pred == ICmpInst::ICMP_EQ) return ConstantInt::getFalse(); else if (pred == ICmpInst::ICMP_NE)