xref: /llvm-project/llvm/test/Transforms/IROutliner/illegal-cleanup.ll (revision f4b925ee7078f058602fd323e25f45f1ae91ca34)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -passes=verify,iroutliner -no-ir-sim-branch-matching -ir-outlining-no-cost < %s | FileCheck %s
3
4; This test checks that cleanuppad instructions are not outlined even if they
5; in a similar section.  Dealing with exception handling inside of an outlined
6; function would require a lot of handling that is not implemented yet.
7
8declare void @llvm.donothing() nounwind readnone
9
10define void @function1() personality i8 3 {
11; CHECK-LABEL: @function1(
12; CHECK-NEXT:  entry:
13; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
14; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
15; CHECK-NEXT:    invoke void @llvm.donothing()
16; CHECK-NEXT:    to label [[NORMAL:%.*]] unwind label [[EXCEPTION:%.*]]
17; CHECK:       exception:
18; CHECK-NEXT:    [[CLEAN:%.*]] = cleanuppad within none []
19; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]])
20; CHECK-NEXT:    br label [[NORMAL]]
21; CHECK:       normal:
22; CHECK-NEXT:    ret void
23;
24entry:
25  %a = alloca i32, align 4
26  %b = alloca i32, align 4
27  invoke void @llvm.donothing() to label %normal unwind label %exception
28exception:
29  %clean = cleanuppad within none []
30  store i32 2, ptr %a, align 4
31  store i32 3, ptr %b, align 4
32  br label %normal
33normal:
34  ret void
35}
36
37define void @function2() personality i8 3 {
38; CHECK-LABEL: @function2(
39; CHECK-NEXT:  entry:
40; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
41; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
42; CHECK-NEXT:    invoke void @llvm.donothing()
43; CHECK-NEXT:    to label [[NORMAL:%.*]] unwind label [[EXCEPTION:%.*]]
44; CHECK:       exception:
45; CHECK-NEXT:    [[CLEAN:%.*]] = cleanuppad within none []
46; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]])
47; CHECK-NEXT:    br label [[NORMAL]]
48; CHECK:       normal:
49; CHECK-NEXT:    ret void
50;
51entry:
52  %a = alloca i32, align 4
53  %b = alloca i32, align 4
54  invoke void @llvm.donothing() to label %normal unwind label %exception
55exception:
56  %clean = cleanuppad within none []
57  store i32 2, ptr %a, align 4
58  store i32 3, ptr %b, align 4
59  br label %normal
60normal:
61  ret void
62}
63