[SYCL] Ignore file-scope asm during device-side SYCL compilation.
authorArtur Gainullin <artur.gainullin@intel.com>
Thu, 11 Feb 2021 20:54:59 +0000 (12:54 -0800)
committerArtur Gainullin <artur.gainullin@intel.com>
Sat, 13 Feb 2021 01:00:45 +0000 (17:00 -0800)
Reviewed By: bader, eandrews

Differential Revision: https://reviews.llvm.org/D96538

clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenSYCL/filescope_asm.c [new file with mode: 0644]

index 6321f74..4688f13 100644 (file)
@@ -5672,6 +5672,9 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     // File-scope asm is ignored during device-side OpenMP compilation.
     if (LangOpts.OpenMPIsDevice)
       break;
+    // File-scope asm is ignored during device-side SYCL compilation.
+    if (LangOpts.SYCLIsDevice)
+      break;
     auto *AD = cast<FileScopeAsmDecl>(D);
     getModule().appendModuleInlineAsm(AD->getAsmString()->getString());
     break;
diff --git a/clang/test/CodeGenSYCL/filescope_asm.c b/clang/test/CodeGenSYCL/filescope_asm.c
new file mode 100644 (file)
index 0000000..5f4f670
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN:  %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
+//
+// Check that file-scope asm is ignored during device-side SYCL compilation.
+//
+// CHECK-NOT: module asm "foo"
+__asm__("foo");