[PATCH] D26777: [CUDA] Use the right section and constant names for fatbins when compiling for macos.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 16 17:00:33 PST 2016


jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D26777

Files:
  clang/lib/CodeGen/CGCUDANV.cpp


Index: clang/lib/CodeGen/CGCUDANV.cpp
===================================================================
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -289,19 +289,24 @@
       continue;
     }
 
+    const char *FatbinConstantName =
+        CGM.getTriple().isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin";
+    // NVIDIA's cuobjdump looks for fatbins in this section.
+    const char *FatbinSectionName =
+        CGM.getTriple().isMacOSX() ? "__NV_CUDA,__fatbin" : ".nvFatBinSegment";
+
     // Create initialized wrapper structure that points to the loaded GPU binary
     llvm::Constant *Values[] = {
         llvm::ConstantInt::get(IntTy, 0x466243b1), // Fatbin wrapper magic.
         llvm::ConstantInt::get(IntTy, 1),          // Fatbin version.
         makeConstantString(GpuBinaryOrErr.get()->getBuffer(), // Data.
-                           "", ".nv_fatbin", 8),              //
+                           "", FatbinConstantName, 8),
         llvm::ConstantPointerNull::get(VoidPtrTy)}; // Unused in fatbin v1.
     llvm::GlobalVariable *FatbinWrapper = new llvm::GlobalVariable(
         TheModule, FatbinWrapperTy, true, llvm::GlobalValue::InternalLinkage,
         llvm::ConstantStruct::get(FatbinWrapperTy, Values),
         "__cuda_fatbin_wrapper");
-    // NVIDIA's cuobjdump looks for fatbins in this section.
-    FatbinWrapper->setSection(".nvFatBinSegment");
+    FatbinWrapper->setSection(FatbinSectionName);
 
     // GpuBinaryHandle = __cudaRegisterFatBinary(&FatbinWrapper);
     llvm::CallInst *RegisterFatbinCall = CtorBuilder.CreateCall(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26777.78291.patch
Type: text/x-patch
Size: 1601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161117/f4ce7c3b/attachment-0001.bin>


More information about the cfe-commits mailing list