1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2 ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
5 ; Don't promote arguments of musttail callee
7 %T = type { i32, i32, i32, i32 }
9 define internal i32 @test(ptr %p) {
10 ; CHECK-LABEL: define {{[^@]+}}@test
11 ; CHECK-SAME: (ptr [[P:%.*]]) {
12 ; CHECK-NEXT: [[A_GEP:%.*]] = getelementptr [[T:%.*]], ptr [[P]], i64 0, i32 3
13 ; CHECK-NEXT: [[B_GEP:%.*]] = getelementptr [[T]], ptr [[P]], i64 0, i32 2
14 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[A_GEP]], align 4
15 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[B_GEP]], align 4
16 ; CHECK-NEXT: [[V:%.*]] = add i32 [[A]], [[B]]
17 ; CHECK-NEXT: ret i32 [[V]]
19 %a.gep = getelementptr %T, ptr %p, i64 0, i32 3
20 %b.gep = getelementptr %T, ptr %p, i64 0, i32 2
21 %a = load i32, ptr %a.gep
22 %b = load i32, ptr %b.gep
27 define i32 @caller(ptr %p) {
28 ; CHECK-LABEL: define {{[^@]+}}@caller
29 ; CHECK-SAME: (ptr [[P:%.*]]) {
30 ; CHECK-NEXT: [[V:%.*]] = musttail call i32 @test(ptr [[P]])
31 ; CHECK-NEXT: ret i32 [[V]]
33 %v = musttail call i32 @test(ptr %p)
37 ; Don't promote arguments of musttail caller
39 define i32 @foo(ptr %p, i32 %v) {
40 ; CHECK-LABEL: define {{[^@]+}}@foo
41 ; CHECK-SAME: (ptr [[P:%.*]], i32 [[V:%.*]]) {
42 ; CHECK-NEXT: ret i32 0
47 define internal i32 @test2(ptr %p, i32 %p2) {
48 ; CHECK-LABEL: define {{[^@]+}}@test2
49 ; CHECK-SAME: (ptr [[P:%.*]], i32 [[P2:%.*]]) {
50 ; CHECK-NEXT: [[A_GEP:%.*]] = getelementptr [[T:%.*]], ptr [[P]], i64 0, i32 3
51 ; CHECK-NEXT: [[B_GEP:%.*]] = getelementptr [[T]], ptr [[P]], i64 0, i32 2
52 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[A_GEP]], align 4
53 ; CHECK-NEXT: [[B:%.*]] = load i32, ptr [[B_GEP]], align 4
54 ; CHECK-NEXT: [[V:%.*]] = add i32 [[A]], [[B]]
55 ; CHECK-NEXT: [[CA:%.*]] = musttail call i32 @foo(ptr undef, i32 [[V]])
56 ; CHECK-NEXT: ret i32 [[CA]]
58 %a.gep = getelementptr %T, ptr %p, i64 0, i32 3
59 %b.gep = getelementptr %T, ptr %p, i64 0, i32 2
60 %a = load i32, ptr %a.gep
61 %b = load i32, ptr %b.gep
63 %ca = musttail call i32 @foo(ptr undef, i32 %v)
67 define i32 @caller2(ptr %g) {
68 ; CHECK-LABEL: define {{[^@]+}}@caller2
69 ; CHECK-SAME: (ptr [[G:%.*]]) {
70 ; CHECK-NEXT: [[V:%.*]] = call i32 @test2(ptr [[G]], i32 0)
71 ; CHECK-NEXT: ret i32 [[V]]
73 %v = call i32 @test2(ptr %g, i32 0)