[NFC][SimplifyCFG] Autogenerate checklines in a few tests

This commit is contained in:
Roman Lebedev 2021-07-02 22:35:14 +03:00
parent aa319f544a
commit 7dd8f98a68
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
2 changed files with 173 additions and 59 deletions

View File

@ -1,3 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
declare void @f()
@ -5,9 +6,22 @@ declare void @llvm.foo(i32) nounwind
declare void @ProcessCLRException()
define void @test1() personality void ()* @ProcessCLRException {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[EXN_DISPATCH:%.*]]
; CHECK: exn.dispatch:
; CHECK-NEXT: [[CS:%.*]] = catchswitch within none [label %pad1] unwind to caller
; CHECK: pad1:
; CHECK-NEXT: [[CP1:%.*]] = catchpad within [[CS]] [i32 1]
; CHECK-NEXT: call void @llvm.foo(i32 1)
; CHECK-NEXT: catchret from [[CP1]] to label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %exit unwind label %exn.dispatch
to label %exit unwind label %exn.dispatch
exn.dispatch:
%cs = catchswitch within none [label %pad1, label %pad2] unwind to caller
pad1:
@ -21,43 +35,51 @@ exit:
ret void
}
; Remove unreachble catch2, leave catch1 as-is
; CHECK-LABEL: define void @test1()
; CHECK: %cs = catchswitch within none [label %pad1] unwind to caller
; CHECK-NOT: catchpad
; CHECK: %cp1 = catchpad within %cs [i32 1]
; CHECK-NOT: catchpad
; Remove both catchpads and the catchswitch from exn.dispatch
; CHECK-LABEL: define void @test2()
define void @test2() personality void ()* @ProcessCLRException {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[VIA_CATCHSWITCH:%.*]] unwind label [[CLEANUP_INNER:%.*]]
; CHECK: cleanup.inner:
; CHECK-NEXT: [[CP_INNER:%.*]] = cleanuppad within none []
; CHECK-NEXT: call void @llvm.foo(i32 0)
; CHECK-NEXT: cleanupret from [[CP_INNER]] unwind to caller
; CHECK: via.catchswitch:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[DISPATCH_INNER:%.*]]
; CHECK: dispatch.inner:
; CHECK-NEXT: [[CS_INNER:%.*]] = catchswitch within none [label %pad.inner] unwind to caller
; CHECK: pad.inner:
; CHECK-NEXT: [[CATCH_INNER:%.*]] = catchpad within [[CS_INNER]] [i32 0]
; CHECK-NEXT: call void @llvm.foo(i32 1)
; CHECK-NEXT: catchret from [[CATCH_INNER]] to label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %via.cleanup unwind label %exn.dispatch
; CHECK-NOT: invoke
; CHECK: call void @f()
to label %via.cleanup unwind label %exn.dispatch
via.cleanup:
invoke void @f()
to label %via.catchswitch unwind label %cleanup.inner
to label %via.catchswitch unwind label %cleanup.inner
cleanup.inner:
%cp.inner = cleanuppad within none []
call void @llvm.foo(i32 0)
cleanupret from %cp.inner unwind label %exn.dispatch
; CHECK: cleanupret from %cp.inner unwind to caller
via.catchswitch:
invoke void @f()
to label %exit unwind label %dispatch.inner
to label %exit unwind label %dispatch.inner
dispatch.inner:
%cs.inner = catchswitch within none [label %pad.inner] unwind label %exn.dispatch
; CHECK: %cs.inner = catchswitch within none [label %pad.inner] unwind to caller
pad.inner:
%catch.inner = catchpad within %cs.inner [i32 0]
; CHECK: %catch.inner = catchpad within %cs.inner
call void @llvm.foo(i32 1)
catchret from %catch.inner to label %exit
exn.dispatch:
%cs = catchswitch within none [label %pad1, label %pad2] unwind to caller
; CHECK-NOT: catchswitch within
; CHECK-NOT: catchpad
pad1:
catchpad within %cs [i32 1]
unreachable
@ -70,36 +92,55 @@ exit:
; Same as @test2, but exn.dispatch catchswitch has an unwind dest that
; preds need to be reidrected to
; CHECK-LABEL: define void @test3()
define void @test3() personality void ()* @ProcessCLRException {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[VIA_CLEANUP:%.*]] unwind label [[CLEANUP:%.*]]
; CHECK: via.cleanup:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[VIA_CATCHSWITCH:%.*]] unwind label [[CLEANUP_INNER:%.*]]
; CHECK: cleanup.inner:
; CHECK-NEXT: [[CP_INNER:%.*]] = cleanuppad within none []
; CHECK-NEXT: call void @llvm.foo(i32 0)
; CHECK-NEXT: cleanupret from [[CP_INNER]] unwind label [[CLEANUP]]
; CHECK: via.catchswitch:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[DISPATCH_INNER:%.*]]
; CHECK: dispatch.inner:
; CHECK-NEXT: [[CS_INNER:%.*]] = catchswitch within none [label %pad.inner] unwind label [[CLEANUP]]
; CHECK: pad.inner:
; CHECK-NEXT: [[CATCH_INNER:%.*]] = catchpad within [[CS_INNER]] [i32 0]
; CHECK-NEXT: call void @llvm.foo(i32 1)
; CHECK-NEXT: catchret from [[CATCH_INNER]] to label [[EXIT]]
; CHECK: cleanup:
; CHECK-NEXT: [[CP:%.*]] = cleanuppad within none []
; CHECK-NEXT: call void @llvm.foo(i32 0)
; CHECK-NEXT: cleanupret from [[CP]] unwind to caller
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %via.cleanup unwind label %exn.dispatch
; CHECK: invoke void @f()
; CHECK-NEXT: to label %via.cleanup unwind label %cleanup
to label %via.cleanup unwind label %exn.dispatch
via.cleanup:
invoke void @f()
to label %via.catchswitch unwind label %cleanup.inner
to label %via.catchswitch unwind label %cleanup.inner
cleanup.inner:
%cp.inner = cleanuppad within none []
call void @llvm.foo(i32 0)
cleanupret from %cp.inner unwind label %exn.dispatch
; CHECK: cleanupret from %cp.inner unwind label %cleanup
via.catchswitch:
invoke void @f()
to label %exit unwind label %dispatch.inner
to label %exit unwind label %dispatch.inner
dispatch.inner:
%cs.inner = catchswitch within none [label %pad.inner] unwind label %exn.dispatch
; CHECK: %cs.inner = catchswitch within none [label %pad.inner] unwind label %cleanup
pad.inner:
%catch.inner = catchpad within %cs.inner [i32 0]
; CHECK: %catch.inner = catchpad within %cs.inner
call void @llvm.foo(i32 1)
catchret from %catch.inner to label %exit
exn.dispatch:
%cs = catchswitch within none [label %pad1, label %pad2] unwind label %cleanup
; CHECK-NOT: catchswitch within
; CHECK-NOT: catchpad
pad1:
catchpad within %cs [i32 1]
unreachable

View File

@ -1,14 +1,18 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
declare void @Personality()
declare void @f()
; CHECK-LABEL: define void @test1()
define void @test1() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @f()
; CHECK-NEXT: ret void
;
entry:
; CHECK: call void @f()
invoke void @f()
to label %exit unwind label %unreachable.unwind
to label %exit unwind label %unreachable.unwind
exit:
ret void
unreachable.unwind:
@ -16,20 +20,28 @@ unreachable.unwind:
unreachable
}
; CHECK-LABEL: define void @test2()
define void @test2() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK: catch.pad:
; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK: catch.body:
; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] []
; CHECK-NEXT: call void @f()
; CHECK-NEXT: catchret from [[CATCH]] to label [[UNREACHABLE:%.*]]
; CHECK: exit:
; CHECK-NEXT: ret void
; CHECK: unreachable:
; CHECK-NEXT: unreachable
;
entry:
invoke void @f()
to label %exit unwind label %catch.pad
to label %exit unwind label %catch.pad
catch.pad:
%cs1 = catchswitch within none [label %catch.body] unwind label %unreachable.unwind
; CHECK: catch.pad:
; CHECK-NEXT: catchswitch within none [label %catch.body] unwind to caller
catch.body:
; CHECK: catch.body:
; CHECK-NEXT: catchpad within %cs1
; CHECK-NEXT: call void @f()
; CHECK-NEXT: unreachable
%catch = catchpad within %cs1 []
call void @f()
catchret from %catch to label %unreachable
@ -42,18 +54,25 @@ unreachable:
unreachable
}
; CHECK-LABEL: define void @test3()
define void @test3() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CLEANUP_PAD:%.*]]
; CHECK: cleanup.pad:
; CHECK-NEXT: [[CLEANUP:%.*]] = cleanuppad within none []
; CHECK-NEXT: call void @f()
; CHECK-NEXT: unreachable
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %exit unwind label %cleanup.pad
to label %exit unwind label %cleanup.pad
cleanup.pad:
; CHECK: %cleanup = cleanuppad within none []
; CHECK-NEXT: call void @f()
; CHECK-NEXT: unreachable
%cleanup = cleanuppad within none []
invoke void @f()
to label %cleanup.ret unwind label %unreachable.unwind
to label %cleanup.ret unwind label %unreachable.unwind
cleanup.ret:
; This cleanupret should be rewritten to unreachable,
; and merged into the pred block.
@ -65,11 +84,22 @@ unreachable.unwind:
unreachable
}
; CHECK-LABEL: define void @test5()
define void @test5() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK: catch.pad:
; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK: catch.body:
; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] []
; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: unreachable
;
entry:
invoke void @f()
to label %exit unwind label %catch.pad
to label %exit unwind label %catch.pad
catch.pad:
%cs1 = catchswitch within none [label %catch.body] unwind to caller
@ -82,15 +112,25 @@ exit:
unreachable
}
; CHECK-LABEL: define void @test6()
define void @test6() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test6(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK: catch.pad:
; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK: catch.body:
; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %exit unwind label %catch.pad
to label %exit unwind label %catch.pad
catch.pad:
%cs1 = catchswitch within none [label %catch.body, label %catch.body] unwind to caller
; CHECK: catchswitch within none [label %catch.body] unwind to caller
catch.body:
%catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
@ -100,15 +140,25 @@ exit:
ret void
}
; CHECK-LABEL: define void @test7()
define void @test7() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test7(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK: catch.pad:
; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK: catch.body:
; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %exit unwind label %catch.pad
to label %exit unwind label %catch.pad
catch.pad:
%cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
; CHECK: catchswitch within none [label %catch.body] unwind to caller
catch.body:
%catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
@ -122,15 +172,25 @@ exit:
ret void
}
; CHECK-LABEL: define void @test8()
define void @test8() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK: catch.pad:
; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK: catch.body:
; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %exit unwind label %catch.pad
to label %exit unwind label %catch.pad
catch.pad:
%cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
; CHECK: catchswitch within none [label %catch.body] unwind to caller
catch.body2:
%catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
@ -144,15 +204,28 @@ exit:
ret void
}
; CHECK-LABEL: define void @test9()
define void @test9() personality i8* bitcast (void ()* @Personality to i8*) {
; CHECK-LABEL: @test9(
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void @f()
; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK: catch.pad:
; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label [[CATCH_BODY:%.*]], label %catch.body2] unwind to caller
; CHECK: catch.body:
; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
; CHECK: catch.body2:
; CHECK-NEXT: [[CATCH2:%.*]] = catchpad within [[CS1]] [i8* null, i32 64, i8* null]
; CHECK-NEXT: catchret from [[CATCH2]] to label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
invoke void @f()
to label %exit unwind label %catch.pad
to label %exit unwind label %catch.pad
catch.pad:
%cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
; CHECK: catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
catch.body:
%catch = catchpad within %cs1 [i8* null, i32 0, i8* null]