[PATCH] D55027: [CallSiteSplitting] Report edge deletion to DomTreeUpdater
Joseph Tremoulet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 28 14:06:17 PST 2018
JosephTremoulet created this revision.
JosephTremoulet added reviewers: fhahn, junbuml.
Herald added a subscriber: llvm-commits.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D55027
Files:
lib/Transforms/Scalar/CallSiteSplitting.cpp
test/Transforms/CallSiteSplitting/musttail.ll
Index: test/Transforms/CallSiteSplitting/musttail.ll
===================================================================
--- test/Transforms/CallSiteSplitting/musttail.ll
+++ test/Transforms/CallSiteSplitting/musttail.ll
@@ -73,3 +73,32 @@
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
+}
Index: lib/Transforms/Scalar/CallSiteSplitting.cpp
===================================================================
--- lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -365,8 +365,10 @@
// 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55027.175766.patch
Type: text/x-patch
Size: 1804 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181128/85321396/attachment.bin>
More information about the llvm-commits
mailing list