@@ -2887,7 +2887,7 @@ class OffloadingActionBuilder final {
2887
2887
virtual void appendLinkDependences (OffloadAction::DeviceDependences &DA) {}
2888
2888
2889
2889
// / Append linker actions generated by the builder.
2890
- virtual void addDeviceLinkDependences (OffloadDepsJobAction *DA) {}
2890
+ virtual void addDeviceLinkDependencies (OffloadDepsJobAction *DA) {}
2891
2891
2892
2892
// / Initialize the builder. Return true if any initialization errors are
2893
2893
// / found.
@@ -3610,7 +3610,7 @@ class OffloadingActionBuilder final {
3610
3610
3611
3611
void appendLinkDependences (OffloadAction::DeviceDependences &DA) override {}
3612
3612
3613
- void addDeviceLinkDependences (OffloadDepsJobAction *DA) override {
3613
+ void addDeviceLinkDependencies (OffloadDepsJobAction *DA) override {
3614
3614
for (unsigned I = 0 ; I < ToolChains.size (); ++I) {
3615
3615
// Register dependent toolchain.
3616
3616
DA->registerDependentActionInfo (
@@ -4361,7 +4361,7 @@ class OffloadingActionBuilder final {
4361
4361
}
4362
4362
}
4363
4363
4364
- void addDeviceLinkDependences (OffloadDepsJobAction *DA) override {
4364
+ void addDeviceLinkDependencies (OffloadDepsJobAction *DA) override {
4365
4365
for (unsigned I = 0 ; I < ToolChains.size (); ++I) {
4366
4366
// Register dependent toolchain.
4367
4367
DA->registerDependentActionInfo (
@@ -4774,7 +4774,11 @@ class OffloadingActionBuilder final {
4774
4774
return false ;
4775
4775
}
4776
4776
4777
- void addDeviceDependencies (ActionList &LinkerInputs) {
4777
+ // / Create link job from the given host inputs and feed the result to offload
4778
+ // / deps job which fetches device dependencies from the linked host image.
4779
+ // / Offload deps output is then forwarded to active device action builders so
4780
+ // / they can add it to the device linker inputs.
4781
+ void addDeviceLinkDependenciesFromHost (ActionList &LinkerInputs) {
4778
4782
// Link image for reading dependencies from it.
4779
4783
auto *LA = C.MakeAction <LinkJobAction>(LinkerInputs, types::TY_Image);
4780
4784
@@ -4792,7 +4796,7 @@ class OffloadingActionBuilder final {
4792
4796
for (auto *SB : SpecializedBuilders) {
4793
4797
if (!SB->isValid ())
4794
4798
continue ;
4795
- SB->addDeviceLinkDependences (DA);
4799
+ SB->addDeviceLinkDependencies (DA);
4796
4800
}
4797
4801
}
4798
4802
@@ -5123,7 +5127,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
5123
5127
// With static fat archives we need to create additional steps for
5124
5128
// generating dependence objects for device link actions.
5125
5129
if (!LinkerInputs.empty () && C.getDriver ().getOffloadStaticLibSeen ())
5126
- OffloadBuilder.addDeviceDependencies (LinkerInputs);
5130
+ OffloadBuilder.addDeviceLinkDependenciesFromHost (LinkerInputs);
5127
5131
5128
5132
// Go through all of the args, and create a Linker specific argument list.
5129
5133
// When dealing with fat static archives each archive is individually
@@ -6026,11 +6030,10 @@ InputInfo Driver::BuildJobsForActionNoCache(
6026
6030
const JobAction *JA = cast<JobAction>(A);
6027
6031
ActionList CollapsedOffloadActions;
6028
6032
6029
- const ToolChain *TCForTS = TC;
6030
- if (auto *DA = dyn_cast<OffloadDepsJobAction>(A))
6031
- TCForTS = DA->getHostTC ();
6033
+ auto *DA = dyn_cast<OffloadDepsJobAction>(JA);
6034
+ const ToolChain *JATC = DA ? DA->getHostTC () : TC;
6032
6035
6033
- ToolSelector TS (JA, *TCForTS , C, isSaveTempsEnabled (),
6036
+ ToolSelector TS (JA, *JATC , C, isSaveTempsEnabled (),
6034
6037
embedBitcodeInObject () && !isUsingLTO ());
6035
6038
const Tool *T = TS.getTool (Inputs, CollapsedOffloadActions);
6036
6039
@@ -6058,15 +6061,10 @@ InputInfo Driver::BuildJobsForActionNoCache(
6058
6061
// FIXME: Clean this up.
6059
6062
bool SubJobAtTopLevel =
6060
6063
AtTopLevel && (isa<DsymutilJobAction>(A) || isa<VerifyJobAction>(A));
6061
- if (auto *DA = dyn_cast<OffloadDepsJobAction>(A))
6062
- InputInfos.push_back (
6063
- BuildJobsForAction (C, Input, DA->getHostTC (), DA->getOffloadingArch (),
6064
- SubJobAtTopLevel, MultipleArchs, LinkingOutput,
6065
- CachedResults, DA->getOffloadingDeviceKind ()));
6066
- else
6067
- InputInfos.push_back (BuildJobsForAction (
6068
- C, Input, TC, BoundArch, SubJobAtTopLevel, MultipleArchs,
6069
- LinkingOutput, CachedResults, A->getOffloadingDeviceKind ()));
6064
+ InputInfos.push_back (BuildJobsForAction (
6065
+ C, Input, JATC, DA ? DA->getOffloadingArch () : BoundArch,
6066
+ SubJobAtTopLevel, MultipleArchs, LinkingOutput, CachedResults,
6067
+ A->getOffloadingDeviceKind ()));
6070
6068
}
6071
6069
// Check if we are in sub-work for preprocessing for host side. If so we will
6072
6070
// add another job to print information to terminal later.
@@ -6257,14 +6255,11 @@ InputInfo Driver::BuildJobsForActionNoCache(
6257
6255
6258
6256
// Get the unique string identifier for this dependence and cache the
6259
6257
// result.
6260
- StringRef Arch;
6261
- if (TargetDeviceOffloadKind == Action::OFK_HIP) {
6262
- if (DI.DependentOffloadKind == Action::OFK_Host)
6263
- Arch = StringRef ();
6264
- else
6265
- Arch = DI.DependentBoundArch ;
6266
- } else
6267
- Arch = BoundArch;
6258
+ StringRef Arch = TargetDeviceOffloadKind == Action::OFK_HIP
6259
+ ? DI.DependentOffloadKind == Action::OFK_Host
6260
+ ? StringRef ()
6261
+ : DI.DependentBoundArch
6262
+ : BoundArch;
6268
6263
6269
6264
CachedResults[{A, GetTriplePlusArchString (DI.DependentToolChain , Arch,
6270
6265
DI.DependentOffloadKind )}] =
0 commit comments