1 ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
3 ; Unused pointer argument should be removed from the function's signature
4 ; while the used arguments should be promoted if they are pointers.
5 ; The pass should not touch any unused non-pointer arguments.
6 define internal i32 @callee(i1 %c, i1 %d, ptr %used, ptr %unused) nounwind {
7 ; CHECK-LABEL: define {{[^@]+}}@callee
8 ; CHECK-SAME: (i1 [[C:%.*]], i1 [[D:%.*]], i32 [[USED_VAL:%.*]]) #[[ATTR0:[0-9]+]] {
10 ; CHECK-NEXT: br i1 [[C]], label %if, label %else
12 ; CHECK-NEXT: ret i32 [[USED_VAL]]
14 ; CHECK-NEXT: ret i32 -1
17 %x = load i32, ptr %used, align 4
18 br i1 %c, label %if, label %else
27 ; Unused byval argument should be removed from the function's signature
28 ; while the used arguments should be promoted if they are pointers.
29 ; The pass should not touch any unused non-pointer arguments.
30 define internal i32 @callee_byval(i1 %c, i1 %d, ptr byval(i32) align 4 %used, ptr byval(i32) align 4 %unused) nounwind {
31 ; CHECK-LABEL: define {{[^@]+}}@callee_byval
32 ; CHECK-SAME: (i1 [[C:%.*]], i1 [[D:%.*]], i32 [[USED_VAL:%.*]]) #[[ATTR0]] {
34 ; CHECK-NEXT: br i1 [[C]], label %if, label %else
36 ; CHECK-NEXT: ret i32 [[USED_VAL]]
38 ; CHECK-NEXT: ret i32 -1
41 %x = load i32, ptr %used, align 4
42 br i1 %c, label %if, label %else
51 define i32 @caller(i1 %c, i1 %d, ptr %arg) nounwind {
52 ; CHECK-LABEL: define {{[^@]+}}@caller
53 ; CHECK-SAME: (i1 [[C:%.*]], i1 [[D:%.*]], ptr [[ARG:%.*]]) #[[ATTR0]] {
55 ; CHECK-NEXT: [[ARG_VAL_0:%.*]] = load i32, ptr [[ARG]], align 4
56 ; CHECK-NEXT: [[RES_0:%.*]] = call i32 @callee_byval(i1 [[C]], i1 [[D]], i32 [[ARG_VAL_0]]) #[[ATTR0]]
57 ; CHECK-NEXT: [[ARG_VAL_1:%.*]] = load i32, ptr [[ARG]], align 4
58 ; CHECK-NEXT: [[RES_1:%.*]] = call i32 @callee(i1 [[C]], i1 [[D]], i32 [[ARG_VAL_1]]) #[[ATTR0]]
59 ; CHECK-NEXT: ret i32 1
62 call i32 @callee_byval(i1 %c, i1 %d, ptr byval(i32) align 4 %arg, ptr byval(i32) align 4 %arg) nounwind
63 call i32 @callee(i1 %c, i1 %d, ptr %arg, ptr %arg) nounwind