1; RUN: opt < %s -argpromotion -S | FileCheck %s
2; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
3
4%struct.ss = type { i32, i64 }
5
6; Don't drop 'byval' on %X here.
7define internal void @f(%struct.ss* byval %b, i32* byval %X, i32 %i) nounwind {
8; CHECK-LABEL: define internal void @f(
9; CHECK: i32 %[[B0:.*]], i64 %[[B1:.*]], i32* byval %X, i32 %i)
10entry:
11; CHECK: %[[B:.*]] = alloca %struct.ss
12; CHECK: %[[B_GEP0:.*]] = getelementptr %struct.ss, %struct.ss* %[[B]], i32 0, i32 0
13; CHECK: store i32 %[[B0]], i32* %[[B_GEP0]]
14; CHECK: %[[B_GEP1:.*]] = getelementptr %struct.ss, %struct.ss* %[[B]], i32 0, i32 1
15; CHECK: store i64 %[[B1]], i64* %[[B_GEP1]]
16
17  %tmp = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 0
18; CHECK: %[[TMP:.*]] = getelementptr %struct.ss, %struct.ss* %[[B]], i32 0, i32 0
19  %tmp1 = load i32, i32* %tmp, align 4
20; CHECK: %[[TMP1:.*]] = load i32, i32* %[[TMP]]
21  %tmp2 = add i32 %tmp1, 1
22; CHECK: %[[TMP2:.*]] = add i32 %[[TMP1]], 1
23  store i32 %tmp2, i32* %tmp, align 4
24; CHECK: store i32 %[[TMP2]], i32* %[[TMP]]
25
26  store i32 0, i32* %X
27; CHECK: store i32 0, i32* %X
28  ret void
29}
30
31; Also make sure we don't drop the call zeroext attribute.
32define i32 @test(i32* %X) {
33; CHECK-LABEL: define i32 @test(
34entry:
35  %S = alloca %struct.ss
36; CHECK: %[[S:.*]] = alloca %struct.ss
37  %tmp1 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 0
38  store i32 1, i32* %tmp1, align 8
39; CHECK: store i32 1
40  %tmp4 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 1
41  store i64 2, i64* %tmp4, align 4
42; CHECK: store i64 2
43
44  call void @f( %struct.ss* byval %S, i32* byval %X, i32 zeroext 0)
45; CHECK: %[[S_GEP0:.*]] = getelementptr %struct.ss, %struct.ss* %[[S]], i32 0, i32 0
46; CHECK: %[[S0:.*]] = load i32, i32* %[[S_GEP0]]
47; CHECK: %[[S_GEP1:.*]] = getelementptr %struct.ss, %struct.ss* %[[S]], i32 0, i32 1
48; CHECK: %[[S1:.*]] = load i64, i64* %[[S_GEP1]]
49; CHECK: call void @f(i32 %[[S0]], i64 %[[S1]], i32* byval %X, i32 zeroext 0)
50
51  ret i32 0
52}
53