@@ -626,42 +626,17 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
626626 CmdArgs.push_back (" -shared" );
627627 }
628628
629- addLinkerCompressDebugSectionsOption (getToolChain (), Args, CmdArgs);
630- Args.AddAllArgs (CmdArgs, options::OPT_L);
631- getToolChain ().AddFilePathLibArgs (Args, CmdArgs);
632- AddLinkerInputs (getToolChain (), Inputs, Args, CmdArgs, JA);
633629 if (C.getDriver ().isUsingLTO ()) {
634630 const bool ThinLTO = (C.getDriver ().getLTOMode () == LTOK_Thin);
635631 addLTOOptions (getToolChain (), Args, CmdArgs, Output, Inputs[0 ], ThinLTO);
636-
637- if (!ThinLTO)
638- addFullLTOPartitionOption (C.getDriver (), Args, CmdArgs);
639- } else if (Args.hasArg (options::OPT_mcpu_EQ)) {
632+ } else if (Args.hasArg (options::OPT_mcpu_EQ))
640633 CmdArgs.push_back (Args.MakeArgString (
641- " -plugin-opt=mcpu=" +
642- getProcessorFromTargetID (getToolChain ().getTriple (),
643- Args.getLastArgValue (options::OPT_mcpu_EQ))));
644- }
634+ " -plugin-opt=mcpu=" + Args.getLastArgValue (options::OPT_mcpu_EQ)));
645635
646- // Always pass the target-id features to the LTO job.
647- std::vector<StringRef> Features;
648- getAMDGPUTargetFeatures (C.getDriver (), getToolChain ().getTriple (), Args,
649- Features);
650- if (!Features.empty ()) {
651- CmdArgs.push_back (
652- Args.MakeArgString (" -plugin-opt=-mattr=" + llvm::join (Features, " ," )));
653- }
654-
655- if (Args.hasArg (options::OPT_stdlib))
656- CmdArgs.append ({" -lc" , " -lm" });
657- if (Args.hasArg (options::OPT_startfiles)) {
658- std::optional<std::string> IncludePath = getToolChain ().getStdlibPath ();
659- if (!IncludePath)
660- IncludePath = " /lib" ;
661- SmallString<128 > P (*IncludePath);
662- llvm::sys::path::append (P, " crt1.o" );
663- CmdArgs.push_back (Args.MakeArgString (P));
664- }
636+ addLinkerCompressDebugSectionsOption (getToolChain (), Args, CmdArgs);
637+ Args.AddAllArgs (CmdArgs, options::OPT_L);
638+ getToolChain ().AddFilePathLibArgs (Args, CmdArgs);
639+ AddLinkerInputs (getToolChain (), Inputs, Args, CmdArgs, JA);
665640
666641 CmdArgs.push_back (" -o" );
667642 CmdArgs.push_back (Output.getFilename ());
@@ -670,6 +645,26 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
670645 CmdArgs, Inputs, Output));
671646}
672647
648+ static unsigned getFullLTOPartitions (const Driver &D, const ArgList &Args) {
649+ int Value = 0 ;
650+ StringRef A = Args.getLastArgValue (options::OPT_flto_partitions_EQ, " 8" );
651+ if (A.getAsInteger (10 , Value) || (Value < 1 )) {
652+ Arg *Arg = Args.getLastArg (options::OPT_flto_partitions_EQ);
653+ D.Diag (diag::err_drv_invalid_int_value)
654+ << Arg->getAsString (Args) << Arg->getValue ();
655+ return 1 ;
656+ }
657+
658+ return Value;
659+ }
660+
661+ void amdgpu::addFullLTOPartitionOption (const Driver &D,
662+ const llvm::opt::ArgList &Args,
663+ llvm::opt::ArgStringList &CmdArgs) {
664+ CmdArgs.push_back (Args.MakeArgString (" --lto-partitions=" +
665+ Twine (getFullLTOPartitions (D, Args))));
666+ }
667+
673668void amdgpu::getAMDGPUTargetFeatures (const Driver &D,
674669 const llvm::Triple &Triple,
675670 const llvm::opt::ArgList &Args,
@@ -763,33 +758,6 @@ llvm::SmallVector<std::string, 12> amdgpu::dlr::getCommonDeviceLibNames(
763758 FastRelaxedMath, CorrectSqrt, ABIVer, isOpenMP);
764759}
765760
766- static unsigned getFullLTOPartitions (const Driver &D, const ArgList &Args) {
767- const Arg *A = Args.getLastArg (options::OPT_flto_partitions_EQ);
768- // In the absence of an option, use 8 as the default.
769- if (!A)
770- return 8 ;
771- int Value = 0 ;
772- if (StringRef (A->getValue ()).getAsInteger (10 , Value) || (Value < 1 )) {
773- D.Diag (diag::err_drv_invalid_int_value)
774- << A->getAsString (Args) << A->getValue ();
775- return 1 ;
776- }
777-
778- return Value;
779- }
780-
781- void amdgpu::addFullLTOPartitionOption (const Driver &D,
782- const llvm::opt::ArgList &Args,
783- llvm::opt::ArgStringList &CmdArgs) {
784- // TODO: Should this be restricted to fgpu-rdc only ? Currently we'll
785- // also do it for non gpu-rdc LTO
786-
787- if (unsigned NumParts = getFullLTOPartitions (D, Args); NumParts > 1 ) {
788- CmdArgs.push_back (
789- Args.MakeArgString (" --lto-partitions=" + Twine (NumParts)));
790- }
791- }
792-
793761// / AMDGPU Toolchain
794762AMDGPUToolChain::AMDGPUToolChain (const Driver &D, const llvm::Triple &Triple,
795763 const ArgList &Args)
0 commit comments