1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
2 ; RUN: opt -S -verify -iroutliner -ir-outlining-no-cost < %s | FileCheck %s
4 ; This test checks that we sucessfully outline identical memcpy var arg
5 ; intrinsics, but not the var arg instruction itself.
7 declare void @llvm.va_start(i8*)
8 declare void @llvm.va_copy(i8*, i8*)
9 declare void @llvm.va_end(i8*)
11 define i32 @func1(i32 %a, double %b, i8* %v, ...) nounwind {
13 %a.addr = alloca i32, align 4
14 %b.addr = alloca double, align 8
15 %ap = alloca i8*, align 4
16 %c = alloca i32, align 4
17 store i32 %a, i32* %a.addr, align 4
18 store double %b, double* %b.addr, align 8
19 %ap1 = bitcast i8** %ap to i8*
20 call void @llvm.va_start(i8* %ap1)
21 %0 = va_arg i8** %ap, i32
22 call void @llvm.va_copy(i8* %v, i8* %ap1)
23 call void @llvm.va_end(i8* %ap1)
24 store i32 %0, i32* %c, align 4
25 %tmp = load i32, i32* %c, align 4
29 define i32 @func2(i32 %a, double %b, i8* %v, ...) nounwind {
31 %a.addr = alloca i32, align 4
32 %b.addr = alloca double, align 8
33 %ap = alloca i8*, align 4
34 %c = alloca i32, align 4
35 store i32 %a, i32* %a.addr, align 4
36 store double %b, double* %b.addr, align 8
37 %ap1 = bitcast i8** %ap to i8*
38 call void @llvm.va_start(i8* %ap1)
39 %0 = va_arg i8** %ap, i32
40 call void @llvm.va_copy(i8* %v, i8* %ap1)
41 call void @llvm.va_end(i8* %ap1)
42 store i32 %0, i32* %c, align 4
43 %ap2 = bitcast i8** %ap to i8*
44 %tmp = load i32, i32* %c, align 4
47 ; CHECK-LABEL: @func1(
49 ; CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
50 ; CHECK-NEXT: [[B_ADDR:%.*]] = alloca double, align 8
51 ; CHECK-NEXT: [[AP:%.*]] = alloca i8*, align 4
52 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
53 ; CHECK-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
54 ; CHECK-NEXT: store double [[B:%.*]], double* [[B_ADDR]], align 8
55 ; CHECK-NEXT: [[AP1:%.*]] = bitcast i8** [[AP]] to i8*
56 ; CHECK-NEXT: call void @llvm.va_start(i8* [[AP1]])
57 ; CHECK-NEXT: [[TMP0:%.*]] = va_arg i8** [[AP]], i32
58 ; CHECK-NEXT: call void @outlined_ir_func_0(i8* [[V:%.*]], i8* [[AP1]], i32 [[TMP0]], i32* [[C]])
59 ; CHECK-NEXT: [[TMP:%.*]] = load i32, i32* [[C]], align 4
60 ; CHECK-NEXT: ret i32 [[TMP]]
63 ; CHECK-LABEL: @func2(
65 ; CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
66 ; CHECK-NEXT: [[B_ADDR:%.*]] = alloca double, align 8
67 ; CHECK-NEXT: [[AP:%.*]] = alloca i8*, align 4
68 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
69 ; CHECK-NEXT: store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
70 ; CHECK-NEXT: store double [[B:%.*]], double* [[B_ADDR]], align 8
71 ; CHECK-NEXT: [[AP1:%.*]] = bitcast i8** [[AP]] to i8*
72 ; CHECK-NEXT: call void @llvm.va_start(i8* [[AP1]])
73 ; CHECK-NEXT: [[TMP0:%.*]] = va_arg i8** [[AP]], i32
74 ; CHECK-NEXT: call void @outlined_ir_func_0(i8* [[V:%.*]], i8* [[AP1]], i32 [[TMP0]], i32* [[C]])
75 ; CHECK-NEXT: [[AP2:%.*]] = bitcast i8** [[AP]] to i8*
76 ; CHECK-NEXT: [[TMP:%.*]] = load i32, i32* [[C]], align 4
77 ; CHECK-NEXT: ret i32 [[TMP]]
80 ; CHECK: define internal void @outlined_ir_func_0(
81 ; CHECK-NEXT: newFuncRoot:
82 ; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]]
83 ; CHECK: entry_to_outline:
84 ; CHECK-NEXT: call void @llvm.va_copy(i8* [[TMP0:%.*]], i8* [[TMP1:%.*]])
85 ; CHECK-NEXT: call void @llvm.va_end(i8* [[TMP1]])
86 ; CHECK-NEXT: store i32 [[TMP2:%.*]], i32* [[TMP3:%.*]], align 4
87 ; CHECK-NEXT: br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]]
88 ; CHECK: entry_after_outline.exitStub:
89 ; CHECK-NEXT: ret void