Skip to content

Commit cd04e86

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents e7aa612 + f229f60 commit cd04e86

File tree

153 files changed

+3666
-2219
lines changed

Some content is hidden

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

153 files changed

+3666
-2219
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,12 +3177,16 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
31773177
}
31783178
}
31793179

3180-
static bool runBundler(const SmallVectorImpl<StringRef> &BundlerArgs,
3180+
static bool runBundler(const SmallVectorImpl<StringRef> &InputArgs,
31813181
Compilation &C) {
31823182
// Find bundler.
31833183
StringRef ExecPath(C.getArgs().MakeArgString(C.getDriver().Dir));
31843184
llvm::ErrorOr<std::string> BundlerBinary =
31853185
llvm::sys::findProgramByName("clang-offload-bundler", ExecPath);
3186+
SmallVector<StringRef, 6> BundlerArgs;
3187+
BundlerArgs.push_back(BundlerBinary.getError() ? "clang-offload-bundler"
3188+
: BundlerBinary.get().c_str());
3189+
BundlerArgs.append(InputArgs);
31863190
// Since this is run in real time and not in the toolchain, output the
31873191
// command line if requested.
31883192
bool OutputOnly = C.getArgs().hasArg(options::OPT__HASH_HASH_HASH);
@@ -3223,8 +3227,8 @@ static bool hasFPGABinary(Compilation &C, std::string Object, types::ID Type) {
32233227
const char *Inputs = C.getArgs().MakeArgString(Twine("-input=") + Object);
32243228
// Always use -type=ao for aocx/aocr bundle checking. The 'bundles' are
32253229
// actually archives.
3226-
SmallVector<StringRef, 6> BundlerArgs = {"clang-offload-bundler", "-type=ao",
3227-
Targets, Inputs, "-check-section"};
3230+
SmallVector<StringRef, 6> BundlerArgs = {"-type=ao", Targets, Inputs,
3231+
"-check-section"};
32283232
return runBundler(BundlerArgs, C);
32293233
}
32303234

@@ -3309,8 +3313,7 @@ static bool hasSYCLDefaultSection(Compilation &C, const StringRef &File) {
33093313
const char *Targets =
33103314
C.getArgs().MakeArgString(Twine("-targets=sycl-") + TT.str());
33113315
const char *Inputs = C.getArgs().MakeArgString(Twine("-input=") + File.str());
3312-
SmallVector<StringRef, 6> BundlerArgs = {"clang-offload-bundler",
3313-
IsArchive ? "-type=ao" : "-type=o",
3316+
SmallVector<StringRef, 6> BundlerArgs = {IsArchive ? "-type=ao" : "-type=o",
33143317
Targets, Inputs, "-check-section"};
33153318
return runBundler(BundlerArgs, C);
33163319
}
@@ -3332,8 +3335,7 @@ static bool hasOffloadSections(Compilation &C, const StringRef &File,
33323335
// of the generic host availability.
33333336
const char *Targets = Args.MakeArgString(Twine("-targets=host-") + TT.str());
33343337
const char *Inputs = Args.MakeArgString(Twine("-input=") + File.str());
3335-
SmallVector<StringRef, 6> BundlerArgs = {"clang-offload-bundler",
3336-
IsArchive ? "-type=ao" : "-type=o",
3338+
SmallVector<StringRef, 6> BundlerArgs = {IsArchive ? "-type=ao" : "-type=o",
33373339
Targets, Inputs, "-check-section"};
33383340
return runBundler(BundlerArgs, C);
33393341
}
@@ -5259,9 +5261,9 @@ class OffloadingActionBuilder final {
52595261
// Select remangled libclc variant
52605262
std::string LibSpirvTargetName =
52615263
(TC->getAuxTriple()->isOSWindows())
5262-
? "remangled-l32-signed_char.libspirv-nvptx64--nvidiacl."
5264+
? "remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda."
52635265
"bc"
5264-
: "remangled-l64-signed_char.libspirv-nvptx64--nvidiacl."
5266+
: "remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda."
52655267
"bc";
52665268

52675269
for (StringRef LibraryPath : LibraryPaths) {
@@ -6781,14 +6783,16 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
67816783
/*BoundArch=*/nullptr);
67826784
}
67836785

6784-
OffloadBuilder->appendTopLevelLinkAction(Actions);
6786+
if (!UseNewOffloadingDriver) {
6787+
OffloadBuilder->appendTopLevelLinkAction(Actions);
67856788

6786-
// With static fat archives we need to create additional steps for
6787-
// generating dependence objects for device link actions.
6788-
if (!LinkerInputs.empty() && C.getDriver().getOffloadStaticLibSeen())
6789-
OffloadBuilder->addDeviceLinkDependenciesFromHost(LinkerInputs);
6789+
// With static fat archives we need to create additional steps for
6790+
// generating dependence objects for device link actions.
6791+
if (!LinkerInputs.empty() && C.getDriver().getOffloadStaticLibSeen())
6792+
OffloadBuilder->addDeviceLinkDependenciesFromHost(LinkerInputs);
67906793

6791-
OffloadBuilder->unbundleStaticArchives(C, Args, PL);
6794+
OffloadBuilder->unbundleStaticArchives(C, Args, PL);
6795+
}
67926796

67936797
// For an FPGA archive, we add the unbundling step above to take care of
67946798
// the device side, but also unbundle here to extract the host side

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,8 @@ std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
731731
// Windows
732732
static const char *getLibSpirvTargetName(const ToolChain &HostTC) {
733733
if (HostTC.getTriple().isOSWindows())
734-
return "remangled-l32-signed_char.libspirv-nvptx64--nvidiacl.bc";
735-
return "remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc";
734+
return "remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc";
735+
return "remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc";
736736
}
737737

738738
void CudaToolChain::addClangTargetOptions(

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
214214
}
215215

216216
static const char *getLibSpirvTargetName(const ToolChain &HostTC) {
217-
return "remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc";
217+
return "remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc";
218218
}
219219

220220
void HIPAMDToolChain::addClangTargetOptions(

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
172172
StringRef InputFilename = llvm::sys::path::filename(FileName);
173173
if (this->getToolChain().getTriple().isNVPTX()) {
174174
// Linking SYCL Device libs requires libclc as well as libdevice
175-
if ((InputFilename.find("nvidiacl") != InputFilename.npos ||
175+
if ((InputFilename.find("libspirv") != InputFilename.npos ||
176176
InputFilename.find("libdevice") != InputFilename.npos))
177177
return true;
178178
LibPostfix = ".cubin";
@@ -700,7 +700,8 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
700700

701701
// Diagnose unsupported options only once.
702702
// All sanitizer options are not currently supported.
703-
for (auto A : Args.filtered(options::OPT_fsanitize_EQ))
703+
for (auto A :
704+
Args.filtered(options::OPT_fsanitize_EQ, options::OPT_fcf_protection_EQ))
704705
D.getDiags().Report(clang::diag::warn_drv_unsupported_option_for_target)
705706
<< A->getAsString(Args) << getTriple().str();
706707
}
@@ -725,6 +726,7 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
725726
// compilation.
726727
switch ((options::ID)A->getOption().getID()) {
727728
case options::OPT_fsanitize_EQ:
729+
case options::OPT_fcf_protection_EQ:
728730
break;
729731
default:
730732
DAL->append(A);

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5085,6 +5085,10 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
50855085
PrintingPolicy Policy(LO);
50865086
Policy.SuppressTypedefs = true;
50875087
Policy.SuppressUnwrittenScope = true;
5088+
// Disable printing anonymous tag locations because on Windows
5089+
// file path separators are treated as escape sequences and cause errors
5090+
// when integration header is compiled with host compiler.
5091+
Policy.AnonymousTagLocations = 0;
50885092
SYCLFwdDeclEmitter FwdDeclEmitter(O, S.getLangOpts());
50895093

50905094
// Predefines which need to be set for custom host compilation

clang/lib/Sema/SemaType.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,9 +1527,13 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
15271527
break;
15281528
case DeclSpec::TST_half: Result = Context.HalfTy; break;
15291529
case DeclSpec::TST_BFloat16:
1530-
if (!S.Context.getTargetInfo().hasBFloat16Type())
1531-
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
1532-
<< "__bf16";
1530+
// Disable errors for SYCL and OpenMP device since definition of __bf16 is
1531+
// being moved to a shared header and it causes new errors emitted when
1532+
// host code is compiled with device compiler for SPIR target.
1533+
// FIXME: device code specific diagnostic is probably needed.
1534+
if (!S.Context.getTargetInfo().hasBFloat16Type() &&
1535+
!S.getLangOpts().SYCLIsDevice && !S.getLangOpts().OpenMPIsDevice)
1536+
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__bf16";
15331537
Result = Context.BFloat16Ty;
15341538
break;
15351539
case DeclSpec::TST_float: Result = Context.FloatTy; break;
@@ -2726,8 +2730,15 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
27262730
}
27272731

27282732
if (!TypeSize || VectorSizeBits % TypeSize) {
2729-
Diag(AttrLoc, diag::err_attribute_invalid_size)
2730-
<< SizeExpr->getSourceRange();
2733+
// Disable errors for SYCL and OpenMP device since definition of __bf16 is
2734+
// being moved to a shared header and it causes new errors emitted when
2735+
// host code is compiled with device compiler for SPIR target.
2736+
// FIXME: device code specific diagnostic is probably needed.
2737+
if (!(!TypeSize &&
2738+
(getLangOpts().OpenMPIsDevice || getLangOpts().SYCLIsDevice))) {
2739+
Diag(AttrLoc, diag::err_attribute_invalid_size)
2740+
<< SizeExpr->getSourceRange();
2741+
}
27312742
return QualType();
27322743
}
27332744

clang/test/CodeGenSYCL/code_location.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int test1() {
2222
// CHECK: }
2323
// CHECK: static constexpr const char* getFunctionName() {
2424
// CHECK: #ifndef NDEBUG
25-
// CHECK: return "";
25+
// CHECK: return "class (lambda)";
2626
// CHECK: #else
2727
// CHECK: return "";
2828
// CHECK: #endif
@@ -214,7 +214,7 @@ int test5() {
214214
// CHECK: }
215215
// CHECK: static constexpr const char* getFunctionName() {
216216
// CHECK: #ifndef NDEBUG
217-
// CHECK: return "NS::";
217+
// CHECK: return "NS::class (lambda)";
218218
// CHECK: #else
219219
// CHECK: return "";
220220
// CHECK: #endif
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-windows-msvc %s 2> %t.win.out
22
// RUN: FileCheck %s --check-prefixes=CHECK-WINDOWS --input-file %t.win.out
3-
// CHECK-WINDOWS: remangled-l32-signed_char.libspirv-nvptx64--nvidiacl.bc
3+
// CHECK-WINDOWS: remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc
44
//
55
// RUN: %clang -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -nocudalib -target x86_64-unknown-linux-gnu %s 2> %t.lnx.out
66
// RUN: FileCheck %s --check-prefixes=CHECK-LINUX --input-file %t.lnx.out
7-
// CHECK-LINUX: remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc
7+
// CHECK-LINUX: remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc

clang/test/Driver/sycl-libspirv-invalid.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
// RUN: -fsycl-targets=nvptx64-nvidia-cuda --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
66
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/no-libspirv-exists-here.bc %s 2>&1 \
77
// RUN: | FileCheck --check-prefix=ERR-CUDA %s
8-
// ERR-CUDA: cannot find 'remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc';
8+
// ERR-CUDA: cannot find 'remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc';
99
// ERR-CUDA-SAME: provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv
1010

1111
// RUN: %clangxx -### -std=c++11 -target x86_64-unknown-windows-msvc -fsycl \
1212
// RUN: -fsycl-targets=nvptx64-nvidia-cuda --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
1313
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/no-libspirv-exists-here.bc %s 2>&1 \
1414
// RUN: | FileCheck --check-prefix=ERR-CUDA-WIN %s
15-
// ERR-CUDA-WIN: cannot find 'remangled-l32-signed_char.libspirv-nvptx64--nvidiacl.bc';
15+
// ERR-CUDA-WIN: cannot find 'remangled-l32-signed_char.libspirv-nvptx64-nvidia-cuda.bc';
1616
// ERR-CUDA-WIN-SAME: provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv
1717

1818
// RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \
1919
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 \
2020
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/no-libspirv-exists-here.bc %s 2>&1 \
2121
// RUN: | FileCheck --check-prefix=ERR-HIP %s
22-
// ERR-HIP: cannot find 'remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc';
22+
// ERR-HIP: cannot find 'remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc';
2323
// ERR-HIP-SAME: provide path to libspirv library via '-fsycl-libspirv-path', or pass '-fno-sycl-libspirv' to build without linking with libspirv
2424

2525
// RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \
2626
// RUN: -fsycl-targets=nvptx64-nvidia-cuda --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
2727
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/no-libspirv-exists-here.bc -fno-sycl-libspirv %s 2>&1 \
2828
// RUN: | FileCheck --check-prefix=OK-CUDA %s
29-
// OK-CUDA-NOT: cannot find suitable 'remangled-l64-signed_char.libspirv-nvptx64--nvidiacl.bc'
29+
// OK-CUDA-NOT: cannot find suitable 'remangled-l64-signed_char.libspirv-nvptx64-nvidia-cuda.bc'
3030

3131
// RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \
3232
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx908 \
3333
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/no-libspirv-exists-here.bc -fno-sycl-libspirv %s 2>&1 \
3434
// RUN: | FileCheck --check-prefix=OK-HIP %s
35-
// OK-HIP-NOT: cannot find 'remangled-l64-signed_char.libspirv-amdgcn--amdhsa.bc'
35+
// OK-HIP-NOT: cannot find 'remangled-l64-signed_char.libspirv-amdgcn-amd-amdhsa.bc'

clang/test/Driver/sycl-offload.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@
147147
// RUN: | FileCheck -check-prefix CHECK_SECTION %s
148148
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu %S/Inputs/SYCL/liblin64.a %s 2>&1 \
149149
// RUN: | FileCheck -check-prefix NO_CHECK_SECTION %s
150-
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=host-x86_64-unknown-linux-gnu"{{.*}} "-check-section"
151-
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr-intel-unknown"{{.*}} "-check-section"
152-
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocx-intel-unknown"{{.*}} "-check-section"
153-
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr_emu-intel-unknown"{{.*}} "-check-section"
150+
// CHECK_SECTION: {{(/|\\)}}clang-offload-bundler{{.*}} "-type=ao" "-targets=host-x86_64-unknown-linux-gnu"{{.*}} "-check-section"
151+
// CHECK_SECTION: {{(/|\\)}}clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr-intel-unknown"{{.*}} "-check-section"
152+
// CHECK_SECTION: {{(/|\\)}}clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocx-intel-unknown"{{.*}} "-check-section"
153+
// CHECK_SECTION: {{(/|\\)}}clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr_emu-intel-unknown"{{.*}} "-check-section"
154154
// NO_CHECK_SECTION-NOT: clang-offload-bundler{{.*}} "-type=ao" "-targets=host-x86_64-unknown-linux-gnu"{{.*}} "-check-section"
155155
// NO_CHECK_SECTION-NOT: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr-intel-unknown"{{.*}} "-check-section"
156156
// NO_CHECK_SECTION-NOT: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocx-intel-unknown"{{.*}} "-check-section"

0 commit comments

Comments
 (0)