Skip to content

Commit 2f4de56

Browse files
authored
[SYCL] Make sure that bound arch is set when using preprocessor (#4899)
With this patch the bound arch is correctly propagated through the phases: ``` +- 0: input, "./../tickets/dashE/woof.cpp", c++, (device-sycl, sm_50) +- 1: preprocessor, {0}, c++-cpp-output, (device-sycl, sm_50) +- 2: offload, "device-sycl (nvptx64-nvidia-cuda:sm_50)" {1}, c++-cpp-output | +- 3: input, "./../tickets/dashE/woof.cpp", c++, (host-sycl) | |- 4: compiler, {1}, none, (device-sycl, sm_50) | +- 5: offload, "host-sycl (x86_64-unknown-linux-gnu)" {3}, "device-sycl (nvptx64-nvidia-cuda:sm_50)" {4}, c++ | +- 6: append-footer, {5}, c++, (host-sycl) |- 7: preprocessor, {6}, c++-cpp-output, (host-sycl) 8: clang-offload-bundler, {2, 7}, c++-cpp-output, (host-sycl) ``` Previously the `compiler` phase (`4`) was lacking the bound arch, which is the root cause of #4758: ``` |- 4: compiler, {1}, none, (device-sycl) ``` Resolves: #4758 Previous discussion in: #4805
1 parent e877e3b commit 2f4de56

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,7 +4113,10 @@ class OffloadingActionBuilder final {
41134113
Args.getLastArg(options::OPT__SLASH_EP, options::OPT__SLASH_P) ||
41144114
Args.getLastArg(options::OPT_M, options::OPT_MM);
41154115
if (IsPreprocessOnly) {
4116-
for (Action *&A : SYCLDeviceActions) {
4116+
for (auto TargetActionInfo :
4117+
llvm::zip(SYCLDeviceActions, SYCLTargetInfoList)) {
4118+
Action *&A = std::get<0>(TargetActionInfo);
4119+
auto &TargetInfo = std::get<1>(TargetActionInfo);
41174120
A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A,
41184121
AssociatedOffloadKind);
41194122
if (SYCLDeviceOnly)
@@ -4122,7 +4125,7 @@ class OffloadingActionBuilder final {
41224125
// header.
41234126
Action *CompileAction =
41244127
C.MakeAction<CompileJobAction>(A, types::TY_Nothing);
4125-
DA.add(*CompileAction, *ToolChains.front(), nullptr,
4128+
DA.add(*CompileAction, *TargetInfo.TC, TargetInfo.BoundArch,
41264129
Action::OFK_SYCL);
41274130
}
41284131
return SYCLDeviceOnly ? ABRT_Ignore_Host : ABRT_Success;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ N.)
7272
// CHK-PHASES: 18: file-table-tform, {12, 17}, tempfiletable, (device-sycl, sm_35)
7373
// CHK-PHASES: 19: clang-offload-wrapper, {18}, object, (device-sycl, sm_35)
7474
// CHK-PHASES: 20: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (nvptx64-nvidia-cuda:sm_35)" {19}, image
75+
76+
/// Check calling preprocessor only
77+
// RUN: %clangxx -E -fsycl -fsycl-targets=nvptx64-nvidia-cuda -ccc-print-phases %s 2>&1 \
78+
// RUN: | FileCheck -check-prefix=CHK-PREPROC %s
79+
// CHK-PREPROC: 1: preprocessor, {0}, c++-cpp-output, (device-sycl, sm_[[CUDA_VERSION:[0-9.]+]])
80+
// CHK-PREPROC: 2: offload, "device-sycl (nvptx64-nvidia-cuda:sm_[[CUDA_VERSION]])" {1}, c++-cpp-output
81+
// CHK-PREPROC: 4: compiler, {1}, none, (device-sycl, sm_[[CUDA_VERSION]])

0 commit comments

Comments
 (0)