Skip to content

Commit adf36ea

Browse files
committed
[Clang] Do not build the OffloadActionBuilder when using the new driver
The Offloading toolchain currently has two methods for construction the requires actions. The "new" driver and the old `OffloadActionBuilder`. Using either one is mutually exclusive, so we should not initialize this when using the new driver. This was causing some error messages to be printed multiple times because we were checking them in both the old and the new driver. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D135715
1 parent ef25a21 commit adf36ea

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3952,14 +3952,17 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
39523952

39533953
handleArguments(C, Args, Inputs, Actions);
39543954

3955-
// Builder to be used to build offloading actions.
3956-
OffloadingActionBuilder OffloadBuilder(C, Args, Inputs);
3957-
39583955
bool UseNewOffloadingDriver =
39593956
C.isOffloadingHostKind(Action::OFK_OpenMP) ||
39603957
Args.hasFlag(options::OPT_offload_new_driver,
39613958
options::OPT_no_offload_new_driver, false);
39623959

3960+
// Builder to be used to build offloading actions.
3961+
std::unique_ptr<OffloadingActionBuilder> OffloadBuilder =
3962+
!UseNewOffloadingDriver
3963+
? std::make_unique<OffloadingActionBuilder>(C, Args, Inputs)
3964+
: nullptr;
3965+
39633966
// Construct the actions to perform.
39643967
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr;
39653968
ExtractAPIJobAction *ExtractAPIAction = nullptr;
@@ -3982,14 +3985,14 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
39823985
// Use the current host action in any of the offloading actions, if
39833986
// required.
39843987
if (!UseNewOffloadingDriver)
3985-
if (OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg))
3988+
if (OffloadBuilder->addHostDependenceToDeviceActions(Current, InputArg))
39863989
break;
39873990

39883991
for (phases::ID Phase : PL) {
39893992

39903993
// Add any offload action the host action depends on.
39913994
if (!UseNewOffloadingDriver)
3992-
Current = OffloadBuilder.addDeviceDependencesToHostAction(
3995+
Current = OffloadBuilder->addDeviceDependencesToHostAction(
39933996
Current, InputArg, Phase, PL.back(), FullPL);
39943997
if (!Current)
39953998
break;
@@ -4052,7 +4055,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
40524055
// Use the current host action in any of the offloading actions, if
40534056
// required.
40544057
if (!UseNewOffloadingDriver)
4055-
if (OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg))
4058+
if (OffloadBuilder->addHostDependenceToDeviceActions(Current, InputArg))
40564059
break;
40574060

40584061
// Try to build the offloading actions and add the result as a dependency
@@ -4070,7 +4073,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
40704073

40714074
// Add any top level actions generated for offloading.
40724075
if (!UseNewOffloadingDriver)
4073-
OffloadBuilder.appendTopLevelActions(Actions, Current, InputArg);
4076+
OffloadBuilder->appendTopLevelActions(Actions, Current, InputArg);
40744077
else if (Current)
40754078
Current->propagateHostOffloadInfo(C.getActiveOffloadKinds(),
40764079
/*BoundArch=*/nullptr);
@@ -4082,12 +4085,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
40824085
Arg *FinalPhaseArg;
40834086
if (getFinalPhase(Args, &FinalPhaseArg) == phases::Link)
40844087
if (!UseNewOffloadingDriver)
4085-
OffloadBuilder.appendDeviceLinkActions(Actions);
4088+
OffloadBuilder->appendDeviceLinkActions(Actions);
40864089
}
40874090

40884091
if (!LinkerInputs.empty()) {
40894092
if (!UseNewOffloadingDriver)
4090-
if (Action *Wrapper = OffloadBuilder.makeHostLinkAction())
4093+
if (Action *Wrapper = OffloadBuilder->makeHostLinkAction())
40914094
LinkerInputs.push_back(Wrapper);
40924095
Action *LA;
40934096
// Check if this Linker Job should emit a static library.
@@ -4102,7 +4105,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
41024105
LA = C.MakeAction<LinkJobAction>(LinkerInputs, types::TY_Image);
41034106
}
41044107
if (!UseNewOffloadingDriver)
4105-
LA = OffloadBuilder.processHostLinkAction(LA);
4108+
LA = OffloadBuilder->processHostLinkAction(LA);
41064109
Actions.push_back(LA);
41074110
}
41084111

0 commit comments

Comments
 (0)