1 ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
3 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
5 %struct.ss = type { i32, i64 }
7 define internal void @f(ptr byval(ptr) align 4 %p) nounwind {
8 ; CHECK-LABEL: define {{[^@]+}}@f
9 ; CHECK-SAME: (ptr byval(ptr) align 4 [[P:%.*]]) #[[ATTR0:[0-9]+]] {
11 ; CHECK-NEXT: store ptr [[P]], ptr [[P]]
12 ; CHECK-NEXT: ret void
19 define internal void @g(ptr byval(ptr) align 4 %p) nounwind {
20 ; CHECK-LABEL: define {{[^@]+}}@g
21 ; CHECK-SAME: (ptr byval(ptr) align 4 [[P:%.*]]) #[[ATTR0]] {
23 ; CHECK-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P]], i64 4
24 ; CHECK-NEXT: store ptr [[P]], ptr [[P1]]
25 ; CHECK-NEXT: ret void
28 %p1 = getelementptr i8, ptr %p, i64 4
33 define internal void @h(ptr byval(ptr) align 4 %p) nounwind {
34 ; CHECK-LABEL: define {{[^@]+}}@h
35 ; CHECK-SAME: (ptr byval(ptr) align 4 [[P:%.*]]) #[[ATTR0]] {
37 ; CHECK-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[P]], i64 4
38 ; CHECK-NEXT: store ptr [[P1]], ptr [[P]]
39 ; CHECK-NEXT: ret void
42 %p1 = getelementptr i8, ptr %p, i64 4
47 define internal void @k(ptr byval(ptr) align 4 %p) nounwind {
48 ; CHECK-LABEL: define {{[^@]+}}@k
49 ; CHECK-SAME: (ptr byval(ptr) align 4 [[P:%.*]]) #[[ATTR0]] {
51 ; CHECK-NEXT: [[X:%.*]] = load ptr, ptr [[P]]
52 ; CHECK-NEXT: store ptr [[P]], ptr [[X]]
53 ; CHECK-NEXT: ret void
61 define internal void @l(ptr byval(ptr) align 4 %p) nounwind {
62 ; CHECK-LABEL: define {{[^@]+}}@l
63 ; CHECK-SAME: () #[[ATTR0]] {
65 ; CHECK-NEXT: ret void
73 define i32 @main() nounwind {
74 ; CHECK-LABEL: define {{[^@]+}}@main
75 ; CHECK-SAME: () #[[ATTR0]] {
77 ; CHECK-NEXT: [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 32
78 ; CHECK-NEXT: [[TEMP1:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 0
79 ; CHECK-NEXT: store i32 1, ptr [[TEMP1]], align 4
80 ; CHECK-NEXT: [[TEMP4:%.*]] = getelementptr [[STRUCT_SS]], ptr [[S]], i32 0, i32 1
81 ; CHECK-NEXT: store i64 2, ptr [[TEMP4]], align 8
82 ; CHECK-NEXT: call void @f(ptr byval(ptr) align 4 [[S]]) #[[ATTR0]]
83 ; CHECK-NEXT: call void @g(ptr byval(ptr) align 4 [[S]]) #[[ATTR0]]
84 ; CHECK-NEXT: call void @h(ptr byval(ptr) align 4 [[S]]) #[[ATTR0]]
85 ; CHECK-NEXT: call void @k(ptr byval(ptr) align 4 [[S]]) #[[ATTR0]]
86 ; CHECK-NEXT: call void @l() #[[ATTR0]]
87 ; CHECK-NEXT: ret i32 0
90 %S = alloca %struct.ss, align 32
91 %temp1 = getelementptr %struct.ss, ptr %S, i32 0, i32 0
92 store i32 1, ptr %temp1, align 4
93 %temp4 = getelementptr %struct.ss, ptr %S, i32 0, i32 1
94 store i64 2, ptr %temp4, align 8
95 call void @f(ptr byval(ptr) align 4 %S) nounwind
96 call void @g(ptr byval(ptr) align 4 %S) nounwind
97 call void @h(ptr byval(ptr) align 4 %S) nounwind
98 call void @k(ptr byval(ptr) align 4 %S) nounwind
99 call void @l(ptr byval(ptr) align 4 %S) nounwind