Justin Lebar | e56360a | 2016-07-27 22:36:21 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \ |
| 2 | // RUN: FileCheck -check-prefix HOST -check-prefix CHECK %s |
| 3 | |
| 4 | // RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \ |
| 5 | // RUN: -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s |
| 6 | |
| 7 | #include "Inputs/cuda.h" |
| 8 | |
| 9 | struct U { |
| 10 | short x; |
| 11 | } __attribute__((packed)); |
| 12 | |
| 13 | struct S { |
| 14 | int *ptr; |
| 15 | char a; |
| 16 | U u; |
| 17 | }; |
| 18 | |
| 19 | // Clang should generate a packed LLVM struct for S (denoted by the <>s), |
| 20 | // otherwise this test isn't interesting. |
| 21 | // CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }> |
| 22 | |
| 23 | static_assert(alignof(S) == 8, "Unexpected alignment."); |
| 24 | |
| 25 | // HOST-LABEL: @_Z6kernelc1SPi |
| 26 | // Marshalled kernel args should be: |
| 27 | // 1. offset 0, width 1 |
| 28 | // 2. offset 8 (because alignof(S) == 8), width 16 |
| 29 | // 3. offset 24, width 8 |
| 30 | // HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 1, i64 0) |
| 31 | // HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 16, i64 8) |
| 32 | // HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24) |
| 33 | |
| 34 | // DEVICE-LABEL: @_Z6kernelc1SPi |
| 35 | // DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32* |
| 36 | __global__ void kernel(char a, S s, int *b) {} |