@@ -3441,178 +3441,6 @@ class OffloadingActionBuilder final {
3441
3441
void appendLinkDependences (OffloadAction::DeviceDependences &DA) override {}
3442
3442
};
3443
3443
3444
- // / OpenMP action builder. The host bitcode is passed to the device frontend
3445
- // / and all the device linked images are passed to the host link phase.
3446
- class OpenMPActionBuilder final : public DeviceActionBuilder {
3447
- // / The OpenMP actions for the current input.
3448
- ActionList OpenMPDeviceActions;
3449
-
3450
- // / The linker inputs obtained for each toolchain.
3451
- SmallVector<ActionList, 8 > DeviceLinkerInputs;
3452
-
3453
- public:
3454
- OpenMPActionBuilder (Compilation &C, DerivedArgList &Args,
3455
- const Driver::InputList &Inputs)
3456
- : DeviceActionBuilder(C, Args, Inputs, Action::OFK_OpenMP) {}
3457
-
3458
- ActionBuilderReturnCode
3459
- getDeviceDependences (OffloadAction::DeviceDependences &DA,
3460
- phases::ID CurPhase, phases::ID FinalPhase,
3461
- PhasesTy &Phases) override {
3462
- if (OpenMPDeviceActions.empty ())
3463
- return ABRT_Inactive;
3464
-
3465
- // We should always have an action for each input.
3466
- assert (OpenMPDeviceActions.size () == ToolChains.size () &&
3467
- " Number of OpenMP actions and toolchains do not match." );
3468
-
3469
- // The host only depends on device action in the linking phase, when all
3470
- // the device images have to be embedded in the host image.
3471
- if (CurPhase == phases::Link) {
3472
- assert (ToolChains.size () == DeviceLinkerInputs.size () &&
3473
- " Toolchains and linker inputs sizes do not match." );
3474
- auto LI = DeviceLinkerInputs.begin ();
3475
- for (auto *A : OpenMPDeviceActions) {
3476
- LI->push_back (A);
3477
- ++LI;
3478
- }
3479
-
3480
- // We passed the device action as a host dependence, so we don't need to
3481
- // do anything else with them.
3482
- OpenMPDeviceActions.clear ();
3483
- return ABRT_Success;
3484
- }
3485
-
3486
- // By default, we produce an action for each device arch.
3487
- for (Action *&A : OpenMPDeviceActions)
3488
- A = C.getDriver ().ConstructPhaseAction (C, Args, CurPhase, A);
3489
-
3490
- return ABRT_Success;
3491
- }
3492
-
3493
- ActionBuilderReturnCode addDeviceDepences (Action *HostAction) override {
3494
-
3495
- // If this is an input action replicate it for each OpenMP toolchain.
3496
- if (auto *IA = dyn_cast<InputAction>(HostAction)) {
3497
- OpenMPDeviceActions.clear ();
3498
- for (unsigned I = 0 ; I < ToolChains.size (); ++I)
3499
- OpenMPDeviceActions.push_back (
3500
- C.MakeAction <InputAction>(IA->getInputArg (), IA->getType ()));
3501
- return ABRT_Success;
3502
- }
3503
-
3504
- // If this is an unbundling action use it as is for each OpenMP toolchain.
3505
- if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction)) {
3506
- OpenMPDeviceActions.clear ();
3507
- auto *IA = cast<InputAction>(UA->getInputs ().back ());
3508
- std::string FileName = IA->getInputArg ().getAsString (Args);
3509
- // Check if the type of the file is the same as the action. Do not
3510
- // unbundle it if it is not. Do not unbundle .so files, for example,
3511
- // which are not object files.
3512
- if (IA->getType () == types::TY_Object &&
3513
- (!llvm::sys::path::has_extension (FileName) ||
3514
- types::lookupTypeForExtension (
3515
- llvm::sys::path::extension (FileName).drop_front ()) !=
3516
- types::TY_Object))
3517
- return ABRT_Inactive;
3518
- for (unsigned I = 0 ; I < ToolChains.size (); ++I) {
3519
- OpenMPDeviceActions.push_back (UA);
3520
- UA->registerDependentActionInfo (
3521
- ToolChains[I], /* BoundArch=*/ StringRef (), Action::OFK_OpenMP);
3522
- }
3523
- return ABRT_Success;
3524
- }
3525
-
3526
- // When generating code for OpenMP we use the host compile phase result as
3527
- // a dependence to the device compile phase so that it can learn what
3528
- // declarations should be emitted. However, this is not the only use for
3529
- // the host action, so we prevent it from being collapsed.
3530
- if (isa<CompileJobAction>(HostAction)) {
3531
- HostAction->setCannotBeCollapsedWithNextDependentAction ();
3532
- assert (ToolChains.size () == OpenMPDeviceActions.size () &&
3533
- " Toolchains and device action sizes do not match." );
3534
- OffloadAction::HostDependence HDep (
3535
- *HostAction, *C.getSingleOffloadToolChain <Action::OFK_Host>(),
3536
- /* BoundArch=*/ nullptr , Action::OFK_OpenMP);
3537
- auto TC = ToolChains.begin ();
3538
- for (Action *&A : OpenMPDeviceActions) {
3539
- assert (isa<CompileJobAction>(A));
3540
- OffloadAction::DeviceDependences DDep;
3541
- DDep.add (*A, **TC, /* BoundArch=*/ nullptr , Action::OFK_OpenMP);
3542
- A = C.MakeAction <OffloadAction>(HDep, DDep);
3543
- ++TC;
3544
- }
3545
- }
3546
- return ABRT_Success;
3547
- }
3548
-
3549
- void appendTopLevelActions (ActionList &AL) override {
3550
- if (OpenMPDeviceActions.empty ())
3551
- return ;
3552
-
3553
- // We should always have an action for each input.
3554
- assert (OpenMPDeviceActions.size () == ToolChains.size () &&
3555
- " Number of OpenMP actions and toolchains do not match." );
3556
-
3557
- // Append all device actions followed by the proper offload action.
3558
- auto TI = ToolChains.begin ();
3559
- for (auto *A : OpenMPDeviceActions) {
3560
- OffloadAction::DeviceDependences Dep;
3561
- Dep.add (*A, **TI, /* BoundArch=*/ nullptr , Action::OFK_OpenMP);
3562
- AL.push_back (C.MakeAction <OffloadAction>(Dep, A->getType ()));
3563
- ++TI;
3564
- }
3565
- // We no longer need the action stored in this builder.
3566
- OpenMPDeviceActions.clear ();
3567
- }
3568
-
3569
- void appendLinkDeviceActions (ActionList &AL) override {
3570
- assert (ToolChains.size () == DeviceLinkerInputs.size () &&
3571
- " Toolchains and linker inputs sizes do not match." );
3572
-
3573
- // Append a new link action for each device.
3574
- auto TC = ToolChains.begin ();
3575
- for (auto &LI : DeviceLinkerInputs) {
3576
- auto *DeviceLinkAction =
3577
- C.MakeAction <LinkJobAction>(LI, types::TY_Image);
3578
- OffloadAction::DeviceDependences DeviceLinkDeps;
3579
- DeviceLinkDeps.add (*DeviceLinkAction, **TC, /* BoundArch=*/ nullptr ,
3580
- Action::OFK_OpenMP);
3581
- AL.push_back (C.MakeAction <OffloadAction>(DeviceLinkDeps,
3582
- DeviceLinkAction->getType ()));
3583
- ++TC;
3584
- }
3585
- DeviceLinkerInputs.clear ();
3586
- }
3587
-
3588
- Action* appendLinkHostActions (ActionList &AL) override {
3589
- // Create wrapper bitcode from the result of device link actions and compile
3590
- // it to an object which will be added to the host link command.
3591
- auto *BC = C.MakeAction <OffloadWrapperJobAction>(AL, types::TY_LLVM_BC);
3592
- auto *ASM = C.MakeAction <BackendJobAction>(BC, types::TY_PP_Asm);
3593
- return C.MakeAction <AssembleJobAction>(ASM, types::TY_Object);
3594
- }
3595
-
3596
- void appendLinkDependences (OffloadAction::DeviceDependences &DA) override {}
3597
-
3598
- bool initialize () override {
3599
- // Get the OpenMP toolchains. If we don't get any, the action builder will
3600
- // know there is nothing to do related to OpenMP offloading.
3601
- auto OpenMPTCRange = C.getOffloadToolChains <Action::OFK_OpenMP>();
3602
- for (auto TI = OpenMPTCRange.first , TE = OpenMPTCRange.second ; TI != TE;
3603
- ++TI)
3604
- ToolChains.push_back (TI->second );
3605
-
3606
- DeviceLinkerInputs.resize (ToolChains.size ());
3607
- return false ;
3608
- }
3609
-
3610
- bool canUseBundlerUnbundler () const override {
3611
- // OpenMP should use bundled files whenever possible.
3612
- return true ;
3613
- }
3614
- };
3615
-
3616
3444
// /
3617
3445
// / TODO: Add the implementation for other specialized builders here.
3618
3446
// /
@@ -3637,9 +3465,6 @@ class OffloadingActionBuilder final {
3637
3465
// Create a specialized builder for HIP.
3638
3466
SpecializedBuilders.push_back (new HIPActionBuilder (C, Args, Inputs));
3639
3467
3640
- // Create a specialized builder for OpenMP.
3641
- SpecializedBuilders.push_back (new OpenMPActionBuilder (C, Args, Inputs));
3642
-
3643
3468
//
3644
3469
// TODO: Build other specialized builders here.
3645
3470
//
@@ -5505,14 +5330,6 @@ InputInfoList Driver::BuildJobsForActionNoCache(
5505
5330
/* CreatePrefixForHost=*/ isa<OffloadPackagerJobAction>(A) ||
5506
5331
!(A->getOffloadingHostActiveKinds () == Action::OFK_None ||
5507
5332
AtTopLevel));
5508
- if (isa<OffloadWrapperJobAction>(JA)) {
5509
- if (Arg *FinalOutput = C.getArgs ().getLastArg (options::OPT_o))
5510
- BaseInput = FinalOutput->getValue ();
5511
- else
5512
- BaseInput = getDefaultImageName ();
5513
- BaseInput =
5514
- C.getArgs ().MakeArgString (std::string (BaseInput) + " -wrapper" );
5515
- }
5516
5333
Result = InputInfo (A, GetNamedOutputPath (C, *JA, BaseInput, BoundArch,
5517
5334
AtTopLevel, MultipleArchs,
5518
5335
OffloadingPrefix),
0 commit comments