diff options
| author | Duncan Sands <baldrick@free.fr> | 2007-09-19 10:10:31 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2007-09-19 10:10:31 +0000 |
| commit | 56df7dec2b60b10c27b0bfb666a604ea21dff77f (patch) | |
| tree | 79ec97b4c2a556eec0c60731aa35664f81b1256a /llvm/lib/Transforms | |
| parent | ef858c9ff679a58e9b1373e681519b8535f5e81b (diff) | |
| download | bcm5719-llvm-56df7dec2b60b10c27b0bfb666a604ea21dff77f.tar.gz bcm5719-llvm-56df7dec2b60b10c27b0bfb666a604ea21dff77f.zip | |
A global variable with external weak linkage can be null, while
an alias could alias such a global variable.
llvm-svn: 42130
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 55ef0a80985..07eb2528c45 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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 |

