|
13 | 13 | // RUN: %s -o %t.ll |
14 | 14 | // RUN: FileCheck --check-prefix=LLVM-HOST --input-file=%t.ll %s |
15 | 15 |
|
| 16 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \ |
| 17 | +// RUN: -x cuda -emit-llvm -target-sdk-version=12.3 \ |
| 18 | +// RUN: -fcuda-include-gpubinary %t.fatbin \ |
| 19 | +// RUN: %s -o %t.ll |
| 20 | +// RUN: FileCheck --check-prefix=OGCG-HOST --input-file=%t.ll %s |
| 21 | + |
| 22 | + |
16 | 23 | // CIR-HOST: module @"{{.*}}" attributes { |
17 | 24 | // CIR-HOST: cir.cu.binary_handle = #cir.cu.binary_handle<{{.*}}.fatbin>, |
18 | 25 | // CIR-HOST: cir.global_ctors = [#cir.global_ctor<"__cuda_module_ctor", {{[0-9]+}}>] |
@@ -125,3 +132,51 @@ __device__ int a; |
125 | 132 | // LLVM-HOST: call void @__cudaRegisterFatBinaryEnd |
126 | 133 | // LLVM-HOST: call i32 @atexit(ptr @__cuda_module_dtor) |
127 | 134 | // LLVM-HOST: } |
| 135 | + |
| 136 | +// OGCG-HOST: @a = internal global i32 undef, align 4 |
| 137 | +// OGCG-HOST: @0 = private unnamed_addr constant [7 x i8] c"_Z2fnv\00", align 1 |
| 138 | +// OGCG-HOST: @1 = private unnamed_addr constant [2 x i8] c"a\00", align 1 |
| 139 | +// OGCG-HOST: @2 = private constant [14 x i8] c"sample fatbin\0A", section ".nv_fatbin", align 8 |
| 140 | +// OGCG-HOST: @__cuda_fatbin_wrapper = internal constant { i32, i32, ptr, ptr } { i32 1180844977, i32 1, ptr @2, ptr null }, section ".nvFatBinSegment", align 8 |
| 141 | +// OGCG-HOST: @__cuda_gpubin_handle = internal global ptr null, align 8 |
| 142 | +// OGCG-HOST: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__cuda_module_ctor, ptr null }] |
| 143 | + |
| 144 | +// OGCG-HOST: define internal void @__cuda_register_globals(ptr %[[#HANDLE:]]) { |
| 145 | +// OGCG-HOST: entry: |
| 146 | +// OGCG-HOST: %1 = call i32 @__cudaRegisterFunction(ptr %[[#HANDLE]], |
| 147 | +// OGCG-HOST-SAME: ptr @_Z17__device_stub__fnv, |
| 148 | +// OGCG-HOST-SAME: ptr @0, |
| 149 | +// OGCG-HOST-SAME: ptr @0, |
| 150 | +// OGCG-HOST-SAME: i32 -1, |
| 151 | +// OGCG-HOST-SAME: ptr null, |
| 152 | +// OGCG-HOST-SAME: ptr null, |
| 153 | +// OGCG-HOST-SAME: ptr null, |
| 154 | +// OGCG-HOST-SAME: ptr null, |
| 155 | +// OGCG-HOST-SAME: ptr null) |
| 156 | +// OGCG-HOST: call void @__cudaRegisterVar(ptr %[[#HANDLE]], |
| 157 | +// OGCG-HOST-SAME: ptr @a, |
| 158 | +// OGCG-HOST-SAME: ptr @1, |
| 159 | +// OGCG-HOST-SAME: ptr @1, |
| 160 | +// OGCG-HOST-SAME: i32 0, |
| 161 | +// OGCG-HOST-SAME: i64 4, |
| 162 | +// OGCG-HOST-SAME: i32 0, |
| 163 | +// OGCG-HOST-SAME: i32 0) |
| 164 | +// OGCG-HOST: ret void |
| 165 | +// OGCG-HOST: } |
| 166 | + |
| 167 | +// OGCG-HOST: define internal void @__cuda_module_ctor() { |
| 168 | +// OGCG-HOST: entry: |
| 169 | +// OGCG-HOST: %[[#WRAPADDR:]] = call ptr @__cudaRegisterFatBinary(ptr @__cuda_fatbin_wrapper) |
| 170 | +// OGCG-HOST: store ptr %[[#WRAPADDR]], ptr @__cuda_gpubin_handle, align 8 |
| 171 | +// OGCG-HOST: call void @__cuda_register_globals(ptr %[[#WRAPADDR]]) |
| 172 | +// OGCG-HOST: call void @__cudaRegisterFatBinaryEnd(ptr %[[#WRAPADDR]]) |
| 173 | +// OGCG-HOST: %1 = call i32 @atexit(ptr @__cuda_module_dtor) |
| 174 | +// OGCG-HOST: ret void |
| 175 | +// OGCG-HOST: } |
| 176 | + |
| 177 | +// OGCG-HOST: define internal void @__cuda_module_dtor() { |
| 178 | +// OGCG-HOST: entry: |
| 179 | +// OGCG-HOST: %[[#HANDLE:]] = load ptr, ptr @__cuda_gpubin_handle, align 8 |
| 180 | +// OGCG-HOST: call void @__cudaUnregisterFatBinary(ptr %[[#HANDLE]]) |
| 181 | +// OGCG-HOST: ret void |
| 182 | +// OGCG-HOST: } |
0 commit comments