Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CGDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ llvm::Constant *CodeGenModule::getOrCreateStaticVarDecl(
// OpenCL/SYCL variables in local address space and CUDA shared
// variables cannot have an initializer.
llvm::Constant *Init = nullptr;
if (Ty.getAddressSpace() == LangAS::opencl_local ||
Ty.getAddressSpace() == LangAS::sycl_local ||
if (AS == LangAS::opencl_local || AS == LangAS::sycl_local ||
D.hasAttr<CUDASharedAttr>() || D.hasAttr<LoaderUninitializedAttr>())
Init = llvm::UndefValue::get(LTy);
else
Expand Down
22 changes: 22 additions & 0 deletions clang/test/CodeGenSYCL/wg_init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s

// This test checks that a local variable initialized within a
// parallel_for_work_group scope is initialized as an UndefValue in addrspace(3)
// in LLVM IR.

#include "Inputs/sycl.hpp"

using namespace sycl;

int main() {
queue q;
q.submit([&](handler &h) {
h.parallel_for_work_group<class kernel>(
range<1>{1}, range<1>{1}, [=](group<1> G) {
int WG_VAR = 10;
});
});
return 0;
}

// CHECK: @{{.*}}WG_VAR = internal addrspace(3) global {{.*}} undef, {{.*}}