Skip to content

Commit 9622e3e

Browse files
committed
Merge branch 'sycl' into free-functions-struct-params
2 parents 2eb3d61 + 9cb370a commit 9622e3e

File tree

87 files changed

+1086
-185
lines changed

Some content is hidden

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

87 files changed

+1086
-185
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
27382738
ConstWithoutErrnoOrExceptions && ErrnoOverridenToFalseWithOpt;
27392739
}
27402740
if (GenerateIntrinsics &&
2741-
!(getLangOpts().SYCLIsDevice && getTarget().getTriple().isNVPTX())) {
2741+
!(getLangOpts().SYCLIsDevice && (getTarget().getTriple().isNVPTX() ||
2742+
getTarget().getTriple().isAMDGCN()))) {
27422743
switch (BuiltinIDIfNoAsmLabel) {
27432744
case Builtin::BIacos:
27442745
case Builtin::BIacosf:

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5555,7 +5555,7 @@ class OffloadingActionBuilder final {
55555555
// AOT compilation.
55565556
bool SYCLDeviceLibLinked = false;
55575557
Action *NativeCPULib = nullptr;
5558-
if (IsSPIR || IsNVPTX || IsSYCLNativeCPU) {
5558+
if (IsSPIR || IsNVPTX || IsAMDGCN || IsSYCLNativeCPU) {
55595559
bool UseJitLink =
55605560
IsSPIR &&
55615561
Args.hasFlag(options::OPT_fsycl_device_lib_jit_link,

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ static bool selectBfloatLibs(const llvm::Triple &Triple, const Compilation &C,
165165

166166
// spir64 target is actually JIT compilation, so we defer selection of
167167
// bfloat16 libraries to runtime. For AOT we need libraries, but skip
168-
// for Nvidia.
169-
NeedLibs =
170-
Triple.getSubArch() != llvm::Triple::NoSubArch && !Triple.isNVPTX();
168+
// for Nvidia and AMD.
169+
NeedLibs = Triple.getSubArch() != llvm::Triple::NoSubArch &&
170+
!Triple.isNVPTX() && !Triple.isAMDGCN();
171171
UseNative = false;
172172
if (NeedLibs && Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen &&
173173
C.hasOffloadToolChain<Action::OFK_SYCL>()) {
@@ -212,9 +212,9 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
212212
SmallVector<std::string, 8> LibraryList;
213213
const llvm::opt::ArgList &Args = C.getArgs();
214214

215-
// For NVPTX we only use one single bitcode library and ignore
215+
// For NVPTX and AMDGCN we only use one single bitcode library and ignore
216216
// manually specified SYCL device libraries.
217-
bool IgnoreSingleLibs = TargetTriple.isNVPTX();
217+
bool IgnoreSingleLibs = TargetTriple.isNVPTX() || TargetTriple.isAMDGCN();
218218

219219
struct DeviceLibOptInfo {
220220
StringRef DeviceLibName;
@@ -278,6 +278,9 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
278278
if (TargetTriple.isNVPTX() && IgnoreSingleLibs)
279279
LibraryList.push_back(Args.MakeArgString("devicelib--cuda.bc"));
280280

281+
if (TargetTriple.isAMDGCN() && IgnoreSingleLibs)
282+
LibraryList.push_back(Args.MakeArgString("devicelib--amd.bc"));
283+
281284
if (IgnoreSingleLibs)
282285
return LibraryList;
283286

@@ -1812,22 +1815,18 @@ void SYCLToolChain::AddSYCLIncludeArgs(const clang::driver::Driver &Driver,
18121815
const ArgList &DriverArgs,
18131816
ArgStringList &CC1Args) {
18141817
// Add the SYCL header search locations in the specified order.
1815-
// ../include/sycl
18161818
// ../include/sycl/stl_wrappers
18171819
// ../include
18181820
SmallString<128> IncludePath(Driver.Dir);
18191821
llvm::sys::path::append(IncludePath, "..");
18201822
llvm::sys::path::append(IncludePath, "include");
1821-
SmallString<128> SYCLPath(IncludePath);
1822-
llvm::sys::path::append(SYCLPath, "sycl");
18231823
// This is used to provide our wrappers around STL headers that provide
18241824
// additional functions/template specializations when the user includes those
18251825
// STL headers in their programs (e.g., <complex>).
1826-
SmallString<128> STLWrappersPath(SYCLPath);
1826+
SmallString<128> STLWrappersPath(IncludePath);
1827+
llvm::sys::path::append(STLWrappersPath, "sycl");
18271828
llvm::sys::path::append(STLWrappersPath, "stl_wrappers");
18281829
CC1Args.push_back("-internal-isystem");
1829-
CC1Args.push_back(DriverArgs.MakeArgString(SYCLPath));
1830-
CC1Args.push_back("-internal-isystem");
18311830
CC1Args.push_back(DriverArgs.MakeArgString(STLWrappersPath));
18321831
CC1Args.push_back("-internal-isystem");
18331832
CC1Args.push_back(DriverArgs.MakeArgString(IncludePath));

clang/test/CodeGenSYCL/sycl-libdevice-cmath.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-cuda -emit-llvm -o - | FileCheck %s
99
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-cuda -ffast-math -emit-llvm -o - | FileCheck %s
10+
// RUN: %clang_cc1 %s -fsycl-is-device -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
11+
// RUN: %clang_cc1 %s -fsycl-is-device -triple amdgcn-amd-amdhsa -ffast-math -emit-llvm -o - | FileCheck %s
1012

1113
#include "Inputs/sycl.hpp"
1214

clang/test/Driver/Inputs/SYCL/lib/devicelib--amd.bc

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Tests specific to `-fsycl-targets=amdgcn-amd-amdhsa`
2+
// Verify that the correct devicelib linking actions are spawned by the driver.
3+
// Check also if the correct warnings are generated.
4+
5+
// UNSUPPORTED: system-windows
6+
7+
// Check if internal libraries are still linked against when linkage of all
8+
// device libs is manually excluded.
9+
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl -fno-sycl-device-lib=all --sysroot=%S/Inputs/SYCL \
10+
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx906 %s 2>&1 \
11+
// RUN: | FileCheck -check-prefix=CHK-NO-DEVLIB %s
12+
13+
// CHK-NO-DEVLIB-NOT: {{[0-9]+}}: input, "{{.*}}devicelib--amd.bc", ir, (device-sycl, gfx906)
14+
// CHK-NO-DEVLIB: [[LIB1:[0-9]+]]: input, "{{.*}}libsycl-itt-user-wrappers.bc", ir, (device-sycl, gfx906)
15+
// CHK-NO-DEVLIB-NOT: {{[0-9]+}}: input, "{{.*}}devicelib--amd.bc", ir, (device-sycl, gfx906)
16+
// CHK-NO-DEVLIB: [[LIB2:[0-9]+]]: input, "{{.*}}libsycl-itt-compiler-wrappers.bc", ir, (device-sycl, gfx906)
17+
// CHK-NO-DEVLIB-NOT: {{[0-9]+}}: input, "{{.*}}devicelib--amd.bc", ir, (device-sycl, gfx906)
18+
// CHK-NO-DEVLIB: [[LIB3:[0-9]+]]: input, "{{.*}}libsycl-itt-stubs.bc", ir, (device-sycl, gfx906)
19+
// CHK-NO-DEVLIB-NOT: {{[0-9]+}}: input, "{{.*}}devicelib--amd.bc", ir, (device-sycl, gfx906)
20+
// CHK-NO-DEVLIB: {{[0-9]+}}: linker, {{{.*}}[[LIB1]], [[LIB2]], [[LIB3]]{{.*}}}, ir, (device-sycl, gfx906)
21+
22+
// Check that the -fsycl-device-lib flag has no effect when "all" is specified.
23+
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl -fsycl-device-lib=all --sysroot=%S/Inputs/SYCL \
24+
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx906 %s 2>&1 \
25+
// RUN: | FileCheck -check-prefix=CHK-ALL %s
26+
27+
// Check that the -fsycl-device-lib flag has no effect when subsets of libs
28+
// are specified.
29+
// RUN: %clangxx -ccc-print-phases -std=c++11 --sysroot=%S/Inputs/SYCL \
30+
// RUN: -fsycl -fsycl-device-lib=libc,libm-fp32,libm-fp64,libimf-fp32,libimf-fp64,libimf-bf16,libm-bfloat16 \
31+
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx906 %s 2>&1 \
32+
// RUN: | FileCheck -check-prefix=CHK-ALL %s
33+
34+
// Check that -fno-sycl-device-lib is ignored when it does not contain "all".
35+
// A warning should be printed that the flag got ignored.
36+
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl --sysroot=%S/Inputs/SYCL \
37+
// RUN: -fno-sycl-device-lib=libc,libm-fp32,libm-fp64,libimf-fp32,libimf-fp64,libimf-bf16,libm-bfloat16 \
38+
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx906 %s 2>&1 \
39+
// RUN: | FileCheck -check-prefixes=CHK-UNUSED-WARN,CHK-ALL %s
40+
41+
// CHK-UNUSED-WARN: warning: argument unused during compilation: '-fno-sycl-device-lib='
42+
// CHK-ALL: [[DEVLIB:[0-9]+]]: input, "{{.*}}devicelib--amd.bc", ir, (device-sycl, gfx906)
43+
// CHK-ALL: {{[0-9]+}}: linker, {{{.*}}[[DEVLIB]]{{.*}}}, ir, (device-sycl, gfx906)
44+

clang/test/Driver/sycl-device-old-model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/// Check "-fsycl-is-device" is passed when compiling for device:
77
// RUN: %clang -### -fsycl-device-only --no-offload-new-driver %s 2>&1 \
88
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
9-
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
9+
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{[^"]*}}bin{{[/\\]+}}..{{[/\\]+}}include"
1010

1111
/// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl"
1212
/// or "-fsycl-device-only" or both:

clang/test/Driver/sycl-device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
99
// RUN: %clang -### --config=%S/Inputs/empty.cfg -fsycl-device-only %s 2>&1 \
1010
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
11-
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
11+
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
1212

1313
/// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl"
1414
/// or "-fsycl-device-only" or both:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
// DEP_GEN: clang{{.*}} "-fsycl-is-device"
7979
// DEP_GEN-SAME: "-dependency-file" "[[DEPFILE:.+\.d]]"
8080
// DEP_GEN-SAME: "-MT"
81-
// DEP_GEN-SAME: "-internal-isystem" "{{.*}}{{[/\\]+}}include{{[/\\]+}}sycl"
81+
// DEP_GEN-SAME: "-internal-isystem" "{{.*}}{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"
8282
// DEP_GEN-SAME: "-x" "c++" "[[INPUTFILE:.+\.cpp]]"
8383
// DEP_GEN: clang{{.*}} "-fsycl-is-host"
8484
// DEP_GEN-SAME: "-dependency-file" "[[DEPFILE]]"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
// DEP_GEN: clang{{.*}} "-fsycl-is-device"
6767
// DEP_GEN-SAME: "-dependency-file" "[[DEPFILE:.+\.d]]"
6868
// DEP_GEN-SAME: "-MT"
69-
// DEP_GEN-SAME: "-internal-isystem" "{{.*}}{{[/\\]+}}include{{[/\\]+}}sycl"
69+
// DEP_GEN-SAME: "-internal-isystem" "{{.*}}{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"
7070
// DEP_GEN-SAME: "-x" "c++" "[[INPUTFILE:.+\.cpp]]"
7171
// DEP_GEN: clang{{.*}} "-fsycl-is-host"
7272
// DEP_GEN-SAME: "-dependency-file" "[[DEPFILE]]"

0 commit comments

Comments
 (0)