@@ -3952,14 +3952,17 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
3952
3952
3953
3953
handleArguments (C, Args, Inputs, Actions);
3954
3954
3955
- // Builder to be used to build offloading actions.
3956
- OffloadingActionBuilder OffloadBuilder (C, Args, Inputs);
3957
-
3958
3955
bool UseNewOffloadingDriver =
3959
3956
C.isOffloadingHostKind (Action::OFK_OpenMP) ||
3960
3957
Args.hasFlag (options::OPT_offload_new_driver,
3961
3958
options::OPT_no_offload_new_driver, false );
3962
3959
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
+
3963
3966
// Construct the actions to perform.
3964
3967
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr ;
3965
3968
ExtractAPIJobAction *ExtractAPIAction = nullptr ;
@@ -3982,14 +3985,14 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
3982
3985
// Use the current host action in any of the offloading actions, if
3983
3986
// required.
3984
3987
if (!UseNewOffloadingDriver)
3985
- if (OffloadBuilder. addHostDependenceToDeviceActions (Current, InputArg))
3988
+ if (OffloadBuilder-> addHostDependenceToDeviceActions (Current, InputArg))
3986
3989
break ;
3987
3990
3988
3991
for (phases::ID Phase : PL) {
3989
3992
3990
3993
// Add any offload action the host action depends on.
3991
3994
if (!UseNewOffloadingDriver)
3992
- Current = OffloadBuilder. addDeviceDependencesToHostAction (
3995
+ Current = OffloadBuilder-> addDeviceDependencesToHostAction (
3993
3996
Current, InputArg, Phase, PL.back (), FullPL);
3994
3997
if (!Current)
3995
3998
break ;
@@ -4052,7 +4055,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4052
4055
// Use the current host action in any of the offloading actions, if
4053
4056
// required.
4054
4057
if (!UseNewOffloadingDriver)
4055
- if (OffloadBuilder. addHostDependenceToDeviceActions (Current, InputArg))
4058
+ if (OffloadBuilder-> addHostDependenceToDeviceActions (Current, InputArg))
4056
4059
break ;
4057
4060
4058
4061
// Try to build the offloading actions and add the result as a dependency
@@ -4070,7 +4073,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4070
4073
4071
4074
// Add any top level actions generated for offloading.
4072
4075
if (!UseNewOffloadingDriver)
4073
- OffloadBuilder. appendTopLevelActions (Actions, Current, InputArg);
4076
+ OffloadBuilder-> appendTopLevelActions (Actions, Current, InputArg);
4074
4077
else if (Current)
4075
4078
Current->propagateHostOffloadInfo (C.getActiveOffloadKinds (),
4076
4079
/* BoundArch=*/ nullptr );
@@ -4082,12 +4085,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4082
4085
Arg *FinalPhaseArg;
4083
4086
if (getFinalPhase (Args, &FinalPhaseArg) == phases::Link)
4084
4087
if (!UseNewOffloadingDriver)
4085
- OffloadBuilder. appendDeviceLinkActions (Actions);
4088
+ OffloadBuilder-> appendDeviceLinkActions (Actions);
4086
4089
}
4087
4090
4088
4091
if (!LinkerInputs.empty ()) {
4089
4092
if (!UseNewOffloadingDriver)
4090
- if (Action *Wrapper = OffloadBuilder. makeHostLinkAction ())
4093
+ if (Action *Wrapper = OffloadBuilder-> makeHostLinkAction ())
4091
4094
LinkerInputs.push_back (Wrapper);
4092
4095
Action *LA;
4093
4096
// Check if this Linker Job should emit a static library.
@@ -4102,7 +4105,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4102
4105
LA = C.MakeAction <LinkJobAction>(LinkerInputs, types::TY_Image);
4103
4106
}
4104
4107
if (!UseNewOffloadingDriver)
4105
- LA = OffloadBuilder. processHostLinkAction (LA);
4108
+ LA = OffloadBuilder-> processHostLinkAction (LA);
4106
4109
Actions.push_back (LA);
4107
4110
}
4108
4111
0 commit comments