diff options
| author | Joseph Tremoulet <jotrem@microsoft.com> | 2018-11-29 15:27:04 +0000 |
|---|---|---|
| committer | Joseph Tremoulet <jotrem@microsoft.com> | 2018-11-29 15:27:04 +0000 |
| commit | 926ee459c40dc6e22945439d278f6e4ec553a640 (patch) | |
| tree | aab020e58eb514d8bee0319cdbf60d52d2751175 | |
| parent | de02e4b1cc68695d0af167fec4aa55cd74b0c90e (diff) | |
| download | bcm5719-llvm-926ee459c40dc6e22945439d278f6e4ec553a640.tar.gz bcm5719-llvm-926ee459c40dc6e22945439d278f6e4ec553a640.zip | |
[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
| -rw-r--r-- | llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/Transforms/CallSiteSplitting/musttail.ll | 29 |
2 files changed, 32 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp index 2be41605c98..a806d6faed6 100644 --- a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp +++ b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp @@ -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); diff --git a/llvm/test/Transforms/CallSiteSplitting/musttail.ll b/llvm/test/Transforms/CallSiteSplitting/musttail.ll index f46b9865248..d8f76aed3dc 100644 --- a/llvm/test/Transforms/CallSiteSplitting/musttail.ll +++ b/llvm/test/Transforms/CallSiteSplitting/musttail.ll @@ -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 +} |

