Skip to content

Commit 9612159

Browse files
authored
[Driver][SYCL] Cleanup redundant dependency steps (#13217)
To try and alleviate improper dependency information generated when -fsycl is enabled, an additionl dependency compilation step was created. This additional step, while creating the needed information causes issues when we use -save-temps. These issues being assosiated with bad dependencies for the integration header. Clean up these pathways to be more in line with a typical 'device' and 'host' only compilation, relying on the dependency information from the device side. Additional changes can be made when we can clean up the dependency generation from the host compilation step when we are building the temporary file. Removing the append file step would clear this up as well.
1 parent 6686560 commit 9612159

File tree

3 files changed

+16
-41
lines changed

3 files changed

+16
-41
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7392,19 +7392,6 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
73927392
break;
73937393
}
73947394

7395-
// When performing -fsycl based compilations and generating dependency
7396-
// information, perform a specific dependency generation compilation which
7397-
// is not based on the source + footer compilation.
7398-
if (Phase == phases::Preprocess && Args.hasArg(options::OPT_fsycl) &&
7399-
Args.hasArg(options::OPT_M_Group) &&
7400-
!Args.hasArg(options::OPT_fno_sycl_use_footer)) {
7401-
Action *PreprocessAction =
7402-
C.MakeAction<PreprocessJobAction>(Current, types::TY_Dependencies);
7403-
PreprocessAction->propagateHostOffloadInfo(Action::OFK_SYCL,
7404-
/*BoundArch=*/nullptr);
7405-
Actions.push_back(PreprocessAction);
7406-
}
7407-
74087395
if (Phase == phases::Precompile && ExtractAPIAction) {
74097396
ExtractAPIAction->addHeaderInput(Current);
74107397
Current = nullptr;
@@ -8161,9 +8148,6 @@ void Driver::BuildJobs(Compilation &C) const {
81618148
// we are also generating .o files. So we allow more than one output file in
81628149
// this case as well.
81638150
//
8164-
// Preprocessing job performed for -fsycl enabled compilation specifically
8165-
// for dependency generation (TY_Dependencies)
8166-
//
81678151
// OffloadClass of type TY_Nothing: device-only output will place many outputs
81688152
// into a single offloading action. We should count all inputs to the action
81698153
// as outputs. Also ignore device-only outputs if we're compiling with
@@ -8179,10 +8163,7 @@ void Driver::BuildJobs(Compilation &C) const {
81798163
A->getKind() == clang::driver::Action::CompileJobClass &&
81808164
0 == NumIfsOutputs++) ||
81818165
(A->getKind() == Action::BindArchClass && A->getInputs().size() &&
8182-
A->getInputs().front()->getKind() == Action::IfsMergeJobClass) ||
8183-
(A->getKind() == Action::PreprocessJobClass &&
8184-
A->getType() == types::TY_Dependencies &&
8185-
C.getArgs().hasArg(options::OPT_fsycl))))
8166+
A->getInputs().front()->getKind() == Action::IfsMergeJobClass)))
81868167
++NumOutputs;
81878168
else if (A->getKind() == Action::OffloadClass &&
81888169
A->getType() == types::TY_Nothing &&

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,8 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
10761076
// Do not add dependency generation information when compiling the source +
10771077
// footer combination. The dependency generation is done in a separate
10781078
// compile step so we can retain original source information.
1079+
// TODO: remove this when/if we can improve the host compilation situation
1080+
// when dealing with the temporary file generated for the footer.
10791081
if (ContainsAppendFooterAction(&JA))
10801082
ArgM = nullptr;
10811083

@@ -1092,12 +1094,6 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
10921094
DepFile, Clang::getBaseInputName(Args, Inputs[0]));
10931095
} else if (Output.getType() == types::TY_Dependencies) {
10941096
DepFile = Output.getFilename();
1095-
if (!ContainsAppendFooterAction(&JA) && Args.hasArg(options::OPT_fsycl) &&
1096-
!Args.hasArg(options::OPT_fno_sycl_use_footer) &&
1097-
!JA.isDeviceOffloading(Action::OFK_SYCL))
1098-
// Name the dependency file for the specific dependency generation
1099-
// step created for the integration footer enabled compilation.
1100-
DepFile = getDependencyFileName(Args, Inputs);
11011097
} else if (!ArgMD) {
11021098
DepFile = "-";
11031099
} else if (IsIntelFPGA && JA.isDeviceOffloading(Action::OFK_SYCL)) {

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
/// Check behaviors for dependency generation
7777
// RUN: %clangxx -fsycl -MD -c %s -### 2>&1 \
7878
// RUN: | FileCheck -check-prefix DEP_GEN %s
79-
// DEP_GEN: clang{{.*}} "-fsycl-is-host"
80-
// DEP_GEN-SAME: "-Eonly"
79+
// DEP_GEN: clang{{.*}} "-fsycl-is-device"
8180
// DEP_GEN-SAME: "-dependency-file"
8281
// DEP_GEN-SAME: "-MT"
8382
// DEP_GEN-SAME: "-internal-isystem" "{{.*}}{{[/\\]+}}include{{[/\\]+}}sycl"
@@ -88,19 +87,18 @@
8887
/// Dependency generation phases
8988
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -MD -c %s -ccc-print-phases 2>&1 \
9089
// RUN: | FileCheck -check-prefix DEP_GEN_PHASES %s
91-
// DEP_GEN_PHASES: 0: input, "[[INPUTFILE:.+\.cpp]]", c++, (host-sycl)
92-
// DEP_GEN_PHASES: 1: preprocessor, {0}, dependencies
93-
// DEP_GEN_PHASES: 2: input, "[[INPUTFILE]]", c++, (device-sycl)
94-
// DEP_GEN_PHASES: 3: preprocessor, {2}, c++-cpp-output, (device-sycl)
95-
// DEP_GEN_PHASES: 4: compiler, {3}, ir, (device-sycl)
96-
// DEP_GEN_PHASES: 5: offload, "device-sycl (spir64-unknown-unknown)" {4}, ir
97-
// DEP_GEN_PHASES: 6: append-footer, {0}, c++, (host-sycl)
98-
// DEP_GEN_PHASES: 7: preprocessor, {6}, c++-cpp-output, (host-sycl)
99-
// DEP_GEN_PHASES: 8: offload, "host-sycl (x86_64-unknown-linux-gnu)" {7}, "device-sycl (spir64-unknown-unknown)" {4}, c++-cpp-output
100-
// DEP_GEN_PHASES: 9: compiler, {8}, ir, (host-sycl)
101-
// DEP_GEN_PHASES: 10: backend, {9}, assembler, (host-sycl)
102-
// DEP_GEN_PHASES: 11: assembler, {10}, object, (host-sycl)
103-
// DEP_GEN_PHASES: 12: clang-offload-bundler, {5, 11}, object, (host-sycl)
90+
// DEP_GEN_PHASES: 0: input, "[[INPUTFILE:.+\.cpp]]", c++, (device-sycl)
91+
// DEP_GEN_PHASES: 1: preprocessor, {0}, c++-cpp-output, (device-sycl)
92+
// DEP_GEN_PHASES: 2: compiler, {1}, ir, (device-sycl)
93+
// DEP_GEN_PHASES: 3: offload, "device-sycl (spir64-unknown-unknown)" {2}, ir
94+
// DEP_GEN_PHASES: 4: input, "[[INPUTFILE]]", c++, (host-sycl)
95+
// DEP_GEN_PHASES: 5: append-footer, {4}, c++, (host-sycl)
96+
// DEP_GEN_PHASES: 6: preprocessor, {5}, c++-cpp-output, (host-sycl)
97+
// DEP_GEN_PHASES: 7: offload, "host-sycl (x86_64-unknown-linux-gnu)" {6}, "device-sycl (spir64-unknown-unknown)" {2}, c++-cpp-output
98+
// DEP_GEN_PHASES: 8: compiler, {7}, ir, (host-sycl)
99+
// DEP_GEN_PHASES: 9: backend, {8}, assembler, (host-sycl)
100+
// DEP_GEN_PHASES: 10: assembler, {9}, object, (host-sycl)
101+
// DEP_GEN_PHASES: 11: clang-offload-bundler, {3, 10}, object, (host-sycl)
104102

105103
/// Allow for -o and preprocessing
106104
// RUN: %clangxx -fsycl -MD -c %s -o dummy -### 2>&1 \

0 commit comments

Comments
 (0)