Skip to content

Commit ea05310

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 1e8336c + bf5d9d5 commit ea05310

File tree

72 files changed

+2220
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2220
-537
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ llvm/ @intel/dpcpp-tools-reviewers
4848
clang/tools/clang-offload-*/ @intel/dpcpp-tools-reviewers
4949

5050
# Explicit SIMD
51-
SYCLLowerIR/ @intel/dpcpp-esimd-reviewers
51+
ESIMD/ @intel/dpcpp-esimd-reviewers
5252
esimd/ @intel/dpcpp-esimd-reviewers
5353
sycl/include/sycl/ext/intel/experimental/esimd.hpp @intel/dpcpp-esimd-reviewers
5454
sycl/doc/extensions/ExplicitSIMD/ @intel/dpcpp-esimd-reviewers

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ def err_drv_expecting_fsycl_with_sycl_opt : Error<
333333
"'%0' must be used in conjunction with '-fsycl' to enable offloading">;
334334
def err_drv_fsycl_with_c_type : Error<
335335
"'%0' must not be used in conjunction with '-fsycl', which expects C++ source">;
336+
def err_drv_fsycl_unsupported_with_opt
337+
: Error<"'%0' is not supported with '-fsycl'">;
336338
def err_drv_sycl_missing_amdgpu_arch : Error<
337339
"missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend --offload-arch'">;
338340
def warn_drv_sycl_offload_target_duplicate : Warning<

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11627,6 +11627,10 @@ def err_sycl_expected_finalize_method : Error<
1162711627
def ext_sycl_2020_attr_spelling : ExtWarn<
1162811628
"use of attribute %0 is a SYCL 2020 extension">,
1162911629
InGroup<Sycl2017Compat>;
11630+
def err_sycl_taking_address_of_wrong_function : Error<
11631+
"taking address of a function not marked with "
11632+
"'intel::device_indirectly_callable' attribute is not allowed in SYCL device "
11633+
"code">;
1163011634

1163111635
// errors of expect.with.probability
1163211636
def err_probability_not_constant_float : Error<

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include "llvm/Passes/PassBuilder.h"
4343
#include "llvm/Passes/PassPlugin.h"
4444
#include "llvm/Passes/StandardInstrumentations.h"
45-
#include "llvm/SYCLLowerIR/ESIMDVerifier.h"
45+
#include "llvm/SYCLLowerIR/ESIMD/ESIMDVerifier.h"
4646
#include "llvm/SYCLLowerIR/LowerWGLocalMemory.h"
4747
#include "llvm/SYCLLowerIR/MutatePrintfAddrspace.h"
4848
#include "llvm/Support/BuryPointer.h"

clang/lib/Driver/Driver.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -939,12 +939,18 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
939939
if (SYCLTargets && SYCLfpga)
940940
Diag(clang::diag::err_drv_option_conflict)
941941
<< SYCLTargets->getSpelling() << SYCLfpga->getSpelling();
942+
943+
auto argSYCLIncompatible = [&](OptSpecifier OptId) {
944+
if (!HasValidSYCLRuntime)
945+
return;
946+
if (Arg *IncompatArg = C.getInputArgs().getLastArg(OptId))
947+
Diag(clang::diag::err_drv_fsycl_unsupported_with_opt)
948+
<< IncompatArg->getSpelling();
949+
};
950+
// -static-libstdc++ is not compatible with -fsycl.
951+
argSYCLIncompatible(options::OPT_static_libstdcxx);
942952
// -ffreestanding cannot be used with -fsycl
943-
if (HasValidSYCLRuntime &&
944-
C.getInputArgs().hasArg(options::OPT_ffreestanding)) {
945-
Diag(clang::diag::err_drv_option_conflict) << "-fsycl"
946-
<< "-ffreestanding";
947-
}
953+
argSYCLIncompatible(options::OPT_ffreestanding);
948954

949955
// Diagnose incorrect inputs to SYCL options.
950956
// FIXME: Since the option definition includes the list of possible values,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9044,17 +9044,12 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
90449044
",+SPV_INTEL_long_constant_composite"
90459045
",+SPV_INTEL_fpga_invocation_pipelining_attributes"
90469046
",+SPV_INTEL_fpga_dsp_control"
9047-
",+SPV_INTEL_arithmetic_fence"
9048-
",+SPV_INTEL_runtime_aligned";
9047+
",+SPV_INTEL_arithmetic_fence";
90499048
ExtArg = ExtArg + DefaultExtArg + INTELExtArg;
90509049
if (!C.getDriver().isFPGAEmulationMode())
9051-
// Enable SPV_INTEL_usm_storage_classes only for FPGA hardware,
9052-
// since it adds new storage classes that represent global_device and
9053-
// global_host address spaces, which are not supported for all
9054-
// targets. With the extension disabled the storage classes will be
9055-
// lowered to CrossWorkgroup storage class that is mapped to just
9056-
// global address space.
9057-
ExtArg += ",+SPV_INTEL_usm_storage_classes";
9050+
// Enable several extensions on FPGA H/W exclusively
9051+
ExtArg += ",+SPV_INTEL_usm_storage_classes"
9052+
",+SPV_INTEL_runtime_aligned";
90589053
else
90599054
// Don't enable several freshly added extensions on FPGA H/W
90609055
ExtArg += ",+SPV_INTEL_token_type"

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -47,41 +47,6 @@ void SYCLInstallationDetector::print(llvm::raw_ostream &OS) const {
4747
}
4848
}
4949

50-
const char *SYCL::Linker::constructLLVMSpirvCommand(
51-
Compilation &C, const JobAction &JA, const InputInfo &Output,
52-
StringRef OutputFilePrefix, bool ToBc, const char *InputFileName) const {
53-
// Construct llvm-spirv command.
54-
// The output is a bc file or vice versa depending on the -r option usage
55-
// llvm-spirv -r -o a_kernel.bc a_kernel.spv
56-
// llvm-spirv -o a_kernel.spv a_kernel.bc
57-
ArgStringList CmdArgs;
58-
const char *OutputFileName = nullptr;
59-
if (ToBc) {
60-
std::string TmpName =
61-
C.getDriver().GetTemporaryPath(OutputFilePrefix.str() + "-spirv", "bc");
62-
OutputFileName = C.addTempFile(C.getArgs().MakeArgString(TmpName));
63-
CmdArgs.push_back("-r");
64-
CmdArgs.push_back("-o");
65-
CmdArgs.push_back(OutputFileName);
66-
} else {
67-
CmdArgs.push_back("-spirv-max-version=1.4");
68-
CmdArgs.push_back("-spirv-ext=+all");
69-
CmdArgs.push_back("-spirv-debug-info-version=ocl-100");
70-
CmdArgs.push_back("-spirv-allow-extra-diexpressions");
71-
CmdArgs.push_back("-spirv-allow-unknown-intrinsics=llvm.genx.");
72-
CmdArgs.push_back("-o");
73-
CmdArgs.push_back(Output.getFilename());
74-
}
75-
CmdArgs.push_back(InputFileName);
76-
77-
SmallString<128> LLVMSpirvPath(C.getDriver().Dir);
78-
llvm::sys::path::append(LLVMSpirvPath, "llvm-spirv");
79-
const char *LLVMSpirv = C.getArgs().MakeArgString(LLVMSpirvPath);
80-
C.addCommand(std::make_unique<Command>(
81-
JA, *this, ResponseFileSupport::AtFileUTF8(), LLVMSpirv, CmdArgs, None));
82-
return OutputFileName;
83-
}
84-
8550
static void addFPGATimingDiagnostic(std::unique_ptr<Command> &Cmd,
8651
Compilation &C) {
8752
const char *Msg = C.getArgs().MakeArgString(
@@ -343,22 +308,11 @@ void SYCL::Linker::ConstructJob(Compilation &C, const JobAction &JA,
343308
return;
344309
}
345310

346-
// We want to use llvm-spirv linker to link spirv binaries before putting
347-
// them into the fat object.
348-
// Each command outputs different files.
349311
InputInfoList SpirvInputs;
350312
for (const auto &II : Inputs) {
351313
if (!II.isFilename())
352314
continue;
353-
if (!Args.getLastArgValue(options::OPT_fsycl_device_obj_EQ)
354-
.equals_insensitive("spirv"))
355-
SpirvInputs.push_back(II);
356-
else {
357-
const char *LLVMSpirvOutputFile = constructLLVMSpirvCommand(
358-
C, JA, Output, Prefix, true, II.getFilename());
359-
SpirvInputs.push_back(InputInfo(types::TY_LLVM_BC, LLVMSpirvOutputFile,
360-
LLVMSpirvOutputFile));
361-
}
315+
SpirvInputs.push_back(II);
362316
}
363317

364318
constructLLVMLinkCommand(C, JA, Output, Args, SubArchName, Prefix,

clang/lib/Driver/ToolChains/SYCL.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
5454
const char *LinkingOutput) const override;
5555

5656
private:
57-
/// \return llvm-spirv output file name.
58-
const char *constructLLVMSpirvCommand(Compilation &C, const JobAction &JA,
59-
const InputInfo &Output,
60-
llvm::StringRef OutputFilePrefix,
61-
bool isBc, const char *InputFile) const;
6257
/// \return llvm-link output file name.
6358
const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
6459
const InputInfo &Output,

clang/lib/Sema/SemaOverload.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,11 +1807,28 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
18071807
// Function-to-pointer conversion (C++ 4.3).
18081808
SCS.First = ICK_Function_To_Pointer;
18091809

1810-
if (auto *DRE = dyn_cast<DeclRefExpr>(From->IgnoreParenCasts()))
1811-
if (auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1810+
if (auto *DRE = dyn_cast<DeclRefExpr>(From->IgnoreParenCasts())) {
1811+
if (auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
18121812
if (!S.checkAddressOfFunctionIsAvailable(FD))
18131813
return false;
18141814

1815+
// Some parts of clang are not designed for deferred diagnostics.
1816+
// One of the examples - initialization. When a new initialization is
1817+
// performed - it may end up here checking validity of a conversion.
1818+
// If false is returned from here, initialization sequence is marked as
1819+
// invalid, then checkAddressOfFunctionIsAvailable is called again
1820+
// to understand the reason of invaid initialization and in the end
1821+
// it is called with 'Complain' parameter to emit diagnostics.
1822+
// We cannot mark an initialization permanently invalid for SYCL device,
1823+
// because we may not know yet where the device code is.
1824+
// So, just call 'checkAddressOfFunctionIsAvailable' again but with
1825+
// 'Complain' parameter to issue a deferred diagnostic.
1826+
if (S.getLangOpts().SYCLIsDevice)
1827+
S.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true,
1828+
DRE->getExprLoc());
1829+
}
1830+
}
1831+
18151832
// An lvalue of function type T can be converted to an rvalue of
18161833
// type "pointer to T." The result is a pointer to the
18171834
// function. (C++ 4.3p1).
@@ -10241,6 +10258,15 @@ static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD,
1024110258
bool Complain,
1024210259
bool InOverloadResolution,
1024310260
SourceLocation Loc) {
10261+
if (Complain && S.getLangOpts().SYCLIsDevice &&
10262+
S.getLangOpts().SYCLAllowFuncPtr) {
10263+
if (!FD->hasAttr<SYCLDeviceIndirectlyCallableAttr>()) {
10264+
S.SYCLDiagIfDeviceCode(Loc,
10265+
diag::err_sycl_taking_address_of_wrong_function,
10266+
Sema::DeviceDiagnosticReason::Sycl);
10267+
}
10268+
}
10269+
1024410270
if (!isFunctionAlwaysEnabled(S.Context, FD)) {
1024510271
if (Complain) {
1024610272
if (InOverloadResolution)

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ static void checkSYCLType(Sema &S, QualType Ty, SourceRange Loc,
444444

445445
// zero length arrays
446446
if (isZeroSizedArray(Ty)) {
447-
S.SYCLDiagIfDeviceCode(Loc.getBegin(), diag::err_typecheck_zero_array_size);
447+
S.SYCLDiagIfDeviceCode(Loc.getBegin(), diag::err_typecheck_zero_array_size)
448+
<< 1;
448449
Emitting = true;
449450
}
450451

@@ -1274,7 +1275,6 @@ class KernelObjVisitor {
12741275
assert(CAT && "Should only be called on constant-size array.");
12751276
QualType ET = CAT->getElementType();
12761277
uint64_t ElemCount = CAT->getSize().getZExtValue();
1277-
assert(ElemCount > 0 && "SYCL prohibits 0 sized arrays");
12781278

12791279
(void)std::initializer_list<int>{
12801280
(Handlers.enterArray(Field, ArrayTy, ET), 0)...};
@@ -3072,10 +3072,6 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
30723072
CollectionInitExprs.pop_back();
30733073
ArrayInfos.pop_back();
30743074

3075-
assert(
3076-
!SemaRef.getASTContext().getAsConstantArrayType(ArrayType)->getSize() ==
3077-
0 &&
3078-
"Constant arrays must have at least 1 element");
30793075
// Remove the IndexExpr.
30803076
MemberExprBases.pop_back();
30813077

0 commit comments

Comments
 (0)