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 | 780164433250ebc6f42671f5fdd259db14d71c0e (patch) | |
tree | 1c886802b75381d9099b87346ea69aaed6e9a047 /lib/VMCore/ConstantFold.cpp | |
parent | 892c7e4a2337fc017418b83f2543bddc11359ff2 (diff) | |
download | external_llvm-780164433250ebc6f42671f5fdd259db14d71c0e.zip external_llvm-780164433250ebc6f42671f5fdd259db14d71c0e.tar.gz external_llvm-780164433250ebc6f42671f5fdd259db14d71c0e.tar.bz2 |
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
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 5c80a37..a61dd06 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<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) |