|
| 1 | +;=========================== begin_copyright_notice ============================ |
| 2 | +; |
| 3 | +; Copyright (C) 2023 Intel Corporation |
| 4 | +; |
| 5 | +; SPDX-License-Identifier: MIT |
| 6 | +; |
| 7 | +;============================ end_copyright_notice ============================= |
| 8 | +; |
| 9 | +; RUN: igc_opt %s -S -o - --igc-legalize-function-signatures | FileCheck %s |
| 10 | + |
| 11 | +; ------------------------------------------------ |
| 12 | +; LegalizeFunctionSignatures |
| 13 | +; ------------------------------------------------ |
| 14 | + |
| 15 | +; The test checks if struct argument passed as generic pointer with byval attribute is correctly legalized |
| 16 | + |
| 17 | +%structtype = type { i32, i32 } |
| 18 | + |
| 19 | +define spir_kernel void @kernel() { |
| 20 | +; CHECK-LABEL: @kernel( |
| 21 | +; CHECK: [[AL:%.*]] = alloca %structtype |
| 22 | +; CHECK: [[TMP0:%.*]] = addrspacecast %structtype* [[AL]] to %structtype addrspace(4)* |
| 23 | +; CHECK: [[GEP0:%.*]] = getelementptr inbounds %structtype, %structtype addrspace(4)* [[TMP0]], i32 0, i32 0 |
| 24 | +; CHECK: [[L0:%.*]] = load i32, i32 addrspace(4)* [[GEP0]] |
| 25 | +; CHECK: [[I0:%.*]] = insertvalue %structtype undef, i32 [[L0]], 0 |
| 26 | +; CHECK: [[GEP1:%.*]] = getelementptr inbounds %structtype, %structtype addrspace(4)* [[TMP0]], i32 0, i32 1 |
| 27 | +; CHECK: [[L1:%.*]] = load i32, i32 addrspace(4)* [[GEP1]] |
| 28 | +; CHECK: [[I1:%.*]] = insertvalue %structtype [[I0]], i32 [[L1]], 1 |
| 29 | +; CHECK: call i32 @foo(%structtype [[I1]]) |
| 30 | +; CHECK: ret void |
| 31 | + |
| 32 | + %1 = alloca %structtype |
| 33 | + %2 = addrspacecast %structtype* %1 to %structtype addrspace(4)* |
| 34 | + call i32 @foo(%structtype addrspace(4)* byval(%structtype) %2) |
| 35 | + ret void |
| 36 | +} |
| 37 | + |
| 38 | +define spir_func i32 @foo(%structtype addrspace(4)* byval(%structtype) %src) #0 { |
| 39 | +; CHECK-LABEL: define spir_func i32 @foo(%structtype %src) |
| 40 | +; CHECK: [[AL:%.*]] = alloca %structtype |
| 41 | +; CHECK: [[GEP0:%.*]] = getelementptr inbounds %structtype, %structtype* [[AL]], i32 0, i32 0 |
| 42 | +; CHECK: [[E0:%.*]] = extractvalue %structtype %src, 0 |
| 43 | +; CHECK: store i32 [[E0]], i32* [[GEP0]] |
| 44 | +; CHECK: [[GEP1:%.*]] = getelementptr inbounds %structtype, %structtype* [[AL]], i32 0, i32 1 |
| 45 | +; CHECK: [[E1:%.*]] = extractvalue %structtype %src, 1 |
| 46 | +; CHECK: store i32 [[E1]], i32* [[GEP1]] |
| 47 | +; |
| 48 | +; CHECK: [[ASC:%.*]] = addrspacecast %structtype* [[AL]] to %structtype addrspace(4)* |
| 49 | +; CHECK: [[GEP2:%.*]] = getelementptr inbounds %structtype, %structtype addrspace(4)* [[ASC]], i64 0, i32 1 |
| 50 | +; CHECK: [[LOAD:%.*]] = load i32, i32 addrspace(4)* [[GEP2]] |
| 51 | +; CHECK: ret i32 [[LOAD]] |
| 52 | + %1 = getelementptr inbounds %structtype, %structtype addrspace(4)* %src, i64 0, i32 1 |
| 53 | + %2 = load i32, i32 addrspace(4)* %1 |
| 54 | + ret i32 %2 |
| 55 | +} |
| 56 | + |
| 57 | +attributes #0 = { "visaStackCall" } |
0 commit comments