Mercurial > hg > CbC > CbC_llvm
comparison clang/test/CodeGenCUDA/device-stub.cu @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | 79ff65ed7e25 |
children | 1f2b6ac9f198 |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
1 // RUN: echo "GPU binary would be here" > %t | 1 // RUN: echo -n "GPU binary would be here." > %t |
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 2 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
3 // RUN: -target-sdk-version=8.0 -fcuda-include-gpubinary %t -o - \ | 3 // RUN: -target-sdk-version=8.0 -fcuda-include-gpubinary %t -o - \ |
4 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ | 4 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ |
5 // RUN: --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-OLD | 5 // RUN: --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-OLD |
6 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 6 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
7 // RUN: -target-sdk-version=8.0 -fcuda-include-gpubinary %t \ | 7 // RUN: -target-sdk-version=8.0 -fcuda-include-gpubinary %t \ |
8 // RUN: -o - -DNOGLOBALS \ | 8 // RUN: -o - -DNOGLOBALS \ |
9 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ | 9 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ |
10 // RUN: -check-prefixes=NOGLOBALS,CUDANOGLOBALS | 10 // RUN: -check-prefixes=NOGLOBALS,CUDANOGLOBALS |
11 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 11 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
12 // RUN: -target-sdk-version=8.0 -fgpu-rdc -fcuda-include-gpubinary %t \ | 12 // RUN: -target-sdk-version=8.0 -fgpu-rdc -fcuda-include-gpubinary %t \ |
13 // RUN: -o - \ | 13 // RUN: -o - \ |
14 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ | 14 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ |
15 // RUN: --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-OLD | 15 // RUN: --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-OLD |
16 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 16 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
17 // RUN: -target-sdk-version=8.0 -o - \ | 17 // RUN: -target-sdk-version=8.0 -o - \ |
18 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN | 18 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN |
19 | 19 |
20 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 20 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
21 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o - \ | 21 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o - \ |
22 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ | 22 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ |
23 // RUN: --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-NEW | 23 // RUN: --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-NEW |
24 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 24 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
25 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ | 25 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ |
26 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ | 26 // RUN: | FileCheck -allow-deprecated-dag-overlap %s \ |
27 // RUN: --check-prefixes=NOGLOBALS,CUDANOGLOBALS | 27 // RUN: --check-prefixes=NOGLOBALS,CUDANOGLOBALS |
28 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 28 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
29 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - \ | 29 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - \ |
30 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ | 30 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ |
31 // RUN: --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-NEW | 31 // RUN: --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-NEW |
32 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \ | 32 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \ |
33 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o - \ | 33 // RUN: -target-sdk-version=9.2 -fcuda-include-gpubinary %t -o - \ |
34 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ | 34 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ |
35 // RUN: --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-NEW,LNX_17,NORDC17 | 35 // RUN: --check-prefixes=ALL,LNX,NORDC,CUDA,CUDANORDC,CUDA-NEW,LNX_17,NORDC17 |
36 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \ | 36 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \ |
37 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - \ | 37 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - \ |
38 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ | 38 // RUN: | FileCheck %s -allow-deprecated-dag-overlap \ |
39 // RUN: --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-NEW,LNX_17,RDC17 | 39 // RUN: --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-NEW,LNX_17,RDC17 |
40 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 40 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
41 // RUN: -target-sdk-version=9.2 -o - \ | 41 // RUN: -target-sdk-version=9.2 -o - \ |
42 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN | 42 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN |
43 | 43 |
44 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 44 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
45 // RUN: -fcuda-include-gpubinary %t -o - -x hip\ | 45 // RUN: -fcuda-include-gpubinary %t -o - -x hip\ |
46 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,LNX,NORDC,HIP,HIPEF | 46 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,LNX,NORDC,HIP,HIPEF |
47 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 47 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
48 // RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS -x hip \ | 48 // RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS -x hip \ |
49 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=NOGLOBALS,HIPNOGLOBALS | 49 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=NOGLOBALS,HIPNOGLOBALS |
50 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ | 50 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s \ |
51 // RUN: -fgpu-rdc -fcuda-include-gpubinary %t -o - -x hip \ | 51 // RUN: -fgpu-rdc -fcuda-include-gpubinary %t -o - -x hip \ |
52 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,LNX,RDC,HIP,HIPEF | 52 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,LNX,RDC,HIP,HIPEF |
53 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - -x hip\ | 53 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s -o - -x hip\ |
54 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=ALL,LNX,NORDC,HIP,HIPNEF | 54 // RUN: | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=ALL,LNX,NORDC,HIP,HIPNEF |
55 | 55 |
56 // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -aux-triple amdgcn -emit-llvm %s \ | 56 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc -aux-triple amdgcn -emit-llvm %s \ |
57 // RUN: -fcuda-include-gpubinary %t -o - -x hip\ | 57 // RUN: -fcuda-include-gpubinary %t -o - -x hip\ |
58 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,WIN | 58 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,WIN |
59 | 59 |
60 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-pc-windows-msvc -aux-triple amdgcn -emit-llvm %s \ | |
61 // RUN: -o - -x hip\ | |
62 // RUN: | FileCheck -allow-deprecated-dag-overlap %s --check-prefixes=ALL,WIN,HIP,HIPNEF | |
63 | |
60 #include "Inputs/cuda.h" | 64 #include "Inputs/cuda.h" |
65 | |
66 // HIPNEF: $__hip_gpubin_handle = comdat any | |
61 | 67 |
62 #ifndef NOGLOBALS | 68 #ifndef NOGLOBALS |
63 // NORDC-DAG: @device_var = internal global i32 | 69 // NORDC-DAG: @device_var = internal global i32 |
64 // RDC-DAG: @device_var = global i32 | 70 // RDC-DAG: @device_var = global i32 |
65 // WIN-DAG: @"?device_var@@3HA" = internal global i32 | 71 // WIN-DAG: @"?device_var@@3HA" = internal global i32 |
151 // ALL: @1 = private unnamed_addr constant [11 x i8] c"device_var\00" | 157 // ALL: @1 = private unnamed_addr constant [11 x i8] c"device_var\00" |
152 // ALL: @2 = private unnamed_addr constant [13 x i8] c"constant_var\00" | 158 // ALL: @2 = private unnamed_addr constant [13 x i8] c"constant_var\00" |
153 // ALL: @3 = private unnamed_addr constant [19 x i8] c"ext_device_var_def\00" | 159 // ALL: @3 = private unnamed_addr constant [19 x i8] c"ext_device_var_def\00" |
154 // ALL: @4 = private unnamed_addr constant [21 x i8] c"ext_constant_var_def\00" | 160 // ALL: @4 = private unnamed_addr constant [21 x i8] c"ext_constant_var_def\00" |
155 // * constant unnamed string with GPU binary | 161 // * constant unnamed string with GPU binary |
156 // CUDA: @[[FATBIN:.*]] = private constant{{.*GPU binary would be here.*}}\00", | 162 // CUDA: @[[FATBIN:.*]] = private constant{{.*}} c"GPU binary would be here.", |
157 // HIPEF: @[[FATBIN:.*]] = private constant{{.*GPU binary would be here.*}}\00",{{.*}}align 4096 | 163 // HIPEF: @[[FATBIN:.*]] = private constant{{.*}} c"GPU binary would be here.",{{.*}}align 4096 |
158 // HIPNEF: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin" | 164 // HIPNEF: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin" |
159 // CUDANORDC-SAME: section ".nv_fatbin", align 8 | 165 // CUDANORDC-SAME: section ".nv_fatbin", align 8 |
160 // CUDARDC-SAME: section "__nv_relfatbin", align 8 | 166 // CUDARDC-SAME: section "__nv_relfatbin", align 8 |
161 // * constant struct that wraps GPU binary | 167 // * constant struct that wraps GPU binary |
162 // ALL: @__[[PREFIX:cuda|hip]]_fatbin_wrapper = internal constant | 168 // ALL: @__[[PREFIX:cuda|hip]]_fatbin_wrapper = internal constant |
249 // HIP: exit: | 255 // HIP: exit: |
250 // HIP-NEXT: load i8**, i8*** @__hip_gpubin_handle | 256 // HIP-NEXT: load i8**, i8*** @__hip_gpubin_handle |
251 // CUDANORDC-NEXT: call void @__[[PREFIX]]_register_globals | 257 // CUDANORDC-NEXT: call void @__[[PREFIX]]_register_globals |
252 // HIP-NEXT: call void @__[[PREFIX]]_register_globals | 258 // HIP-NEXT: call void @__[[PREFIX]]_register_globals |
253 // * In separate mode we also register a destructor. | 259 // * In separate mode we also register a destructor. |
254 // CUDANORDC-NEXT: call i32 @atexit(void (i8*)* @__[[PREFIX]]_module_dtor) | 260 // CUDANORDC-NEXT: call i32 @atexit(void ()* @__[[PREFIX]]_module_dtor) |
255 // HIP-NEXT: call i32 @atexit(void (i8*)* @__[[PREFIX]]_module_dtor) | 261 // HIP-NEXT: call i32 @atexit(void ()* @__[[PREFIX]]_module_dtor) |
256 | 262 |
257 // With relocatable device code we call __[[PREFIX]]RegisterLinkedBinary%NVModuleID% | 263 // With relocatable device code we call __[[PREFIX]]RegisterLinkedBinary%NVModuleID% |
258 // CUDARDC: call{{.*}}__[[PREFIX]]RegisterLinkedBinary[[MODULE_ID]]( | 264 // CUDARDC: call{{.*}}__[[PREFIX]]RegisterLinkedBinary[[MODULE_ID]]( |
259 // CUDARDC-SAME: __[[PREFIX]]_register_globals, {{.*}}__[[PREFIX]]_fatbin_wrapper | 265 // CUDARDC-SAME: __[[PREFIX]]_register_globals, {{.*}}__[[PREFIX]]_fatbin_wrapper |
260 // CUDARDC-SAME: [[MODULE_ID_GLOBAL]] | 266 // CUDARDC-SAME: [[MODULE_ID_GLOBAL]] |