[llvm-commits] [llvm] r42131 - /llvm/trunk/lib/VMCore/ConstantFold.cpp
Duncan Sands
baldrick at free.fr
Wed Sep 19 03:16:18 PDT 2007
Author: baldrick
Date: Wed Sep 19 05:16:17 2007
New Revision: 42131
URL: http://llvm.org/viewvc/llvm-project?rev=42131&view=rev
Log:
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.
Modified:
llvm/trunk/lib/VMCore/ConstantFold.cpp
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=42131&r1=42130&r2=42131&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Wed Sep 19 05:16:17 2007
@@ -1124,7 +1124,8 @@
// 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 @@
// 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)
More information about the llvm-commits
mailing list