Skip to content

Commit

Permalink
[SYCL] Disable dereferenceable attribute for SPIRV emitted from SYCL …
Browse files Browse the repository at this point in the history
…1.2.1.

Signed-off-by: Vladimir Lazarev <vladimir.lazarev@intel.com>
  • Loading branch information
vladimirlaz committed Jan 22, 2019
1 parent d35c08f commit 70774e8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
#include "llvm/Transforms/Utils/SymbolRewriter.h"
#include "LLVMSPIRVLib.h"
#include <memory>

namespace SPIRV {
extern llvm::cl::opt<bool> SPIRVNoDerefAttr;
}

using namespace clang;
using namespace llvm;

Expand Down Expand Up @@ -835,7 +840,8 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,


case Backend_EmitSPIRV:

if (LangOpts.SYCL)
SPIRV::SPIRVNoDerefAttr = true;
PerModulePasses.add(createSPIRVWriterPass(*OS));

break;
Expand Down
20 changes: 20 additions & 0 deletions clang/test/CodeGenSYCL/spir-no-deref-attr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %clang -cc1 -triple spir64-unknown-linux-sycldevice -std=c++11 -fsycl-is-device -S -emit-spirv -x c++ %s -o %t.spv
// RUN: llvm-spirv %t.spv -to-text -o %t.txt
// RUN: FileCheck < %t.txt %s --check-prefix=CHECK

template <typename name, typename Func>
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
kernelFunc();
}
struct foo {
static void bar(int &val) {
val = 1;
}
};
int main() {
kernel_single_task<class fake_kernel>([]() { int var; foo::bar(var); });
return 0;
}

// CHECK: 3 Name [[os_ID:[0-9]+]] "val"
// CHECK-NOT: Decorate {{[0-9]+}} MaxByteOffset

0 comments on commit 70774e8

Please sign in to comment.