[llvm-branch-commits] [llvm-branch] r143438 - in /llvm/branches/release_30: ./ lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/crash.ll

Bill Wendling isanbard at gmail.com
Mon Oct 31 21:51:01 PDT 2011


Author: void
Date: Mon Oct 31 23:51:01 2011
New Revision: 143438

URL: http://llvm.org/viewvc/llvm-project?rev=143438&view=rev
Log:
Merging r143437:
------------------------------------------------------------------------
r143437 | efriedma | 2011-10-31 21:49:29 -0700 (Mon, 31 Oct 2011) | 3 lines

Make sure we use the right insertion point when instcombine replaces a PHI with another instruction.  (Specifically, don't insert an arbitrary instruction before a PHI.)  Fixes PR11275.


------------------------------------------------------------------------

Modified:
    llvm/branches/release_30/   (props changed)
    llvm/branches/release_30/lib/Transforms/InstCombine/InstructionCombining.cpp
    llvm/branches/release_30/test/Transforms/InstCombine/crash.ll

Propchange: llvm/branches/release_30/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 31 23:51:01 2011
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:142039,142055,142058,142112,142123,142125,142165,142168,142243,142350,142482,142486,142489,142491-142493,142537,142550,142559,142573-142574,142801,142806,142841,142869,142956,142994,142998,143006,143222,143247,143302
+/llvm/trunk:142039,142055,142058,142112,142123,142125,142165,142168,142243,142350,142482,142486,142489,142491-142493,142537,142550,142559,142573-142574,142801,142806,142841,142869,142956,142994,142998,143006,143222,143247,143302,143437

Modified: llvm/branches/release_30/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_30/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=143438&r1=143437&r2=143438&view=diff
==============================================================================
--- llvm/branches/release_30/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/branches/release_30/lib/Transforms/InstCombine/InstructionCombining.cpp Mon Oct 31 23:51:01 2011
@@ -2025,9 +2025,10 @@
         BasicBlock *InstParent = I->getParent();
         BasicBlock::iterator InsertPos = I;
 
-        if (!isa<PHINode>(Result))        // If combining a PHI, don't insert
-          while (isa<PHINode>(InsertPos)) // middle of a block of PHIs.
-            ++InsertPos;
+        // If we replace a PHI with something that isn't a PHI, fix up the
+        // insertion point.
+        if (!isa<PHINode>(Result) && isa<PHINode>(InsertPos))
+          InsertPos = InstParent->getFirstInsertionPt();
 
         InstParent->getInstList().insert(InsertPos, Result);
 

Modified: llvm/branches/release_30/test/Transforms/InstCombine/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_30/test/Transforms/InstCombine/crash.ll?rev=143438&r1=143437&r2=143438&view=diff
==============================================================================
--- llvm/branches/release_30/test/Transforms/InstCombine/crash.ll (original)
+++ llvm/branches/release_30/test/Transforms/InstCombine/crash.ll Mon Oct 31 23:51:01 2011
@@ -374,3 +374,28 @@
 return:                                           ; No predecessors!
   ret void
 }
+
+; PR11275
+declare void @test18b() noreturn
+declare void @test18foo(double**)
+declare void @test18a() noreturn
+define fastcc void @test18x(i8* %t0, i1 %b) uwtable align 2 {
+entry:
+  br i1 %b, label %e1, label %e2
+e1:
+  %t2 = bitcast i8* %t0 to double**
+  invoke void @test18b() noreturn
+          to label %u unwind label %lpad
+e2:
+  %t4 = bitcast i8* %t0 to double**
+  invoke void @test18a() noreturn
+          to label %u unwind label %lpad
+lpad:
+  %t5 = phi double** [ %t2, %e1 ], [ %t4, %e2 ]
+  %lpad.nonloopexit262 = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
+          cleanup
+  call void @test18foo(double** %t5)
+  unreachable
+u:
+  unreachable
+}





More information about the llvm-branch-commits mailing list