blob: a85a088291aca16fca718e1d39670ed0f3daa10b [file] [log] [blame]
Chandler Carruth044d1e02017-02-06 08:43:11 +00001; RUN: opt < %s -argpromotion -S | FileCheck %s
Chris Lattner5630c4f2008-01-17 01:17:03 +00002
Chandler Carruth044d1e02017-02-06 08:43:11 +00003%struct.ss = type { i32, i64 }
Chris Lattner5630c4f2008-01-17 01:17:03 +00004
Chandler Carruth044d1e02017-02-06 08:43:11 +00005; Don't drop 'byval' on %X here.
6define internal void @f(%struct.ss* byval %b, i32* byval %X, i32 %i) nounwind {
7; CHECK-LABEL: define internal void @f(
8; CHECK: i32 %[[B0:.*]], i64 %[[B1:.*]], i32* byval %X, i32 %i)
Chris Lattner5630c4f2008-01-17 01:17:03 +00009entry:
Chandler Carruth044d1e02017-02-06 08:43:11 +000010; CHECK: %[[B:.*]] = alloca %struct.ss
11; CHECK: %[[B_GEP0:.*]] = getelementptr %struct.ss, %struct.ss* %[[B]], i32 0, i32 0
12; CHECK: store i32 %[[B0]], i32* %[[B_GEP0]]
13; CHECK: %[[B_GEP1:.*]] = getelementptr %struct.ss, %struct.ss* %[[B]], i32 0, i32 1
14; CHECK: store i64 %[[B1]], i64* %[[B_GEP1]]
Chris Lattner5630c4f2008-01-17 01:17:03 +000015
Chandler Carruth044d1e02017-02-06 08:43:11 +000016 %tmp = getelementptr %struct.ss, %struct.ss* %b, i32 0, i32 0
17; CHECK: %[[TMP:.*]] = getelementptr %struct.ss, %struct.ss* %[[B]], i32 0, i32 0
18 %tmp1 = load i32, i32* %tmp, align 4
19; CHECK: %[[TMP1:.*]] = load i32, i32* %[[TMP]]
20 %tmp2 = add i32 %tmp1, 1
21; CHECK: %[[TMP2:.*]] = add i32 %[[TMP1]], 1
22 store i32 %tmp2, i32* %tmp, align 4
23; CHECK: store i32 %[[TMP2]], i32* %[[TMP]]
24
25 store i32 0, i32* %X
26; CHECK: store i32 0, i32* %X
27 ret void
Chris Lattner5630c4f2008-01-17 01:17:03 +000028}
29
Chandler Carruth044d1e02017-02-06 08:43:11 +000030; Also make sure we don't drop the call zeroext attribute.
Chris Lattner5630c4f2008-01-17 01:17:03 +000031define i32 @test(i32* %X) {
Chandler Carruth044d1e02017-02-06 08:43:11 +000032; CHECK-LABEL: define i32 @test(
Chris Lattner5630c4f2008-01-17 01:17:03 +000033entry:
Chandler Carruth044d1e02017-02-06 08:43:11 +000034 %S = alloca %struct.ss
35; CHECK: %[[S:.*]] = alloca %struct.ss
36 %tmp1 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 0
37 store i32 1, i32* %tmp1, align 8
38; CHECK: store i32 1
39 %tmp4 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 1
40 store i64 2, i64* %tmp4, align 4
41; CHECK: store i64 2
42
43 call void @f( %struct.ss* byval %S, i32* byval %X, i32 zeroext 0)
44; CHECK: %[[S_GEP0:.*]] = getelementptr %struct.ss, %struct.ss* %[[S]], i32 0, i32 0
45; CHECK: %[[S0:.*]] = load i32, i32* %[[S_GEP0]]
46; CHECK: %[[S_GEP1:.*]] = getelementptr %struct.ss, %struct.ss* %[[S]], i32 0, i32 1
47; CHECK: %[[S1:.*]] = load i64, i64* %[[S_GEP1]]
48; CHECK: call void @f(i32 %[[S0]], i64 %[[S1]], i32* byval %X, i32 zeroext 0)
49
50 ret i32 0
Chris Lattner5630c4f2008-01-17 01:17:03 +000051}