diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3952,14 +3952,17 @@ handleArguments(C, Args, Inputs, Actions); - // Builder to be used to build offloading actions. - OffloadingActionBuilder OffloadBuilder(C, Args, Inputs); - bool UseNewOffloadingDriver = C.isOffloadingHostKind(Action::OFK_OpenMP) || Args.hasFlag(options::OPT_offload_new_driver, options::OPT_no_offload_new_driver, false); + // Builder to be used to build offloading actions. + std::unique_ptr OffloadBuilder = + !UseNewOffloadingDriver + ? std::make_unique(C, Args, Inputs) + : nullptr; + // Construct the actions to perform. HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr; ExtractAPIJobAction *ExtractAPIAction = nullptr; @@ -3982,14 +3985,14 @@ // Use the current host action in any of the offloading actions, if // required. if (!UseNewOffloadingDriver) - if (OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg)) + if (OffloadBuilder->addHostDependenceToDeviceActions(Current, InputArg)) break; for (phases::ID Phase : PL) { // Add any offload action the host action depends on. if (!UseNewOffloadingDriver) - Current = OffloadBuilder.addDeviceDependencesToHostAction( + Current = OffloadBuilder->addDeviceDependencesToHostAction( Current, InputArg, Phase, PL.back(), FullPL); if (!Current) break; @@ -4052,7 +4055,7 @@ // Use the current host action in any of the offloading actions, if // required. if (!UseNewOffloadingDriver) - if (OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg)) + if (OffloadBuilder->addHostDependenceToDeviceActions(Current, InputArg)) break; // Try to build the offloading actions and add the result as a dependency @@ -4070,7 +4073,7 @@ // Add any top level actions generated for offloading. if (!UseNewOffloadingDriver) - OffloadBuilder.appendTopLevelActions(Actions, Current, InputArg); + OffloadBuilder->appendTopLevelActions(Actions, Current, InputArg); else if (Current) Current->propagateHostOffloadInfo(C.getActiveOffloadKinds(), /*BoundArch=*/nullptr); @@ -4082,12 +4085,12 @@ Arg *FinalPhaseArg; if (getFinalPhase(Args, &FinalPhaseArg) == phases::Link) if (!UseNewOffloadingDriver) - OffloadBuilder.appendDeviceLinkActions(Actions); + OffloadBuilder->appendDeviceLinkActions(Actions); } if (!LinkerInputs.empty()) { if (!UseNewOffloadingDriver) - if (Action *Wrapper = OffloadBuilder.makeHostLinkAction()) + if (Action *Wrapper = OffloadBuilder->makeHostLinkAction()) LinkerInputs.push_back(Wrapper); Action *LA; // Check if this Linker Job should emit a static library. @@ -4102,7 +4105,7 @@ LA = C.MakeAction(LinkerInputs, types::TY_Image); } if (!UseNewOffloadingDriver) - LA = OffloadBuilder.processHostLinkAction(LA); + LA = OffloadBuilder->processHostLinkAction(LA); Actions.push_back(LA); }