xref: /llvm-project/llvm/test/Transforms/IROutliner/illegal-returns-twice.ll (revision f4b925ee7078f058602fd323e25f45f1ae91ca34)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
3
4; This test checks that we do not outline functions that are marked as returns
5; twice, since these can alter the frame of the function and affect how the
6; outliner behaves, causing miscompiles.
7
8; Function Attrs: optsize returns_twice
9declare i32 @setjmp(ptr) local_unnamed_addr #1
10@tmp_jmpb = global [37 x i32] zeroinitializer, align 16
11
12define void @function1() {
13; CHECK-LABEL: @function1(
14; CHECK-NEXT:  entry:
15; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
16; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
17; CHECK-NEXT:    [[C:%.*]] = alloca i32, align 4
18; CHECK-NEXT:    store i32 2, ptr [[A]], align 4
19; CHECK-NEXT:    store i32 3, ptr [[B]], align 4
20; CHECK-NEXT:    store i32 4, ptr [[C]], align 4
21; CHECK-NEXT:    [[CALL:%.*]] = call i32 @setjmp(ptr @tmp_jmpb)
22; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])
23; CHECK-NEXT:    ret void
24;
25entry:
26  %a = alloca i32, align 4
27  %b = alloca i32, align 4
28  %c = alloca i32, align 4
29  store i32 2, ptr %a, align 4
30  store i32 3, ptr %b, align 4
31  store i32 4, ptr %c, align 4
32  %call = call i32 @setjmp(ptr @tmp_jmpb)
33  %al = load i32, ptr %a
34  %bl = load i32, ptr %b
35  %cl = load i32, ptr %c
36  ret void
37}
38
39define void @function2() {
40; CHECK-LABEL: @function2(
41; CHECK-NEXT:  entry:
42; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
43; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
44; CHECK-NEXT:    [[C:%.*]] = alloca i32, align 4
45; CHECK-NEXT:    store i32 2, ptr [[A]], align 4
46; CHECK-NEXT:    store i32 3, ptr [[B]], align 4
47; CHECK-NEXT:    store i32 4, ptr [[C]], align 4
48; CHECK-NEXT:    [[CALL:%.*]] = call i32 @setjmp(ptr @tmp_jmpb)
49; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])
50; CHECK-NEXT:    ret void
51;
52entry:
53  %a = alloca i32, align 4
54  %b = alloca i32, align 4
55  %c = alloca i32, align 4
56  store i32 2, ptr %a, align 4
57  store i32 3, ptr %b, align 4
58  store i32 4, ptr %c, align 4
59  %call = call i32 @setjmp(ptr @tmp_jmpb)
60  %al = load i32, ptr %a
61  %bl = load i32, ptr %b
62  %cl = load i32, ptr %c
63  ret void
64}
65
66attributes #1 = { optsize returns_twice }
67