Added code that checks to see if a global variable is external before replacing
authorJohn Criswell <criswell@uiuc.edu>
Mon, 21 Jul 2003 19:42:57 +0000 (19:42 +0000)
committerJohn Criswell <criswell@uiuc.edu>
Mon, 21 Jul 2003 19:42:57 +0000 (19:42 +0000)
a load of the global variable with the variable's constant value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7216 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index bb8f97be3b92f4b810fcb854ca3f6d27b9999d0f..b066decee0b2f80166ece5d281a54ec01cdb6543 100644 (file)
@@ -1294,7 +1294,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
 
   // Instcombine load (constant global) into the value loaded...
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
-    if (GV->isConstant())
+    if ((GV->isConstant()) && (!(GV->isExternal())))
       return ReplaceInstUsesWith(LI, GV->getInitializer());
 
   // Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded...