GlobalOpt forgot to handle bitcast when analyzing globals. Found by inspection.
authorDuncan Sands <baldrick@free.fr>
Mon, 2 Jul 2012 18:55:39 +0000 (18:55 +0000)
committerDuncan Sands <baldrick@free.fr>
Mon, 2 Jul 2012 18:55:39 +0000 (18:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159546 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp
test/Transforms/GlobalOpt/unnamed-addr.ll

index 35f98b226536f1886fb8e749c3526627f8ef4948..4e1c23c1980c0f74670709c03576f58884a7eda3 100644 (file)
@@ -254,6 +254,8 @@ static bool AnalyzeGlobal(const Value *V, GlobalStatus &GS,
             GS.StoredType = GlobalStatus::isStored;
           }
         }
+      } else if (isa<BitCastInst>(I)) {
+        if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
       } else if (isa<GetElementPtrInst>(I)) {
         if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
       } else if (isa<SelectInst>(I)) {
index babadc62103507b9ffc8cfbd68803d7dd3aede1d..ee75058731268658a951c228b0e5dde98f48417b 100644 (file)
@@ -26,7 +26,9 @@ define i1 @bah(i64 %i) nounwind readonly optsize ssp {
 entry:
   %arrayidx4 = getelementptr inbounds [4 x i8]* @d, i64 0, i64 %i
   %tmp5 = load i8* %arrayidx4, align 1
-  %cmp = icmp eq i8 %tmp5, 42
+  %array0 = bitcast [4 x i8]* @d to i8*
+  %tmp6 = load i8* %array0, align 1
+  %cmp = icmp eq i8 %tmp5, %tmp6
   ret i1 %cmp
 }