Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -argpromotion -S | FileCheck %s |
Chandler Carruth | addcda4 | 2017-02-09 23:46:27 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s |
Chris Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 3 | |
Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 4 | %struct.ss = type { i32, i64 } |
Chris Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 5 | |
Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 6 | ; Don't drop 'byval' on %X here. |
| 7 | define 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 Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 10 | entry: |
Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 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]] |
Chris Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 16 | |
Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 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 |
Chris Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 29 | } |
| 30 | |
Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 31 | ; Also make sure we don't drop the call zeroext attribute. |
Chris Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 32 | define i32 @test(i32* %X) { |
Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 33 | ; CHECK-LABEL: define i32 @test( |
Chris Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 34 | entry: |
Chandler Carruth | 044d1e0 | 2017-02-06 08:43:11 +0000 | [diff] [blame] | 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 |
Chris Lattner | 5630c4f | 2008-01-17 01:17:03 +0000 | [diff] [blame] | 52 | } |