summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-09-19 10:10:31 +0000
committerDuncan Sands <baldrick@free.fr>2007-09-19 10:10:31 +0000
commit892c7e4a2337fc017418b83f2543bddc11359ff2 (patch)
treea7b7581e1944f6abb867fa45bb5114d96c72d4bc
parent9dbf8ed140666d7e26a586a91f3c5c16339151aa (diff)
downloadexternal_llvm-892c7e4a2337fc017418b83f2543bddc11359ff2.zip
external_llvm-892c7e4a2337fc017418b83f2543bddc11359ff2.tar.gz
external_llvm-892c7e4a2337fc017418b83f2543bddc11359ff2.tar.bz2
A global variable with external weak linkage can be null, while
an alias could alias such a global variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42130 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 55ef0a8..07eb252 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -8936,8 +8936,12 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) {
/// specified pointer, we do a quick local scan of the basic block containing
/// ScanFrom, to determine if the address is already accessed.
static bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) {
- // If it is an alloca or global variable, it is always safe to load from.
- if (isa<AllocaInst>(V) || isa<GlobalVariable>(V)) return true;
+ // If it is an alloca it is always safe to load from.
+ if (isa<AllocaInst>(V)) return true;
+
+ // Don't try to evaluate aliases. External weak GV can be null.
+ if (const GlobalValue *GV = dyn_cast<GlobalVariable>(V))
+ return !isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage();
// Otherwise, be a little bit agressive by scanning the local block where we
// want to check to see if the pointer is already being loaded or stored