[llvm] r347872 - [CallSiteSplitting] Report edge deletion to DomTreeUpdater
Joseph Tremoulet via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 29 07:27:04 PST 2018
Author: josepht
Date: Thu Nov 29 07:27:04 2018
New Revision: 347872
URL: http://llvm.org/viewvc/llvm-project?rev=347872&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
llvm/trunk/test/Transforms/CallSiteSplitting/musttail.ll
Modified: llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp?rev=347872&r1=347871&r2=347872&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp Thu Nov 29 07:27:04 2018
@@ -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);
Modified: llvm/trunk/test/Transforms/CallSiteSplitting/musttail.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CallSiteSplitting/musttail.ll?rev=347872&r1=347871&r2=347872&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CallSiteSplitting/musttail.ll (original)
+++ llvm/trunk/test/Transforms/CallSiteSplitting/musttail.ll Thu Nov 29 07:27:04 2018
@@ -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
+}
More information about the llvm-commits
mailing list