[llvm] 9f5f917 - [NFC][SimplifyCFG] Add basic test for tail-merging `resume` function terminators

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 24 05:09:06 PDT 2021


Author: Roman Lebedev
Date: 2021-06-24T15:08:55+03:00
New Revision: 9f5f91778710a891b2b5ccafeb783c3609192ae8

URL: https://github.com/llvm/llvm-project/commit/9f5f91778710a891b2b5ccafeb783c3609192ae8
DIFF: https://github.com/llvm/llvm-project/commit/9f5f91778710a891b2b5ccafeb783c3609192ae8.diff

LOG: [NFC][SimplifyCFG] Add basic test for tail-merging `resume` function terminators

Added: 
    llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll b/llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll
new file mode 100644
index 0000000000000..e38937a58aeb2
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll
@@ -0,0 +1,67 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -sink-common-insts  -S < %s | FileCheck %s
+
+; Test that we tail merge resume blocks and phi operands properly.
+
+declare void @foo()
+declare void @bar()
+declare void @baz()
+declare void @qux()
+declare void @quux()
+declare void @quuz()
+
+define void @merge_simple(i1 %cond) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+; CHECK-LABEL: @merge_simple(
+; CHECK-NEXT:    invoke void @foo()
+; CHECK-NEXT:    to label [[INVOKE_CONT:%.*]] unwind label [[LPAD:%.*]]
+; CHECK:       invoke.cont:
+; CHECK-NEXT:    invoke void @bar()
+; CHECK-NEXT:    to label [[INVOKE_CONT2:%.*]] unwind label [[LPAD2:%.*]]
+; CHECK:       invoke.cont2:
+; CHECK-NEXT:    ret void
+; CHECK:       lpad:
+; CHECK-NEXT:    [[LP:%.*]] = landingpad { i8*, i32 }
+; CHECK-NEXT:    cleanup
+; CHECK-NEXT:    call void @baz()
+; CHECK-NEXT:    br i1 [[COND:%.*]], label [[RESUME0:%.*]], label [[RESUME1:%.*]]
+; CHECK:       lpad2:
+; CHECK-NEXT:    [[LP2:%.*]] = landingpad { i8*, i32 }
+; CHECK-NEXT:    cleanup
+; CHECK-NEXT:    call void @quuz()
+; CHECK-NEXT:    resume { i8*, i32 } [[LP2]]
+; CHECK:       resume0:
+; CHECK-NEXT:    call void @qux()
+; CHECK-NEXT:    resume { i8*, i32 } [[LP]]
+; CHECK:       resume1:
+; CHECK-NEXT:    call void @quux()
+; CHECK-NEXT:    resume { i8*, i32 } [[LP]]
+;
+  invoke void @foo() to label %invoke.cont unwind label %lpad
+
+invoke.cont:
+  invoke void @bar()to label %invoke.cont2 unwind label %lpad2
+  ret void
+
+invoke.cont2:
+  ret void
+
+lpad:
+  %lp = landingpad { i8*, i32 } cleanup
+  call void @baz()
+  br i1 %cond, label %resume0, label %resume1
+
+lpad2:
+  %lp2 = landingpad { i8*, i32 } cleanup
+  call void @quuz()
+  resume { i8*, i32 } %lp2
+
+resume0:
+  call void @qux()
+  resume { i8*, i32 } %lp
+
+resume1:
+  call void @quux()
+  resume { i8*, i32 } %lp
+}
+
+declare dso_local i32 @__gxx_personality_v0(...)


        


More information about the llvm-commits mailing list