blob: 29cef50fe802923010db4702821d996d00449119 [file] [log] [blame]
Chandler Carruth044d1e02017-02-06 08:43:11 +00001; RUN: opt < %s -argpromotion -S | FileCheck %s
Chandler Carruthaddcda42017-02-09 23:46:27 +00002; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
Chris Lattner5630c4f2008-01-17 01:17:03 +00003
Chandler Carruth044d1e02017-02-06 08:43:11 +00004%struct.ss = type { i32, i64 }
Chris Lattner5630c4f2008-01-17 01:17:03 +00005
Chandler Carruth044d1e02017-02-06 08:43:11 +00006; 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)
Chris Lattner5630c4f2008-01-17 01:17:03 +000010entry:
Chandler Carruth044d1e02017-02-06 08:43:11 +000011; 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]]
Chris Lattner5630c4f2008-01-17 01:17:03 +000016
Chandler Carruth044d1e02017-02-06 08:43:11 +000017 %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
Chris Lattner5630c4f2008-01-17 01:17:03 +000029}
30
Chandler Carruth044d1e02017-02-06 08:43:11 +000031; Also make sure we don't drop the call zeroext attribute.
Chris Lattner5630c4f2008-01-17 01:17:03 +000032define i32 @test(i32* %X) {
Chandler Carruth044d1e02017-02-06 08:43:11 +000033; CHECK-LABEL: define i32 @test(
Chris Lattner5630c4f2008-01-17 01:17:03 +000034entry:
Chandler Carruth044d1e02017-02-06 08:43:11 +000035 %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
Chris Lattner5630c4f2008-01-17 01:17:03 +000052}