Skip to content

Commit 7b0a7db

Browse files
committed
Merge remote-tracking branch 'intel_llvm/sycl' into llvmspirv_pulldown
2 parents 761df2f + f821153 commit 7b0a7db

File tree

79 files changed

+1184
-4179
lines changed

Some content is hidden

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

79 files changed

+1184
-4179
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ There are 3 types of tests which are used for DPC++ toolchain validation:
6666
should not have hardware (e.g. GPU, FPGA, etc.) or external software
6767
dependencies (e.g. OpenCL, Level Zero, CUDA runtimes). All tests not following
6868
this approach should be moved to DPC++ end-to-end or SYCL-CTS tests.
69-
However, the tests for a feature under active development requiring atomic
70-
change for tests and product can be put to
71-
[sycl/test/on-device](../../sycl/test/on-device) temporarily. It is developer
72-
responsibility to move the tests to DPC++ E2E test suite or SYCL-CTS once
73-
the feature is stabilized.
7469

7570
**Guidelines for adding DPC++ in-tree LIT tests (DPC++ Clang FE tests)**:
7671
- Use `sycl::` namespace instead of `cl::sycl::`

buildbot/configure.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def do_configure(args):
6161
if args.rocm_platform == 'AMD':
6262
llvm_targets_to_build += ';AMDGPU'
6363
libclc_targets_to_build += ';amdgcn--;amdgcn--amdhsa'
64+
65+
# The ROCm plugin for AMD uses lld for linking
66+
llvm_enable_projects += ';lld'
6467
elif args.rocm_platform == 'NVIDIA' and not args.cuda:
6568
llvm_targets_to_build += ';NVPTX'
6669
libclc_targets_to_build += ';nvptx64--;nvptx64--nvidiacl'

clang/lib/Driver/Driver.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2932,6 +2932,18 @@ bool Driver::checkForSYCLDefaultDevice(Compilation &C,
29322932
if (Args.hasArg(options::OPT_fno_sycl_link_spirv))
29332933
return false;
29342934

2935+
// Do not do the check if the default device is passed in -fsycl-targets
2936+
// or if -fsycl-targets isn't passed (that implies default device)
2937+
if (const Arg *A = Args.getLastArg(options::OPT_fsycl_targets_EQ)) {
2938+
for (const char *Val : A->getValues()) {
2939+
llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val));
2940+
if (TT.isSPIR() && TT.getSubArch() == llvm::Triple::NoSubArch)
2941+
// Default triple found
2942+
return false;
2943+
}
2944+
} else if (!Args.hasArg(options::OPT_fintelfpga))
2945+
return false;
2946+
29352947
SmallVector<const char *, 16> AllArgs(getLinkerArgs(C, Args, true));
29362948
for (StringRef Arg : AllArgs) {
29372949
if (hasSYCLDefaultSection(C, Arg))
@@ -5492,6 +5504,16 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
54925504
break;
54935505
}
54945506

5507+
// When performing -fsycl based compilations and generating dependency
5508+
// information, perform a specific dependency generation compilation which
5509+
// is not based on the source + footer compilation.
5510+
if (Phase == phases::Preprocess && Args.hasArg(options::OPT_fsycl) &&
5511+
Args.hasArg(options::OPT_M_Group) &&
5512+
!Args.hasArg(options::OPT_fno_sycl_use_footer)) {
5513+
Actions.push_back(
5514+
C.MakeAction<PreprocessJobAction>(Current, types::TY_Dependencies));
5515+
}
5516+
54955517
// FIXME: Should we include any prior module file outputs as inputs of
54965518
// later actions in the same command line?
54975519

@@ -5856,6 +5878,9 @@ void Driver::BuildJobs(Compilation &C) const {
58565878
// we are also generating .o files. So we allow more than one output file in
58575879
// this case as well.
58585880
//
5881+
// Preprocessing job performed for -fsycl enabled compilation specifically
5882+
// for dependency generation (TY_Dependencies)
5883+
//
58595884
if (FinalOutput) {
58605885
unsigned NumOutputs = 0;
58615886
unsigned NumIfsOutputs = 0;
@@ -5866,7 +5891,10 @@ void Driver::BuildJobs(Compilation &C) const {
58665891
A->getKind() == clang::driver::Action::CompileJobClass &&
58675892
0 == NumIfsOutputs++) ||
58685893
(A->getKind() == Action::BindArchClass && A->getInputs().size() &&
5869-
A->getInputs().front()->getKind() == Action::IfsMergeJobClass)))
5894+
A->getInputs().front()->getKind() == Action::IfsMergeJobClass) ||
5895+
(A->getKind() == Action::PreprocessJobClass &&
5896+
A->getType() == types::TY_Dependencies &&
5897+
C.getArgs().hasArg(options::OPT_fsycl))))
58705898
++NumOutputs;
58715899

58725900
if (NumOutputs > 1) {

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,12 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
12031203
C.getDriver().addFPGATempDepFile(DepFile, BaseName);
12041204
};
12051205

1206+
// Do not add dependency generation information when compiling the source +
1207+
// footer combination. The dependency generation is done in a separate
1208+
// compile step so we can retain original source information.
1209+
if (ContainsAppendFooterAction(&JA))
1210+
ArgM = nullptr;
1211+
12061212
if (ArgM) {
12071213
// Determine the output location.
12081214
const char *DepFile;
@@ -1216,6 +1222,12 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
12161222
DepFile, Clang::getBaseInputName(Args, Inputs[0]));
12171223
} else if (Output.getType() == types::TY_Dependencies) {
12181224
DepFile = Output.getFilename();
1225+
if (!ContainsAppendFooterAction(&JA) && Args.hasArg(options::OPT_fsycl) &&
1226+
!Args.hasArg(options::OPT_fno_sycl_use_footer) &&
1227+
!JA.isDeviceOffloading(Action::OFK_SYCL))
1228+
// Name the dependency file for the specific dependency generation
1229+
// step created for the integration footer enabled compilation.
1230+
DepFile = getDependencyFileName(Args, Inputs);
12191231
} else if (!ArgMD) {
12201232
DepFile = "-";
12211233
} else if (IsIntelFPGA && JA.isDeviceOffloading(Action::OFK_SYCL)) {

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,35 @@
6767
// FOOTER_PATH: append-file{{.*}} "--append=dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"
6868
// FOOTER_PATH-SAME: "--output=dummy_dir{{(/|\\\\)}}[[APPENDEDSRC:.+\.cpp]]"
6969
// FOOTER_PATH: clang{{.*}} "-x" "c++" "dummy_dir{{(/|\\\\)}}[[APPENDEDSRC]]"
70+
71+
/// Check behaviors for dependency generation
72+
// RUN: %clangxx -fsycl -MD -c %s -### 2>&1 \
73+
// RUN: | FileCheck -check-prefix DEP_GEN %s
74+
// DEP_GEN: clang{{.*}} "-Eonly"
75+
// DEP_GEN-SAME: "-dependency-file"
76+
// DEP_GEN-SAME: "-MT"
77+
// DEP_GEN-SAME: "-x" "c++" "[[INPUTFILE:.+\.cpp]]"
78+
// DEP_GEN: append-file{{.*}} "[[INPUTFILE]]"
79+
// DEP_GEN-NOT: clang{{.*}} "-dependency-file"
80+
81+
/// Dependency generation phases
82+
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -MD -c %s -ccc-print-phases 2>&1 \
83+
// RUN: | FileCheck -check-prefix DEP_GEN_PHASES %s
84+
// DEP_GEN_PHASES: 0: input, "[[INPUTFILE:.+\.cpp]]", c++, (host-sycl)
85+
// DEP_GEN_PHASES: 1: preprocessor, {0}, dependencies
86+
// DEP_GEN_PHASES: 2: input, "[[INPUTFILE]]", c++, (device-sycl)
87+
// DEP_GEN_PHASES: 3: preprocessor, {2}, c++-cpp-output, (device-sycl)
88+
// DEP_GEN_PHASES: 4: compiler, {3}, ir, (device-sycl)
89+
// DEP_GEN_PHASES: 5: offload, "device-sycl (spir64-unknown-unknown-sycldevice)" {4}, ir
90+
// DEP_GEN_PHASES: 6: append-footer, {0}, c++, (host-sycl)
91+
// DEP_GEN_PHASES: 7: preprocessor, {6}, c++-cpp-output, (host-sycl)
92+
// DEP_GEN_PHASES: 8: offload, "host-sycl (x86_64-unknown-linux-gnu)" {7}, "device-sycl (spir64-unknown-unknown-sycldevice)" {4}, c++-cpp-output
93+
// DEP_GEN_PHASES: 9: compiler, {8}, ir, (host-sycl)
94+
// DEP_GEN_PHASES: 10: backend, {9}, assembler, (host-sycl)
95+
// DEP_GEN_PHASES: 11: assembler, {10}, object, (host-sycl)
96+
// DEP_GEN_PHASES: 12: clang-offload-bundler, {5, 11}, object, (host-sycl)
97+
98+
/// Allow for -o and preprocessing
99+
// RUN: %clangxx -fsycl -MD -c %s -o dummy -### 2>&1 \
100+
// RUN: | FileCheck -check-prefix DEP_GEN_OUT_ERROR %s
101+
// DEP_GEN_OUT_ERROR-NOT: cannot specify -o when generating multiple output files

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@
322322
/// -fintelfpga dependency file check with host .d enabled
323323
// RUN: %clangxx -### -MMD -fsycl -fintelfpga -Xshardware %t-1.cpp %t-2.cpp 2>&1 \
324324
// RUN: | FileCheck -check-prefix=CHK-FPGA-DEP-FILES-HOST %s
325-
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-dependency-file" "[[INPUT1:.+\.d]]" "-MT" "{{.*}}.o"
326-
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-dependency-file" "[[INPUT2:.+\.d]]" "-MT" "{{.*}}.o"
325+
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-triple" "spir64_fpga-unknown-unknown-sycldevice"{{.*}} "-dependency-file" "[[INPUT1:.+\.d]]" "-MT" "{{.*}}.o"
326+
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-triple" "spir64_fpga-unknown-unknown-sycldevice"{{.*}} "-dependency-file" "[[INPUT2:.+\.d]]" "-MT" "{{.*}}.o"
327327
// CHK-FPGA-DEP-FILES-HOST: aoc{{.*}} "-dep-files={{.*}}[[INPUT1]],{{.*}}[[INPUT2]]"
328-
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-fsycl-is-host"{{.*}} "-dependency-file"
329-
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-fsycl-is-host"{{.*}} "-dependency-file"
328+
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-fsycl-is-host"{{.*}}
329+
// CHK-FPGA-DEP-FILES-HOST: clang{{.*}} "-fsycl-is-host"{{.*}}
330330

331331
/// -fintelfpga dependency file generation test to object
332332
// RUN: %clangxx -### -fsycl -fintelfpga -target x86_64-unknown-linux-gnu %t-1.cpp %t-2.cpp -c 2>&1 \
@@ -348,7 +348,7 @@
348348
// RUN: | FileCheck -check-prefixes=CHK-FPGA-DEP-FILES3,CHK-FPGA-DEP-FILES3-LIN %s
349349
// RUN: %clang_cl -### --target=x86_64-pc-windows-msvc -fsycl -fintelfpga %t-1.cpp -c -Fodummy.obj 2>&1 \
350350
// RUN: | FileCheck -check-prefixes=CHK-FPGA-DEP-FILES3,CHK-FPGA-DEP-FILES3-WIN %s
351-
// CHK-FPGA-DEP-FILES3: clang{{.*}} "-dependency-file" "[[OUTPUT:.+\.d]]"
351+
// CHK-FPGA-DEP-FILES3: clang{{.*}} "-triple" "spir64_fpga-unknown-unknown-sycldevice"{{.*}} "-dependency-file" "[[OUTPUT:.+\.d]]"
352352
// CHK-FPGA-DEP-FILES3-LIN: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice,host-x86_64-unknown-linux-gnu,sycl-fpga_dep" {{.*}} "-inputs={{.*}}.bc,{{.*}}.o,[[OUTPUT]]"
353353
// CHK-FPGA-DEP-FILES3-WIN: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64_fpga-unknown-unknown-sycldevice,host-x86_64-pc-windows-msvc,sycl-fpga_dep" {{.*}} "-inputs={{.*}}.bc,{{.*}}.obj,[[OUTPUT]]"
354354

clang/test/Driver/sycl-offload.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,10 @@
9696
// RUN: | FileCheck -check-prefix NO_IMPLIED_DEVICE %s
9797
// NO_IMPLIED_DEVICE: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown-sycldevice"{{.*}} "-check-section"
9898
// NO_IMPLIED_DEVICE-NOT: clang-offload-bundler{{.*}} "-targets={{.*}}spir64-unknown-unknown-sycldevice{{.*}}" "-unbundle"
99+
100+
/// Passing in the default triple should allow for -Xsycl-target options
101+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64 -Xsycl-target-backend=spir64 -DFOO -Xsycl-target-linker=spir64 -DFOO2 %S/Inputs/SYCL/objlin64.o 2>&1 \
102+
// RUN: | FileCheck -check-prefixes=SYCL_TARGET_OPT %s
103+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -Xsycl-target-backend=spir64 -DFOO -Xsycl-target-linker=spir64 -DFOO2 %S/Inputs/SYCL/objlin64.o 2>&1 \
104+
// RUN: | FileCheck -check-prefixes=SYCL_TARGET_OPT %s
105+
// SYCL_TARGET_OPT: clang-offload-wrapper{{.*}} "-compile-opts=-DFOO" "-link-opts=-DFOO2"

0 commit comments

Comments
 (0)