llvm.org GIT mirror llvm / c6db06a
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. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_30@143438 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
2 changed file(s) with 29 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
20242024 BasicBlock *InstParent = I->getParent();
20252025 BasicBlock::iterator InsertPos = I;
20262026
2027 if (!isa(Result)) // If combining a PHI, don't insert
2028 while (isa(InsertPos)) // middle of a block of PHIs.
2029 ++InsertPos;
2027 // If we replace a PHI with something that isn't a PHI, fix up the
2028 // insertion point.
2029 if (!isa(Result) && isa(InsertPos))
2030 InsertPos = InstParent->getFirstInsertionPt();
20302031
20312032 InstParent->getInstList().insert(InsertPos, Result);
20322033
373373 return: ; No predecessors!
374374 ret void
375375 }
376
377 ; PR11275
378 declare void @test18b() noreturn
379 declare void @test18foo(double**)
380 declare void @test18a() noreturn
381 define fastcc void @test18x(i8* %t0, i1 %b) uwtable align 2 {
382 entry:
383 br i1 %b, label %e1, label %e2
384 e1:
385 %t2 = bitcast i8* %t0 to double**
386 invoke void @test18b() noreturn
387 to label %u unwind label %lpad
388 e2:
389 %t4 = bitcast i8* %t0 to double**
390 invoke void @test18a() noreturn
391 to label %u unwind label %lpad
392 lpad:
393 %t5 = phi double** [ %t2, %e1 ], [ %t4, %e2 ]
394 %lpad.nonloopexit262 = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0
395 cleanup
396 call void @test18foo(double** %t5)
397 unreachable
398 u:
399 unreachable
400 }