[PATCH] D104849: [SimplifyCFG] Tail-merging all blocks with `resume` terminator
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 24 11:26:13 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
lebedev.ri marked an inline comment as done.
Closed by commit rGd0641826121d: [SimplifyCFG] Tail-merging all blocks with `resume` terminator (authored by lebedev.ri).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104849/new/
https://reviews.llvm.org/D104849
Files:
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll
Index: llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll
+++ llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll
@@ -39,19 +39,20 @@
; CHECK-NEXT: cleanup
; CHECK-NEXT: call void @baz()
; CHECK-NEXT: br label [[RESUME2]]
+; CHECK: common.resume:
+; CHECK-NEXT: [[COMMON_RESUME_OP:%.*]] = phi { i8*, i32 } [ [[LP]], [[RESUME0]] ], [ [[LP]], [[RESUME1]] ], [ [[SEMICOMMON_LP:%.*]], [[RESUME2]] ]
+; CHECK-NEXT: call void @common()
+; CHECK-NEXT: resume { i8*, i32 } [[COMMON_RESUME_OP]]
; CHECK: resume0:
; CHECK-NEXT: call void @qux()
-; CHECK-NEXT: call void @common()
-; CHECK-NEXT: resume { i8*, i32 } [[LP]]
+; CHECK-NEXT: br label [[COMMON_RESUME:%.*]]
; CHECK: resume1:
; CHECK-NEXT: call void @quux()
-; CHECK-NEXT: call void @common()
-; CHECK-NEXT: resume { i8*, i32 } [[LP]]
+; CHECK-NEXT: br label [[COMMON_RESUME]]
; CHECK: resume2:
-; CHECK-NEXT: [[SEMICOMMON_LP:%.*]] = phi { i8*, i32 } [ [[LP2]], [[LPAD2]] ], [ [[LP3]], [[LPAD3]] ]
+; CHECK-NEXT: [[SEMICOMMON_LP]] = phi { i8*, i32 } [ [[LP2]], [[LPAD2]] ], [ [[LP3]], [[LPAD3]] ]
; CHECK-NEXT: call void @quuz()
-; CHECK-NEXT: call void @common()
-; CHECK-NEXT: resume { i8*, i32 } [[SEMICOMMON_LP]]
+; CHECK-NEXT: br label [[COMMON_RESUME]]
;
invoke void @maybe_throws() to label %invoke.cont unwind label %lpad
Index: llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -94,10 +94,15 @@
auto *Term = BB.getTerminator();
- // Fow now only support `ret` function terminators.
+ // Fow now only support `ret`/`resume` function terminators.
// FIXME: lift this restriction.
- if (Term->getOpcode() != Instruction::Ret)
+ switch (Term->getOpcode()) {
+ case Instruction::Ret:
+ case Instruction::Resume:
+ break;
+ default:
continue;
+ }
// We can't tail-merge block that contains a musttail call.
if (BB.getTerminatingMustTailCall())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104849.354315.patch
Type: text/x-patch
Size: 2259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210624/4bf8b142/attachment.bin>
More information about the llvm-commits
mailing list