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
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.
8 ; Function Attrs: optsize returns_twice
9 declare i32 @setjmp(ptr) local_unnamed_addr #1
10 @tmp_jmpb = global [37 x i32] zeroinitializer, align 16
12 define void @function1() {
13 ; CHECK-LABEL: @function1(
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
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
39 define void @function2() {
40 ; CHECK-LABEL: @function2(
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
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
66 attributes #1 = { optsize returns_twice }