[llvm-branch-commits] [llvm-branch] r101137 - in /llvm/branches/release_27: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/crash.ll

Tanya Lattner tonic at nondot.org
Tue Apr 13 09:34:45 PDT 2010


Author: tbrethou
Date: Tue Apr 13 11:34:45 2010
New Revision: 101137

URL: http://llvm.org/viewvc/llvm-project?rev=101137&view=rev
Log:
Merge r100936 from mainline to fix PR6760.

Modified:
    llvm/branches/release_27/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/branches/release_27/test/Transforms/GlobalOpt/crash.ll

Modified: llvm/branches/release_27/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_27/lib/Transforms/IPO/GlobalOpt.cpp?rev=101137&r1=101136&r2=101137&view=diff
==============================================================================
--- llvm/branches/release_27/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/branches/release_27/lib/Transforms/IPO/GlobalOpt.cpp Tue Apr 13 11:34:45 2010
@@ -955,7 +955,8 @@
       continue; // Otherwise, storing through it, or storing into GV... fine.
     }
     
-    if (isa<GetElementPtrInst>(Inst)) {
+    // Must index into the array and into the struct.
+    if (isa<GetElementPtrInst>(Inst) && Inst->getNumOperands() >= 3) {
       if (!ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Inst, GV, PHIs))
         return false;
       continue;

Modified: llvm/branches/release_27/test/Transforms/GlobalOpt/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_27/test/Transforms/GlobalOpt/crash.ll?rev=101137&r1=101136&r2=101137&view=diff
==============================================================================
--- llvm/branches/release_27/test/Transforms/GlobalOpt/crash.ll (original)
+++ llvm/branches/release_27/test/Transforms/GlobalOpt/crash.ll Tue Apr 13 11:34:45 2010
@@ -9,8 +9,34 @@
 @_ZL6vTwist =  global %struct.btSimdScalar zeroinitializer ; <%struct.btSimdScalar*> [#uses=1]
 @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I__ZN21btConeTwistConstraintC2Ev }] ; <[12 x %0]*> [#uses=0]
 
-define internal  void @_GLOBAL__I__ZN21btConeTwistConstraintC2Ev() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" {
+define internal void @_GLOBAL__I__ZN21btConeTwistConstraintC2Ev() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" {
 entry:
   store float 1.0, float* getelementptr inbounds (%struct.btSimdScalar* @_ZL6vTwist, i32 0, i32 0, i32 0, i32 3), align 4
   ret void
 }
+
+
+; PR6760
+%T = type { [5 x i32] }
+
+ at switch_inf = internal global %T* null
+
+define void @test(i8* %arch_file, i32 %route_type) {
+entry:
+  %A = sext i32 1 to i64
+  %B = mul i64 %A, 20
+  %C = call noalias i8* @malloc(i64 %B) nounwind
+  %D = bitcast i8* %C to %T*
+  store %T* %D, %T** @switch_inf, align 8
+  unreachable
+
+bb.nph.i: 
+  %scevgep.i539 = getelementptr i8* %C, i64 4
+  unreachable
+
+xx:
+  %E = load %T** @switch_inf, align 8 
+  unreachable
+}
+
+declare noalias i8* @malloc(i64) nounwind





More information about the llvm-branch-commits mailing list