@@ -624,19 +624,18 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
624624 CmdArgs.push_back (" --no-undefined" );
625625 CmdArgs.push_back (" -shared" );
626626
627- addLinkerCompressDebugSectionsOption (getToolChain (), Args, CmdArgs);
628- Args.AddAllArgs (CmdArgs, options::OPT_L);
629- getToolChain ().AddFilePathLibArgs (Args, CmdArgs);
630- AddLinkerInputs (getToolChain (), Inputs, Args, CmdArgs, JA);
631627 if (C.getDriver ().isUsingLTO ()) {
632628 const bool ThinLTO = (C.getDriver ().getLTOMode () == LTOK_Thin);
633629 addLTOOptions (getToolChain (), Args, CmdArgs, Output, Inputs[0 ], ThinLTO);
634-
635- if (!ThinLTO)
636- addFullLTOPartitionOption (C.getDriver (), Args, CmdArgs);
637630 } else if (Args.hasArg (options::OPT_mcpu_EQ))
638631 CmdArgs.push_back (Args.MakeArgString (
639632 " -plugin-opt=mcpu=" + Args.getLastArgValue (options::OPT_mcpu_EQ)));
633+
634+ addLinkerCompressDebugSectionsOption (getToolChain (), Args, CmdArgs);
635+ Args.AddAllArgs (CmdArgs, options::OPT_L);
636+ getToolChain ().AddFilePathLibArgs (Args, CmdArgs);
637+ AddLinkerInputs (getToolChain (), Inputs, Args, CmdArgs, JA);
638+
640639 CmdArgs.push_back (" -o" );
641640 CmdArgs.push_back (Output.getFilename ());
642641 C.addCommand (std::make_unique<Command>(
@@ -645,14 +644,12 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
645644}
646645
647646static unsigned getFullLTOPartitions (const Driver &D, const ArgList &Args) {
648- const Arg *A = Args.getLastArg (options::OPT_flto_partitions_EQ);
649- // In the absence of an option, use 8 as the default.
650- if (!A)
651- return 8 ;
652647 int Value = 0 ;
653- if (StringRef (A->getValue ()).getAsInteger (10 , Value) || (Value < 1 )) {
648+ StringRef A = Args.getLastArgValue (options::OPT_flto_partitions_EQ, " 8" );
649+ if (A.getAsInteger (10 , Value) || (Value < 1 )) {
650+ Arg *Arg = Args.getLastArg (options::OPT_flto_partitions_EQ);
654651 D.Diag (diag::err_drv_invalid_int_value)
655- << A ->getAsString (Args) << A ->getValue ();
652+ << Arg ->getAsString (Args) << Arg ->getValue ();
656653 return 1 ;
657654 }
658655
@@ -662,13 +659,8 @@ static unsigned getFullLTOPartitions(const Driver &D, const ArgList &Args) {
662659void amdgpu::addFullLTOPartitionOption (const Driver &D,
663660 const llvm::opt::ArgList &Args,
664661 llvm::opt::ArgStringList &CmdArgs) {
665- // TODO: Should this be restricted to fgpu-rdc only ? Currently we'll
666- // also do it for non gpu-rdc LTO
667-
668- if (unsigned NumParts = getFullLTOPartitions (D, Args); NumParts > 1 ) {
669- CmdArgs.push_back (
670- Args.MakeArgString (" --lto-partitions=" + Twine (NumParts)));
671- }
662+ CmdArgs.push_back (Args.MakeArgString (" --lto-partitions=" +
663+ Twine (getFullLTOPartitions (D, Args))));
672664}
673665
674666void amdgpu::getAMDGPUTargetFeatures (const Driver &D,
0 commit comments