• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2; RUN: opt < %s -argpromotion -S | FileCheck %s
3; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
4
5target 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"
6
7%struct.ss = type { i32, i64 }
8
9define internal void @f(%struct.ss* byval(%struct.ss)  %b) nounwind  {
10; CHECK-LABEL: define {{[^@]+}}@f
11; CHECK-SAME: (i32 [[B_0:%.*]], i64 [[B_1:%.*]])
12; CHECK-NEXT:  entry:
13; CHECK-NEXT:    [[B:%.*]] = alloca [[STRUCT_SS:%.*]], align 4
14; CHECK-NEXT:    [[DOT0:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B]], i32 0, i32 0
15; CHECK-NEXT:    store i32 [[B_0]], i32* [[DOT0]], align 4
16; CHECK-NEXT:    [[DOT1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B]], i32 0, i32 1
17; CHECK-NEXT:    store i64 [[B_1]], i64* [[DOT1]], align 4
18; CHECK-NEXT:    [[TMP:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B]], i32 0, i32 0
19; CHECK-NEXT:    [[TMP1:%.*]] = load i32, i32* [[TMP]], align 4
20; CHECK-NEXT:    [[TMP2:%.*]] = add i32 [[TMP1]], 1
21; CHECK-NEXT:    store i32 [[TMP2]], i32* [[TMP]], align 4
22; CHECK-NEXT:    ret void
23;
24entry:
25  %tmp = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 0
26  %tmp1 = load i32, i32* %tmp, align 4
27  %tmp2 = add i32 %tmp1, 1
28  store i32 %tmp2, i32* %tmp, align 4
29  ret void
30}
31
32
33define internal void @g(%struct.ss* byval(%struct.ss) align 32 %b) nounwind {
34; CHECK-LABEL: define {{[^@]+}}@g
35; CHECK-SAME: (i32 [[B_0:%.*]], i64 [[B_1:%.*]])
36; CHECK-NEXT:  entry:
37; CHECK-NEXT:    [[B:%.*]] = alloca [[STRUCT_SS:%.*]], align 32
38; CHECK-NEXT:    [[DOT0:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B]], i32 0, i32 0
39; CHECK-NEXT:    store i32 [[B_0]], i32* [[DOT0]], align 4
40; CHECK-NEXT:    [[DOT1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B]], i32 0, i32 1
41; CHECK-NEXT:    store i64 [[B_1]], i64* [[DOT1]], align 4
42; CHECK-NEXT:    [[TMP:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[B]], i32 0, i32 0
43; CHECK-NEXT:    [[TMP1:%.*]] = load i32, i32* [[TMP]], align 4
44; CHECK-NEXT:    [[TMP2:%.*]] = add i32 [[TMP1]], 1
45; CHECK-NEXT:    store i32 [[TMP2]], i32* [[TMP]], align 4
46; CHECK-NEXT:    ret void
47;
48entry:
49  %tmp = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 0
50  %tmp1 = load i32, i32* %tmp, align 4
51  %tmp2 = add i32 %tmp1, 1
52  store i32 %tmp2, i32* %tmp, align 4
53  ret void
54}
55
56
57define i32 @main() nounwind  {
58; CHECK-LABEL: define {{[^@]+}}@main()
59; CHECK-NEXT:  entry:
60; CHECK-NEXT:    [[S:%.*]] = alloca [[STRUCT_SS:%.*]], align 4
61; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 0
62; CHECK-NEXT:    store i32 1, i32* [[TMP1]], align 8
63; CHECK-NEXT:    [[TMP4:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 1
64; CHECK-NEXT:    store i64 2, i64* [[TMP4]], align 4
65; CHECK-NEXT:    [[S_0:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 0
66; CHECK-NEXT:    [[S_0_VAL:%.*]] = load i32, i32* [[S_0]], align 4
67; CHECK-NEXT:    [[S_1:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 1
68; CHECK-NEXT:    [[S_1_VAL:%.*]] = load i64, i64* [[S_1]], align 4
69; CHECK-NEXT:    call void @f(i32 [[S_0_VAL]], i64 [[S_1_VAL]])
70; CHECK-NEXT:    [[S_01:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 0
71; CHECK-NEXT:    [[S_01_VAL:%.*]] = load i32, i32* [[S_01]], align 4
72; CHECK-NEXT:    [[S_12:%.*]] = getelementptr [[STRUCT_SS]], %struct.ss* [[S]], i32 0, i32 1
73; CHECK-NEXT:    [[S_12_VAL:%.*]] = load i64, i64* [[S_12]], align 4
74; CHECK-NEXT:    call void @g(i32 [[S_01_VAL]], i64 [[S_12_VAL]])
75; CHECK-NEXT:    ret i32 0
76;
77entry:
78  %S = alloca %struct.ss
79  %tmp1 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 0
80  store i32 1, i32* %tmp1, align 8
81  %tmp4 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 1
82  store i64 2, i64* %tmp4, align 4
83  call void @f(%struct.ss* byval(%struct.ss) %S) nounwind
84  call void @g(%struct.ss* byval(%struct.ss) %S) nounwind
85  ret i32 0
86}
87
88
89