1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

A global variable with external weak linkage can be null, while

an alias could alias such a global variable.

llvm-svn: 42130
This commit is contained in:
Duncan Sands 2007-09-19 10:10:31 +00:00
parent b366bd7fb6
commit d88f60ed32

View File

@ -8936,8 +8936,12 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) {
/// specified pointer, we do a quick local scan of the basic block containing /// specified pointer, we do a quick local scan of the basic block containing
/// ScanFrom, to determine if the address is already accessed. /// ScanFrom, to determine if the address is already accessed.
static bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) { static bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) {
// If it is an alloca or global variable, it is always safe to load from. // If it is an alloca it is always safe to load from.
if (isa<AllocaInst>(V) || isa<GlobalVariable>(V)) return true; 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 // 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 // want to check to see if the pointer is already being loaded or stored