Skip to content

Commit 9238f53

Browse files
committed
Merge branch 'sycl' of https://github.com/intel/llvm into ij2397
2 parents 037bc1d + 7e22445 commit 9238f53

File tree

18 files changed

+1047
-319
lines changed

18 files changed

+1047
-319
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,10 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
14181418
A->render(Args, CmdArgs);
14191419
}
14201420

1421+
Args.AddAllArgs(CmdArgs,
1422+
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
1423+
options::OPT_F, options::OPT_index_header_map});
1424+
14211425
// The file being compiled that contains the integration footer is not being
14221426
// compiled in the directory of the original source. Add that directory
14231427
// as an -internal-isystem option so we can properly find potential headers
@@ -1426,19 +1430,15 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
14261430
SmallString<128> SourcePath(Inputs[0].getBaseInput());
14271431
llvm::sys::path::remove_filename(SourcePath);
14281432
if (!SourcePath.empty()) {
1429-
CmdArgs.push_back("-internal-isystem");
1433+
CmdArgs.push_back("-I");
14301434
CmdArgs.push_back(Args.MakeArgString(SourcePath));
14311435
} else if (llvm::ErrorOr<std::string> CWD =
14321436
D.getVFS().getCurrentWorkingDirectory()) {
1433-
CmdArgs.push_back("-internal-isystem");
1437+
CmdArgs.push_back("-I");
14341438
CmdArgs.push_back(Args.MakeArgString(*CWD));
14351439
}
14361440
}
14371441

1438-
Args.AddAllArgs(CmdArgs,
1439-
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
1440-
options::OPT_F, options::OPT_index_header_map});
1441-
14421442
// Add -Wp, and -Xpreprocessor if using the preprocessor.
14431443

14441444
// FIXME: There is a very unfortunate problem here, some troubled
@@ -8711,7 +8711,8 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
87118711
",+SPV_INTEL_long_constant_composite"
87128712
",+SPV_INTEL_fpga_invocation_pipelining_attributes"
87138713
",+SPV_INTEL_fpga_dsp_control"
8714-
",+SPV_INTEL_arithmetic_fence";
8714+
",+SPV_INTEL_arithmetic_fence"
8715+
",+SPV_INTEL_runtime_aligned";
87158716
ExtArg = ExtArg + DefaultExtArg + INTELExtArg;
87168717
if (!C.getDriver().isFPGAEmulationMode())
87178718
// Enable SPV_INTEL_usm_storage_classes only for FPGA hardware,

clang/lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,14 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
225225
ExprEvalContexts.empty() ||
226226
(!isUnevaluatedContext() && !isConstantEvaluated());
227227
bool IsEsimdPrivateGlobal = isSYCLEsimdPrivateGlobal(VD);
228-
if (IsRuntimeEvaluated && !IsConst &&
228+
// Non-const statics are not allowed in SYCL except for ESIMD or with the
229+
// SYCLGlobalVar attribute.
230+
if (IsRuntimeEvaluated && !IsEsimdPrivateGlobal && !IsConst &&
229231
VD->getStorageClass() == SC_Static &&
230232
!VD->hasAttr<SYCLGlobalVarAttr>())
231233
SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_sycl_restrict)
232234
<< Sema::KernelNonConstStaticDataVariable;
233-
// Non-const globals are allowed for SYCL explicit SIMD or with the
235+
// Non-const globals are not allowed in SYCL except for ESIMD or with the
234236
// SYCLGlobalVar attribute.
235237
else if (IsRuntimeEvaluated && !IsEsimdPrivateGlobal && !IsConst &&
236238
VD->hasGlobalStorage() && !VD->hasAttr<SYCLGlobalVarAttr>())

clang/test/Driver/clang-offload-bundler-tgtsym.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
// CHECK-NOT: static_used
2222
// CHECK-NOT: sycl-spir64.llvm.used
2323
// CHECK-NOT: sycl-spir64.llvm.compiler.used
24+
// CHECK-NOT: sycl-spir64.const_as
25+
26+
const __attribute__((opencl_constant)) char const_as[] = "abc";
2427

2528
extern void undefined_func(void);
2629

clang/test/Driver/sycl-int-footer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/// Check compilation tool steps when using the integration footer
2-
// RUN: %clangxx -fsycl -include dummy.h %/s -### 2>&1 \
3-
// RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S
2+
// RUN: %clangxx -fsycl -I cmdline/dir -include dummy.h %/s -### 2>&1 \
3+
// RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S -DCMDDIR=cmdline/dir
44
// FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"{{.*}} "-include" "dummy.h"
55
// FOOTER: append-file{{.*}} "[[INPUTFILE:.+\.cpp]]" "--append=[[INTFOOTER]]" "--orig-filename=[[INPUTFILE]]" "--output=[[APPENDEDSRC:.+\.cpp]]"
6-
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-internal-isystem" "[[SRCDIR]]"
6+
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" "-I" "[[SRCDIR]]"
77
// FOOTER-NOT: "-include" "[[INTHEADER]]"
88

99
/// Preprocessed file creation with integration footer

clang/test/Driver/sycl-spirv-ext.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
// CHECK-DEFAULT-SAME:,+SPV_INTEL_fpga_invocation_pipelining_attributes
5050
// CHECK-DEFAULT-SAME:,+SPV_INTEL_fpga_dsp_control
5151
// CHECK-DEFAULT-SAME:,+SPV_INTEL_arithmetic_fence
52+
// CHECK-DEFAULT-SAME:,+SPV_INTEL_runtime_aligned
5253
// CHECK-DEFAULT-SAME:,+SPV_INTEL_token_type"
5354
// CHECK-FPGA-HW: llvm-spirv{{.*}}"-spirv-ext=-all
5455
// CHECK-FPGA-HW-SAME:,+SPV_EXT_shader_atomic_float_add
@@ -74,4 +75,5 @@
7475
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_fpga_invocation_pipelining_attributes
7576
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_fpga_dsp_control
7677
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_arithmetic_fence
78+
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_runtime_aligned
7779
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_usm_storage_classes"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -verify -pedantic %s
2+
// expected-no-diagnostics
3+
4+
// This test checks that non-const statics are allowed for ESIMD
5+
6+
static __attribute__((opencl_private)) __attribute__((sycl_explicit_simd)) int esimdPrivStatic;
7+
8+
struct S {
9+
static __attribute__((opencl_private)) __attribute__((sycl_explicit_simd)) int esimdPrivStaticMember;
10+
};
11+
12+
__attribute__((sycl_device)) __attribute__((sycl_explicit_simd)) void usage() {
13+
esimdPrivStatic = 42;
14+
S::esimdPrivStaticMember = 42;
15+
}

clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,22 @@ class ObjectFileHandler final : public FileHandler {
643643
return createStringError(inconvertibleErrorCode(),
644644
Err.getMessage());
645645

646+
bool UpdateBuf = false;
646647
if (!Mod->getModuleInlineAsm().empty()) {
647648
Mod->setModuleInlineAsm("");
648-
649+
UpdateBuf = true;
650+
}
651+
for (auto I = Mod->global_begin(), E = Mod->global_end(); I != E;) {
652+
GlobalVariable &GV = *I++;
653+
// Do not add globals with constant address space to the tgtsym.
654+
if (!GV.isDeclaration() && !GV.hasLocalLinkage() &&
655+
GV.getAddressSpace() == 2) {
656+
GV.dropAllReferences();
657+
GV.eraseFromParent();
658+
UpdateBuf = true;
659+
}
660+
}
661+
if (UpdateBuf) {
649662
SmallVector<char, 0> ModuleBuf;
650663
raw_svector_ostream ModuleOS(ModuleBuf);
651664
WriteBitcodeToFile(*Mod, ModuleOS);

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ static void LowerEsimdConstructs(Module &M) {
702702
MPM.add(createInstructionCombiningPass());
703703
MPM.add(createDeadCodeEliminationPass());
704704
}
705-
MPM.add(createGenXSPIRVWriterAdaptorPass());
705+
MPM.add(createGenXSPIRVWriterAdaptorPass(/*RewriteTypes=*/true));
706706
MPM.run(M);
707707
}
708708

sycl/doc/SharedLibraries.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,3 +603,8 @@ One more possible mitigation would be to record name of the library from which
603603
each symbol should be imported, but it still won't resolve all potential
604604
issues with run-time library loading, because user can load the library with the
605605
same name as one of the explicitly linked libraries.
606+
607+
## Related links
608+
609+
1. Test plan for this feature
610+
https://github.com/intel/llvm-test-suite/blob/intel/SYCL/TestPlans/DynamicLinkingTestPlan.md

sycl/include/sycl/ext/oneapi/functional.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,15 @@ struct GroupOpTag<T, detail::enable_if_t<detail::is_sgenfloat<T>::value>> {
9191
#define __SYCL_CALC_OVERLOAD(GroupTag, SPIRVOperation, BinaryOperation) \
9292
template <typename T, __spv::GroupOperation O, __spv::Scope::Flag S> \
9393
static T calc(GroupTag, T x, BinaryOperation) { \
94-
using OCLT = detail::ConvertToOpenCLType_t<T>; \
94+
using ConvertedT = detail::ConvertToOpenCLType_t<T>; \
95+
\
96+
using OCLT = \
97+
conditional_t<std::is_same<ConvertedT, cl_char>() || \
98+
std::is_same<ConvertedT, cl_short>(), \
99+
cl_int, \
100+
conditional_t<std::is_same<ConvertedT, cl_uchar>() || \
101+
std::is_same<ConvertedT, cl_ushort>(), \
102+
cl_uint, ConvertedT>>; \
95103
OCLT Arg = x; \
96104
OCLT Ret = \
97105
__spirv_Group##SPIRVOperation(S, static_cast<unsigned int>(O), Arg); \

0 commit comments

Comments
 (0)