Skip to content

Commit 70774e8

Browse files
committed
[SYCL] Disable dereferenceable attribute for SPIRV emitted from SYCL 1.2.1.
Signed-off-by: Vladimir Lazarev <[email protected]>
1 parent d35c08f commit 70774e8

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
#include "llvm/Transforms/Utils/SymbolRewriter.h"
6464
#include "LLVMSPIRVLib.h"
6565
#include <memory>
66+
67+
namespace SPIRV {
68+
extern llvm::cl::opt<bool> SPIRVNoDerefAttr;
69+
}
70+
6671
using namespace clang;
6772
using namespace llvm;
6873

@@ -835,7 +840,8 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
835840

836841

837842
case Backend_EmitSPIRV:
838-
843+
if (LangOpts.SYCL)
844+
SPIRV::SPIRVNoDerefAttr = true;
839845
PerModulePasses.add(createSPIRVWriterPass(*OS));
840846

841847
break;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang -cc1 -triple spir64-unknown-linux-sycldevice -std=c++11 -fsycl-is-device -S -emit-spirv -x c++ %s -o %t.spv
2+
// RUN: llvm-spirv %t.spv -to-text -o %t.txt
3+
// RUN: FileCheck < %t.txt %s --check-prefix=CHECK
4+
5+
template <typename name, typename Func>
6+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
7+
kernelFunc();
8+
}
9+
struct foo {
10+
static void bar(int &val) {
11+
val = 1;
12+
}
13+
};
14+
int main() {
15+
kernel_single_task<class fake_kernel>([]() { int var; foo::bar(var); });
16+
return 0;
17+
}
18+
19+
// CHECK: 3 Name [[os_ID:[0-9]+]] "val"
20+
// CHECK-NOT: Decorate {{[0-9]+}} MaxByteOffset

0 commit comments

Comments
 (0)