brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · f648d20 Raw
66 lines · plain
1; RUN: opt < %s -passes=argpromotion -S | FileCheck %s2 3; Unused pointer argument should be removed from the function's signature4; while the used arguments should be promoted if they are pointers.5; The pass should not touch any unused non-pointer arguments.6define internal i32 @callee(i1 %c, i1 %d, ptr %used, ptr %unused) nounwind {7; CHECK-LABEL: define {{[^@]+}}@callee8; CHECK-SAME: (i1 [[C:%.*]], i1 [[D:%.*]], i32 [[USED_VAL:%.*]]) #[[ATTR0:[0-9]+]] {9; CHECK-NEXT:  entry:10; CHECK-NEXT:    br i1 [[C]], label %if, label %else11; CHECK:       if:12; CHECK-NEXT:    ret i32 [[USED_VAL]]13; CHECK:       else:14; CHECK-NEXT:    ret i32 -115;16entry:17  %x = load i32, ptr %used, align 418  br i1 %c, label %if, label %else19 20if:21  ret i32 %x22 23else:24  ret i32 -125}26 27; Unused byval argument should be removed from the function's signature28; while the used arguments should be promoted if they are pointers.29; The pass should not touch any unused non-pointer arguments.30define 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_byval32; CHECK-SAME: (i1 [[C:%.*]], i1 [[D:%.*]], i32 [[USED_VAL:%.*]]) #[[ATTR0]] {33; CHECK-NEXT:  entry:34; CHECK-NEXT:    br i1 [[C]], label %if, label %else35; CHECK:       if:36; CHECK-NEXT:    ret i32 [[USED_VAL]]37; CHECK:       else:38; CHECK-NEXT:    ret i32 -139;40entry:41  %x = load i32, ptr %used, align 442  br i1 %c, label %if, label %else43 44if:45  ret i32 %x46 47else:48  ret i32 -149}50 51define i32 @caller(i1 %c, i1 %d, ptr %arg) nounwind {52; CHECK-LABEL: define {{[^@]+}}@caller53; CHECK-SAME: (i1 [[C:%.*]], i1 [[D:%.*]], ptr [[ARG:%.*]]) #[[ATTR0]] {54; CHECK-NEXT:  entry:55; CHECK-NEXT:    [[ARG_VAL_0:%.*]] = load i32, ptr [[ARG]], align 456; 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 458; CHECK-NEXT:    [[RES_1:%.*]] = call i32 @callee(i1 [[C]], i1 [[D]], i32 [[ARG_VAL_1]]) #[[ATTR0]]59; CHECK-NEXT:  ret i32 160;61entry:62  call i32 @callee_byval(i1 %c, i1 %d, ptr byval(i32) align 4 %arg, ptr byval(i32) align 4 %arg) nounwind63  call i32 @callee(i1 %c, i1 %d, ptr %arg, ptr %arg) nounwind64  ret i32 165}66