1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt -passes=globalopt -S < %s | FileCheck %s
4 define i32 @main(ptr %a) {
5 ; CHECK-LABEL: define {{[^@]+}}@main
6 ; CHECK-SAME: (ptr [[A:%.*]]) local_unnamed_addr {
7 ; CHECK-NEXT: [[ARGMEM:%.*]] = alloca inalloca <{ ptr, i32 }>, align 4
8 ; CHECK-NEXT: store ptr [[A]], ptr [[ARGMEM]], align 8
9 ; CHECK-NEXT: [[G0:%.*]] = getelementptr inbounds <{ ptr, i32 }>, ptr [[ARGMEM]], i32 0, i32 1
10 ; CHECK-NEXT: store i32 5, ptr [[G0]], align 4
11 ; CHECK-NEXT: [[CALL3:%.*]] = call i32 (ptr, ...) @i(ptr inalloca(ptr) [[ARGMEM]])
12 ; CHECK-NEXT: ret i32 [[CALL3]]
14 %argmem = alloca inalloca <{ ptr, i32 }>, align 4
15 store ptr %a, ptr %argmem, align 8
16 %g0 = getelementptr inbounds <{ ptr, i32 }>, ptr %argmem, i32 0, i32 1
17 store i32 5, ptr %g0, align 4
18 %call3 = call i32 (ptr, ...) @i(ptr inalloca(ptr) %argmem)
22 define internal i32 @i(ptr inalloca(ptr) %a, ...) {
23 ; CHECK-LABEL: define {{[^@]+}}@i
24 ; CHECK-SAME: (ptr inalloca(ptr) [[A:%.*]], ...) unnamed_addr {
25 ; CHECK-NEXT: [[AP:%.*]] = alloca ptr, align 4
26 ; CHECK-NEXT: call void @llvm.va_start(ptr [[AP]])
27 ; CHECK-NEXT: [[ARGP_CUR:%.*]] = load ptr, ptr [[AP]], align 4
28 ; CHECK-NEXT: [[L:%.*]] = load i32, ptr [[ARGP_CUR]], align 4
29 ; CHECK-NEXT: ret i32 [[L]]
31 %ap = alloca ptr, align 4
32 call void @llvm.va_start(ptr %ap)
33 %argp.cur = load ptr, ptr %ap, align 4
34 %l = load i32, ptr %argp.cur, align 4
38 declare void @llvm.va_start(ptr)