[llvm-commits] [llvm] r42130 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Duncan Sands baldrick at free.fr
Wed Sep 19 03:10:33 PDT 2007


Author: baldrick
Date: Wed Sep 19 05:10:31 2007
New Revision: 42130

URL: http://llvm.org/viewvc/llvm-project?rev=42130&view=rev
Log:
A global variable with external weak linkage can be null, while
an alias could alias such a global variable.

Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=42130&r1=42129&r2=42130&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Sep 19 05:10:31 2007
@@ -8936,8 +8936,12 @@
 /// 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





More information about the llvm-commits mailing list