1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[CallSiteSplitting] Report edge deletion to DomTreeUpdater

Summary:
When splitting musttail calls, the split blocks' original terminators
get removed; inform the DTU when this happens.

Also add a testcase that fails an assertion in the DTU without this fix.


Reviewers: fhahn, junbuml

Reviewed By: fhahn

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D55027

llvm-svn: 347872
This commit is contained in:
Joseph Tremoulet 2018-11-29 15:27:04 +00:00
parent c65201ef09
commit 7c785c2fc4
2 changed files with 32 additions and 1 deletions

View File

@ -365,8 +365,10 @@ static void splitCallSite(
// attempting removal.
SmallVector<BasicBlock *, 2> Splits(predecessors((TailBB)));
assert(Splits.size() == 2 && "Expected exactly 2 splits!");
for (unsigned i = 0; i < Splits.size(); i++)
for (unsigned i = 0; i < Splits.size(); i++) {
Splits[i]->getTerminator()->eraseFromParent();
DTU.deleteEdge(Splits[i], TailBB);
}
// Erase the tail block once done with musttail patching
DTU.deleteBB(TailBB);

View File

@ -73,3 +73,32 @@ End:
define void @void_callee(i8* %a, i8* %b) noinline {
ret void
}
; Include a test with a larger CFG that exercises the DomTreeUpdater
; machinery a bit more.
;CHECK-LABEL: @larger_cfg_caller
;CHECK-LABEL: Top.split:
;CHECK: %r1 = musttail call i8* @callee(i8* null, i8* %b)
;CHECK: ret i8* %r1
;CHECK-LABEL: TBB.split
;CHECK: %r2 = musttail call i8* @callee(i8* nonnull %a, i8* null)
;CHECK: ret i8* %r2
define i8* @larger_cfg_caller(i8* %a, i8* %b) {
Top:
%cond1 = icmp eq i8* %a, null
br i1 %cond1, label %Tail, label %ExtraTest
ExtraTest:
%a0 = load i8, i8* %a
%cond2 = icmp eq i8 %a0, 0
br i1 %cond2, label %TBB_pred, label %End
TBB_pred:
br label %TBB
TBB:
%cond3 = icmp eq i8* %b, null
br i1 %cond3, label %Tail, label %End
Tail:
%r = musttail call i8* @callee(i8* %a, i8* %b)
ret i8* %r
End:
ret i8* null
}