diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index b2b761d41779e..82a308f35c218 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -256,16 +256,6 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, // The parser verifies that there is a string literal here. assert(AsmString->isAscii()); - // Skip all the checks if we are compiling SYCL device code, but the function - // is not marked to be used on device, this code won't be codegen'ed anyway. - if (getLangOpts().SYCLIsDevice) { - SYCLDiagIfDeviceCode(AsmLoc, diag::err_sycl_restrict) << KernelUseAssembly; - return new (Context) - GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, - Names, Constraints, Exprs.data(), AsmString, NumClobbers, - Clobbers, NumLabels, RParenLoc); - } - FunctionDecl *FD = dyn_cast(getCurLexicalContext()); llvm::StringMap FeatureMap; Context.getFunctionFeatureMap(FeatureMap, FD); @@ -902,9 +892,6 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, SourceLocation EndLoc) { bool IsSimple = (NumOutputs != 0 || NumInputs != 0); setFunctionHasBranchProtectedScope(); - if (getLangOpts().SYCLIsDevice) - SYCLDiagIfDeviceCode(AsmLoc, diag::err_sycl_restrict) - << KernelUseAssembly; MSAsmStmt *NS = new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, IsSimple, /*IsVolatile*/ true, AsmToks, NumOutputs, NumInputs, diff --git a/clang/test/CodeGenSYCL/inline_asm.cpp b/clang/test/CodeGenSYCL/inline_asm.cpp new file mode 100644 index 0000000000000..db1956673a15a --- /dev/null +++ b/clang/test/CodeGenSYCL/inline_asm.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm -x c++ %s -o - | FileCheck %s + +class kernel; + +template +__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) { + // CHECK: %[[ARRAY_A:[0-9a-z]+]] = alloca [100 x i32], align 4 + // CHECK: %[[IDX:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[ARRAY_A]], i64 0, i64 0 + int a[100], i = 0; + // CHECK-NEXT: call void asm sideeffect + // CHECK: ".decl V52 v_type=G type=d num_elts=16 align=GRF + // CHECK: svm_gather.4.1 (M1, 16) $0.0 V52.0 + // CHECK: add(M1, 16) V52(0, 0)<1> V52(0, 0)<1; 1, 0> 0x1 + // CHECK: svm_scatter.4.1 (M1, 16) $0.0 V52.0", + // CHECK: "rw"(i32* nonnull %[[IDX]]) + asm volatile(".decl V52 v_type=G type=d num_elts=16 align=GRF\n" + "svm_gather.4.1 (M1, 16) %0.0 V52.0\n" + "add(M1, 16) V52(0, 0)<1> V52(0, 0)<1; 1, 0> 0x1\n" + "svm_scatter.4.1 (M1, 16) %0.0 V52.0" + : + : "rw"(&a[i])); +} + +int main() { + kernel_single_task([]() {}); + return 0; +} diff --git a/clang/test/SemaSYCL/inline-asm.cpp b/clang/test/SemaSYCL/inline-asm.cpp index 696a7ba3bb0e0..4c73eab54ea1a 100644 --- a/clang/test/SemaSYCL/inline-asm.cpp +++ b/clang/test/SemaSYCL/inline-asm.cpp @@ -1,6 +1,8 @@ // RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify %s -DLINUX_ASM // RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -verify -triple x86_64-windows -fasm-blocks %s +// expected-no-diagnostics + void foo() { int a; #ifdef LINUX_ASM @@ -13,26 +15,24 @@ void foo() { void bar() { int a; #ifdef LINUX_ASM - __asm__("int3"); // expected-error {{SYCL kernel cannot use inline assembly}} + __asm__("int3"); #else - __asm int 3 // expected-error {{SYCL kernel cannot use inline assembly}} + __asm int 3 #endif // LINUX_ASM } template __attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) { - // expected-note@+1 {{called by 'kernel_single_task([]() { bar(); }); return 0; }