[llvm-commits] [llvm] r173279 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/getelementptr.ll

Benjamin Kramer benny.kra at googlemail.com
Wed Jan 23 09:52:29 PST 2013


Author: d0k
Date: Wed Jan 23 11:52:29 2013
New Revision: 173279

URL: http://llvm.org/viewvc/llvm-project?rev=173279&view=rev
Log:
Revert "InstCombine: Clean up weird code that talks about a modulus that's long gone."

This causes crashes during the build of compiler-rt during selfhost. Add a
testcase for coverage.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
    llvm/trunk/test/Transforms/InstCombine/getelementptr.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=173279&r1=173278&r2=173279&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Wed Jan 23 11:52:29 2013
@@ -758,7 +758,12 @@
     FirstIdx = Offset/TySize;
     Offset -= FirstIdx*TySize;
 
-    assert(Offset >= 0 && "Offset should never be negative!");
+    // Handle hosts where % returns negative instead of values [0..TySize).
+    if (Offset < 0) {
+      --FirstIdx;
+      Offset += TySize;
+      assert(Offset >= 0);
+    }
     assert((uint64_t)Offset < (uint64_t)TySize && "Out of range offset");
   }
 

Modified: llvm/trunk/test/Transforms/InstCombine/getelementptr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/getelementptr.ll?rev=173279&r1=173278&r2=173279&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/getelementptr.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/getelementptr.ll Wed Jan 23 11:52:29 2013
@@ -492,3 +492,19 @@
 
 declare void @three_gep_g(i32*)
 declare void @three_gep_h(%three_gep_t2*)
+
+%struct.ham = type { i32, %struct.zot*, %struct.zot*, %struct.zot* }
+%struct.zot = type { i64, i8 }
+
+define void @test39(%struct.ham* %arg, i8 %arg1) nounwind {
+  %tmp = getelementptr inbounds %struct.ham* %arg, i64 0, i32 2
+  %tmp2 = load %struct.zot** %tmp, align 8
+  %tmp3 = bitcast %struct.zot* %tmp2 to i8*
+  %tmp4 = getelementptr inbounds i8* %tmp3, i64 -8
+  store i8 %arg1, i8* %tmp4, align 8
+  ret void
+
+; CHECK: @test39
+; CHECK: getelementptr inbounds %struct.ham* %arg, i64 0, i32 2
+; CHECK: getelementptr inbounds i8* %tmp3, i64 -8
+}





More information about the llvm-commits mailing list