Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 1 | //===----- CGCUDANV.cpp - Interface to NVIDIA CUDA Runtime ----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This provides a class for CUDA code generation targeting the NVIDIA CUDA |
| 11 | // runtime library. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "CGCUDARuntime.h" |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 16 | #include "CodeGenFunction.h" |
| 17 | #include "CodeGenModule.h" |
| 18 | #include "clang/AST/Decl.h" |
Chandler Carruth | ffd5551 | 2013-01-02 11:45:17 +0000 | [diff] [blame] | 19 | #include "llvm/IR/BasicBlock.h" |
Chandler Carruth | c80ceea | 2014-03-04 11:02:08 +0000 | [diff] [blame] | 20 | #include "llvm/IR/CallSite.h" |
Chandler Carruth | ffd5551 | 2013-01-02 11:45:17 +0000 | [diff] [blame] | 21 | #include "llvm/IR/Constants.h" |
| 22 | #include "llvm/IR/DerivedTypes.h" |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 23 | |
| 24 | using namespace clang; |
| 25 | using namespace CodeGen; |
| 26 | |
| 27 | namespace { |
| 28 | |
| 29 | class CGNVCUDARuntime : public CGCUDARuntime { |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 30 | |
| 31 | private: |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 32 | llvm::Type *IntTy, *SizeTy, *VoidTy; |
| 33 | llvm::PointerType *CharPtrTy, *VoidPtrTy, *VoidPtrPtrTy; |
| 34 | |
| 35 | /// Convenience reference to LLVM Context |
| 36 | llvm::LLVMContext &Context; |
| 37 | /// Convenience reference to the current module |
| 38 | llvm::Module &TheModule; |
| 39 | /// Keeps track of kernel launch stubs emitted in this module |
| 40 | llvm::SmallVector<llvm::Function *, 16> EmittedKernels; |
| 41 | /// Keeps track of variables containing handles of GPU binaries. Populated by |
| 42 | /// ModuleCtorFunction() and used to create corresponding cleanup calls in |
| 43 | /// ModuleDtorFunction() |
| 44 | llvm::SmallVector<llvm::GlobalVariable *, 16> GpuBinaryHandles; |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 45 | |
| 46 | llvm::Constant *getSetupArgumentFn() const; |
| 47 | llvm::Constant *getLaunchFn() const; |
| 48 | |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 49 | /// Creates a function to register all kernel stubs generated in this module. |
| 50 | llvm::Function *makeRegisterKernelsFn(); |
| 51 | |
| 52 | /// Helper function that generates a constant string and returns a pointer to |
| 53 | /// the start of the string. The result of this function can be used anywhere |
| 54 | /// where the C code specifies const char*. |
| 55 | llvm::Constant *makeConstantString(const std::string &Str, |
| 56 | const std::string &Name = "", |
| 57 | unsigned Alignment = 0) { |
| 58 | llvm::Constant *Zeros[] = {llvm::ConstantInt::get(SizeTy, 0), |
| 59 | llvm::ConstantInt::get(SizeTy, 0)}; |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 60 | auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str()); |
| 61 | return llvm::ConstantExpr::getGetElementPtr(ConstStr.getElementType(), |
| 62 | ConstStr.getPointer(), Zeros); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | void emitDeviceStubBody(CodeGenFunction &CGF, FunctionArgList &Args); |
| 66 | |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 67 | public: |
| 68 | CGNVCUDARuntime(CodeGenModule &CGM); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 69 | |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 70 | void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) override; |
| 71 | /// Creates module constructor function |
| 72 | llvm::Function *makeModuleCtorFunction() override; |
| 73 | /// Creates module destructor function |
| 74 | llvm::Function *makeModuleDtorFunction() override; |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 77 | } |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 78 | |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 79 | CGNVCUDARuntime::CGNVCUDARuntime(CodeGenModule &CGM) |
| 80 | : CGCUDARuntime(CGM), Context(CGM.getLLVMContext()), |
| 81 | TheModule(CGM.getModule()) { |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 82 | CodeGen::CodeGenTypes &Types = CGM.getTypes(); |
| 83 | ASTContext &Ctx = CGM.getContext(); |
| 84 | |
| 85 | IntTy = Types.ConvertType(Ctx.IntTy); |
| 86 | SizeTy = Types.ConvertType(Ctx.getSizeType()); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 87 | VoidTy = llvm::Type::getVoidTy(Context); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 88 | |
| 89 | CharPtrTy = llvm::PointerType::getUnqual(Types.ConvertType(Ctx.CharTy)); |
| 90 | VoidPtrTy = cast<llvm::PointerType>(Types.ConvertType(Ctx.VoidPtrTy)); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 91 | VoidPtrPtrTy = VoidPtrTy->getPointerTo(); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | llvm::Constant *CGNVCUDARuntime::getSetupArgumentFn() const { |
| 95 | // cudaError_t cudaSetupArgument(void *, size_t, size_t) |
| 96 | std::vector<llvm::Type*> Params; |
| 97 | Params.push_back(VoidPtrTy); |
| 98 | Params.push_back(SizeTy); |
| 99 | Params.push_back(SizeTy); |
| 100 | return CGM.CreateRuntimeFunction(llvm::FunctionType::get(IntTy, |
| 101 | Params, false), |
| 102 | "cudaSetupArgument"); |
| 103 | } |
| 104 | |
| 105 | llvm::Constant *CGNVCUDARuntime::getLaunchFn() const { |
| 106 | // cudaError_t cudaLaunch(char *) |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 107 | return CGM.CreateRuntimeFunction( |
| 108 | llvm::FunctionType::get(IntTy, CharPtrTy, false), "cudaLaunch"); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 109 | } |
| 110 | |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 111 | void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF, |
| 112 | FunctionArgList &Args) { |
| 113 | EmittedKernels.push_back(CGF.CurFn); |
| 114 | emitDeviceStubBody(CGF, Args); |
| 115 | } |
| 116 | |
| 117 | void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction &CGF, |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 118 | FunctionArgList &Args) { |
| 119 | // Build the argument value list and the argument stack struct type. |
Dmitri Gribenko | f857950 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 120 | SmallVector<llvm::Value *, 16> ArgValues; |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 121 | std::vector<llvm::Type *> ArgTypes; |
| 122 | for (FunctionArgList::const_iterator I = Args.begin(), E = Args.end(); |
| 123 | I != E; ++I) { |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 124 | llvm::Value *V = CGF.GetAddrOfLocalVar(*I).getPointer(); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 125 | ArgValues.push_back(V); |
| 126 | assert(isa<llvm::PointerType>(V->getType()) && "Arg type not PointerType"); |
| 127 | ArgTypes.push_back(cast<llvm::PointerType>(V->getType())->getElementType()); |
| 128 | } |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 129 | llvm::StructType *ArgStackTy = llvm::StructType::get(Context, ArgTypes); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 130 | |
| 131 | llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end"); |
| 132 | |
| 133 | // Emit the calls to cudaSetupArgument |
| 134 | llvm::Constant *cudaSetupArgFn = getSetupArgumentFn(); |
| 135 | for (unsigned I = 0, E = Args.size(); I != E; ++I) { |
| 136 | llvm::Value *Args[3]; |
| 137 | llvm::BasicBlock *NextBlock = CGF.createBasicBlock("setup.next"); |
| 138 | Args[0] = CGF.Builder.CreatePointerCast(ArgValues[I], VoidPtrTy); |
| 139 | Args[1] = CGF.Builder.CreateIntCast( |
| 140 | llvm::ConstantExpr::getSizeOf(ArgTypes[I]), |
| 141 | SizeTy, false); |
| 142 | Args[2] = CGF.Builder.CreateIntCast( |
| 143 | llvm::ConstantExpr::getOffsetOf(ArgStackTy, I), |
| 144 | SizeTy, false); |
John McCall | 882987f | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 145 | llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 146 | llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0); |
| 147 | llvm::Value *CSZero = CGF.Builder.CreateICmpEQ(CS.getInstruction(), Zero); |
| 148 | CGF.Builder.CreateCondBr(CSZero, NextBlock, EndBlock); |
| 149 | CGF.EmitBlock(NextBlock); |
| 150 | } |
| 151 | |
| 152 | // Emit the call to cudaLaunch |
| 153 | llvm::Constant *cudaLaunchFn = getLaunchFn(); |
| 154 | llvm::Value *Arg = CGF.Builder.CreatePointerCast(CGF.CurFn, CharPtrTy); |
John McCall | 882987f | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 155 | CGF.EmitRuntimeCallOrInvoke(cudaLaunchFn, Arg); |
Peter Collingbourne | fa4d603 | 2011-10-06 18:51:56 +0000 | [diff] [blame] | 156 | CGF.EmitBranch(EndBlock); |
| 157 | |
| 158 | CGF.EmitBlock(EndBlock); |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 161 | /// Creates internal function to register all kernel stubs generated in this |
| 162 | /// module with the CUDA runtime. |
| 163 | /// \code |
| 164 | /// void __cuda_register_kernels(void** GpuBinaryHandle) { |
| 165 | /// __cudaRegisterFunction(GpuBinaryHandle,Kernel0,...); |
| 166 | /// ... |
| 167 | /// __cudaRegisterFunction(GpuBinaryHandle,KernelM,...); |
| 168 | /// } |
| 169 | /// \endcode |
| 170 | llvm::Function *CGNVCUDARuntime::makeRegisterKernelsFn() { |
| 171 | llvm::Function *RegisterKernelsFunc = llvm::Function::Create( |
| 172 | llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false), |
| 173 | llvm::GlobalValue::InternalLinkage, "__cuda_register_kernels", &TheModule); |
| 174 | llvm::BasicBlock *EntryBB = |
| 175 | llvm::BasicBlock::Create(Context, "entry", RegisterKernelsFunc); |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 176 | CGBuilderTy Builder(CGM, Context); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 177 | Builder.SetInsertPoint(EntryBB); |
| 178 | |
| 179 | // void __cudaRegisterFunction(void **, const char *, char *, const char *, |
| 180 | // int, uint3*, uint3*, dim3*, dim3*, int*) |
| 181 | std::vector<llvm::Type *> RegisterFuncParams = { |
| 182 | VoidPtrPtrTy, CharPtrTy, CharPtrTy, CharPtrTy, IntTy, |
| 183 | VoidPtrTy, VoidPtrTy, VoidPtrTy, VoidPtrTy, IntTy->getPointerTo()}; |
| 184 | llvm::Constant *RegisterFunc = CGM.CreateRuntimeFunction( |
| 185 | llvm::FunctionType::get(IntTy, RegisterFuncParams, false), |
| 186 | "__cudaRegisterFunction"); |
| 187 | |
| 188 | // Extract GpuBinaryHandle passed as the first argument passed to |
| 189 | // __cuda_register_kernels() and generate __cudaRegisterFunction() call for |
| 190 | // each emitted kernel. |
| 191 | llvm::Argument &GpuBinaryHandlePtr = *RegisterKernelsFunc->arg_begin(); |
| 192 | for (llvm::Function *Kernel : EmittedKernels) { |
| 193 | llvm::Constant *KernelName = makeConstantString(Kernel->getName()); |
| 194 | llvm::Constant *NullPtr = llvm::ConstantPointerNull::get(VoidPtrTy); |
| 195 | llvm::Value *args[] = { |
| 196 | &GpuBinaryHandlePtr, Builder.CreateBitCast(Kernel, VoidPtrTy), |
| 197 | KernelName, KernelName, llvm::ConstantInt::get(IntTy, -1), NullPtr, |
| 198 | NullPtr, NullPtr, NullPtr, |
| 199 | llvm::ConstantPointerNull::get(IntTy->getPointerTo())}; |
| 200 | Builder.CreateCall(RegisterFunc, args); |
| 201 | } |
| 202 | |
| 203 | Builder.CreateRetVoid(); |
| 204 | return RegisterKernelsFunc; |
| 205 | } |
| 206 | |
| 207 | /// Creates a global constructor function for the module: |
| 208 | /// \code |
| 209 | /// void __cuda_module_ctor(void*) { |
| 210 | /// Handle0 = __cudaRegisterFatBinary(GpuBinaryBlob0); |
| 211 | /// __cuda_register_kernels(Handle0); |
| 212 | /// ... |
| 213 | /// HandleN = __cudaRegisterFatBinary(GpuBinaryBlobN); |
| 214 | /// __cuda_register_kernels(HandleN); |
| 215 | /// } |
| 216 | /// \endcode |
| 217 | llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() { |
| 218 | // void __cuda_register_kernels(void* handle); |
| 219 | llvm::Function *RegisterKernelsFunc = makeRegisterKernelsFn(); |
| 220 | // void ** __cudaRegisterFatBinary(void *); |
| 221 | llvm::Constant *RegisterFatbinFunc = CGM.CreateRuntimeFunction( |
| 222 | llvm::FunctionType::get(VoidPtrPtrTy, VoidPtrTy, false), |
| 223 | "__cudaRegisterFatBinary"); |
| 224 | // struct { int magic, int version, void * gpu_binary, void * dont_care }; |
| 225 | llvm::StructType *FatbinWrapperTy = |
| 226 | llvm::StructType::get(IntTy, IntTy, VoidPtrTy, VoidPtrTy, nullptr); |
| 227 | |
| 228 | llvm::Function *ModuleCtorFunc = llvm::Function::Create( |
| 229 | llvm::FunctionType::get(VoidTy, VoidPtrTy, false), |
| 230 | llvm::GlobalValue::InternalLinkage, "__cuda_module_ctor", &TheModule); |
| 231 | llvm::BasicBlock *CtorEntryBB = |
| 232 | llvm::BasicBlock::Create(Context, "entry", ModuleCtorFunc); |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 233 | CGBuilderTy CtorBuilder(CGM, Context); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 234 | |
| 235 | CtorBuilder.SetInsertPoint(CtorEntryBB); |
| 236 | |
| 237 | // For each GPU binary, register it with the CUDA runtime and store returned |
| 238 | // handle in a global variable and save the handle in GpuBinaryHandles vector |
| 239 | // to be cleaned up in destructor on exit. Then associate all known kernels |
| 240 | // with the GPU binary handle so CUDA runtime can figure out what to call on |
| 241 | // the GPU side. |
| 242 | for (const std::string &GpuBinaryFileName : |
| 243 | CGM.getCodeGenOpts().CudaGpuBinaryFileNames) { |
| 244 | llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> GpuBinaryOrErr = |
| 245 | llvm::MemoryBuffer::getFileOrSTDIN(GpuBinaryFileName); |
| 246 | if (std::error_code EC = GpuBinaryOrErr.getError()) { |
| 247 | CGM.getDiags().Report(diag::err_cannot_open_file) << GpuBinaryFileName |
| 248 | << EC.message(); |
| 249 | continue; |
| 250 | } |
| 251 | |
| 252 | // Create initialized wrapper structure that points to the loaded GPU binary |
| 253 | llvm::Constant *Values[] = { |
| 254 | llvm::ConstantInt::get(IntTy, 0x466243b1), // Fatbin wrapper magic. |
| 255 | llvm::ConstantInt::get(IntTy, 1), // Fatbin version. |
| 256 | makeConstantString(GpuBinaryOrErr.get()->getBuffer(), "", 16), // Data. |
| 257 | llvm::ConstantPointerNull::get(VoidPtrTy)}; // Unused in fatbin v1. |
| 258 | llvm::GlobalVariable *FatbinWrapper = new llvm::GlobalVariable( |
| 259 | TheModule, FatbinWrapperTy, true, llvm::GlobalValue::InternalLinkage, |
| 260 | llvm::ConstantStruct::get(FatbinWrapperTy, Values), |
| 261 | "__cuda_fatbin_wrapper"); |
Justin Lebar | 21e5d4f | 2016-01-14 21:41:27 +0000 | [diff] [blame^] | 262 | // NVIDIA's cuobjdump looks for fatbins in this section. |
| 263 | FatbinWrapper->setSection(".nvFatBinSegment"); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 264 | |
| 265 | // GpuBinaryHandle = __cudaRegisterFatBinary(&FatbinWrapper); |
| 266 | llvm::CallInst *RegisterFatbinCall = CtorBuilder.CreateCall( |
| 267 | RegisterFatbinFunc, |
| 268 | CtorBuilder.CreateBitCast(FatbinWrapper, VoidPtrTy)); |
| 269 | llvm::GlobalVariable *GpuBinaryHandle = new llvm::GlobalVariable( |
| 270 | TheModule, VoidPtrPtrTy, false, llvm::GlobalValue::InternalLinkage, |
| 271 | llvm::ConstantPointerNull::get(VoidPtrPtrTy), "__cuda_gpubin_handle"); |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 272 | CtorBuilder.CreateAlignedStore(RegisterFatbinCall, GpuBinaryHandle, |
| 273 | CGM.getPointerAlign()); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 274 | |
| 275 | // Call __cuda_register_kernels(GpuBinaryHandle); |
| 276 | CtorBuilder.CreateCall(RegisterKernelsFunc, RegisterFatbinCall); |
| 277 | |
| 278 | // Save GpuBinaryHandle so we can unregister it in destructor. |
| 279 | GpuBinaryHandles.push_back(GpuBinaryHandle); |
| 280 | } |
| 281 | |
| 282 | CtorBuilder.CreateRetVoid(); |
| 283 | return ModuleCtorFunc; |
| 284 | } |
| 285 | |
| 286 | /// Creates a global destructor function that unregisters all GPU code blobs |
| 287 | /// registered by constructor. |
| 288 | /// \code |
| 289 | /// void __cuda_module_dtor(void*) { |
| 290 | /// __cudaUnregisterFatBinary(Handle0); |
| 291 | /// ... |
| 292 | /// __cudaUnregisterFatBinary(HandleN); |
| 293 | /// } |
| 294 | /// \endcode |
| 295 | llvm::Function *CGNVCUDARuntime::makeModuleDtorFunction() { |
| 296 | // void __cudaUnregisterFatBinary(void ** handle); |
| 297 | llvm::Constant *UnregisterFatbinFunc = CGM.CreateRuntimeFunction( |
| 298 | llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false), |
| 299 | "__cudaUnregisterFatBinary"); |
| 300 | |
| 301 | llvm::Function *ModuleDtorFunc = llvm::Function::Create( |
| 302 | llvm::FunctionType::get(VoidTy, VoidPtrTy, false), |
| 303 | llvm::GlobalValue::InternalLinkage, "__cuda_module_dtor", &TheModule); |
| 304 | llvm::BasicBlock *DtorEntryBB = |
| 305 | llvm::BasicBlock::Create(Context, "entry", ModuleDtorFunc); |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 306 | CGBuilderTy DtorBuilder(CGM, Context); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 307 | DtorBuilder.SetInsertPoint(DtorEntryBB); |
| 308 | |
| 309 | for (llvm::GlobalVariable *GpuBinaryHandle : GpuBinaryHandles) { |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 310 | auto HandleValue = |
| 311 | DtorBuilder.CreateAlignedLoad(GpuBinaryHandle, CGM.getPointerAlign()); |
| 312 | DtorBuilder.CreateCall(UnregisterFatbinFunc, HandleValue); |
Artem Belevich | 52cc487 | 2015-05-07 19:34:16 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | DtorBuilder.CreateRetVoid(); |
| 316 | return ModuleDtorFunc; |
| 317 | } |
| 318 | |
Peter Collingbourne | fe88342 | 2011-10-06 18:29:37 +0000 | [diff] [blame] | 319 | CGCUDARuntime *CodeGen::CreateNVCUDARuntime(CodeGenModule &CGM) { |
| 320 | return new CGNVCUDARuntime(CGM); |
| 321 | } |