REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9270

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCUDA/filter-decl.cu

Index: cfe/trunk/test/CodeGenCUDA/filter-decl.cu
===================================================================
--- cfe/trunk/test/CodeGenCUDA/filter-decl.cu
+++ cfe/trunk/test/CodeGenCUDA/filter-decl.cu
@@ -3,6 +3,12 @@
 
 #include "Inputs/cuda.h"
 
+// This has to be at the top of the file as that's where file-scope
+// asm ends up.
+// CHECK-HOST: module asm "file scope asm is host only"
+// CHECK-DEVICE-NOT: module asm "file scope asm is host only"
+__asm__("file scope asm is host only");
+
 // CHECK-HOST-NOT: constantdata = global
 // CHECK-DEVICE: constantdata = global
 __constant__ char constantdata[256];
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -3356,6 +3356,9 @@
     break;
 
   case Decl::FileScopeAsm: {
+    // File-scope asm is ignored during device-side CUDA compilation.
+    if (LangOpts.CUDA && LangOpts.CUDAIsDevice)
+      break;
     auto *AD = cast<FileScopeAsmDecl>(D);
     getModule().appendModuleInlineAsm(AD->getAsmString()->getString());
     break;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: cfe/trunk/test/CodeGenCUDA/filter-decl.cu
===================================================================
--- cfe/trunk/test/CodeGenCUDA/filter-decl.cu
+++ cfe/trunk/test/CodeGenCUDA/filter-decl.cu
@@ -3,6 +3,12 @@
 
 #include "Inputs/cuda.h"
 
+// This has to be at the top of the file as that's where file-scope
+// asm ends up.
+// CHECK-HOST: module asm "file scope asm is host only"
+// CHECK-DEVICE-NOT: module asm "file scope asm is host only"
+__asm__("file scope asm is host only");
+
 // CHECK-HOST-NOT: constantdata = global
 // CHECK-DEVICE: constantdata = global
 __constant__ char constantdata[256];
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -3356,6 +3356,9 @@
     break;
 
   case Decl::FileScopeAsm: {
+    // File-scope asm is ignored during device-side CUDA compilation.
+    if (LangOpts.CUDA && LangOpts.CUDAIsDevice)
+      break;
     auto *AD = cast<FileScopeAsmDecl>(D);
     getModule().appendModuleInlineAsm(AD->getAsmString()->getString());
     break;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to