diff options
| author | Duncan Sands <baldrick@free.fr> | 2007-09-19 10:16:17 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2007-09-19 10:16:17 +0000 |
| commit | a38e527523f1981f644cb53ba72fe38186401b9c (patch) | |
| tree | 0370e0ae690c6c40469411d74986ec7b6df5d1c6 /llvm | |
| parent | 56df7dec2b60b10c27b0bfb666a604ea21dff77f (diff) | |
| download | bcm5719-llvm-a38e527523f1981f644cb53ba72fe38186401b9c.tar.gz bcm5719-llvm-a38e527523f1981f644cb53ba72fe38186401b9c.zip | |
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.
llvm-svn: 42131
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 5c80a377ba7..a61dd06ff1f 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/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<GlobalValue>(C2)) - if (!GV->hasExternalWeakLinkage()) // External weak GV can be null + // Don't try to evaluate aliases. External weak GV can be null. + if (!isa<GlobalAlias>(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<GlobalValue>(C1)) - if (!GV->hasExternalWeakLinkage()) // External weak GV can be null + // Don't try to evaluate aliases. External weak GV can be null. + if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage()) if (pred == ICmpInst::ICMP_EQ) return ConstantInt::getFalse(); else if (pred == ICmpInst::ICMP_NE) |

