1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=always-inline %s | FileCheck %s
4 ; The byval parameters use a different address space from the alloca
5 ; address space. Make sure this is gracefully handled by using the
6 ; original byval pointer type's address space instead of what the
7 ; datalayout says to use.
9 target datalayout = "A5"
11 %struct = type { i64, i64 }
13 define i64 @bar(ptr byval(%struct) %a) alwaysinline {
14 ; CHECK-LABEL: define i64 @bar(
15 ; CHECK-SAME: ptr byval([[STRUCT:%.*]]) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
16 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr [[STRUCT]], ptr [[A]], i64 0, i32 1
17 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr [[TMP1]], align 4
18 ; CHECK-NEXT: ret i64 0
20 %1 = getelementptr %struct, ptr %a, i64 0, i32 1
21 %2 = load i64, ptr %1, align 4
25 define i64 @foo(ptr %arg) {
26 ; CHECK-LABEL: define i64 @foo(
27 ; CHECK-SAME: ptr [[ARG:%.*]]) {
28 ; CHECK-NEXT: [[ARG1:%.*]] = alloca [[STRUCT:%.*]], align 8
29 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 16, ptr [[ARG1]])
30 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 [[ARG1]], ptr align 1 [[ARG]], i64 16, i1 false)
31 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr [[STRUCT]], ptr [[ARG1]], i64 0, i32 1
32 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr [[TMP1]], align 4
33 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 16, ptr [[ARG1]])
34 ; CHECK-NEXT: ret i64 0
36 %1 = call i64 @bar(ptr byval(%struct) align 8 %arg)