@@ -10620,10 +10620,10 @@ static void addArgs(ArgStringList &DstArgs, const llvm::opt::ArgList &Alloc,
10620
10620
}
10621
10621
}
10622
10622
10623
- static void getOtherSYCLPostLinkOpts (const ToolChain &TC, const JobAction &JA ,
10624
- const llvm::opt::ArgList &TCArgs ,
10625
- ArgStringList &PostLinkArgs ,
10626
- bool SpecConsts, types::ID OutputType ) {
10623
+ static void getNonTripleBasedSYCLPostLinkOpts (const ToolChain &TC,
10624
+ const JobAction &JA ,
10625
+ const llvm::opt::ArgList &TCArgs ,
10626
+ ArgStringList &PostLinkArgs ) {
10627
10627
// See if device code splitting is requested
10628
10628
if (Arg *A = TCArgs.getLastArg (options::OPT_fsycl_device_code_split_EQ)) {
10629
10629
auto CodeSplitValue = StringRef (A->getValue ());
@@ -10636,19 +10636,8 @@ static void getOtherSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
10636
10636
else { // Device code split is off
10637
10637
}
10638
10638
}
10639
- if (OutputType == types::TY_LLVM_BC) {
10640
- // single file output requested - this means only perform necessary IR
10641
- // transformations (like specialization constant intrinsic lowering) and
10642
- // output LLVMIR
10643
- addArgs (PostLinkArgs, TCArgs, {" -ir-output-only" });
10644
- }
10645
10639
addArgs (PostLinkArgs, TCArgs,
10646
10640
{StringRef (getSYCLPostLinkOptimizationLevel (TCArgs))});
10647
- // specialization constants processing is mandatory
10648
- if (SpecConsts)
10649
- addArgs (PostLinkArgs, TCArgs, {" -spec-const=native" });
10650
- else
10651
- addArgs (PostLinkArgs, TCArgs, {" -spec-const=emulation" });
10652
10641
10653
10642
// Process device-globals.
10654
10643
addArgs (PostLinkArgs, TCArgs, {" -device-globals" });
@@ -10665,31 +10654,47 @@ getTripleBasedSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
10665
10654
const llvm::opt::ArgList &TCArgs,
10666
10655
llvm::Triple Triple, ArgStringList &PostLinkArgs,
10667
10656
bool SpecConsts, types::ID OutputType) {
10657
+ bool NewOffloadDriver = TC.getDriver ().getUseNewOffloadingDriver ();
10658
+ // Note: Do not use Triple when NewOffloadDriver is 'true'.
10659
+ if (!NewOffloadDriver && (OutputType == types::TY_LLVM_BC)) {
10660
+ // single file output requested - this means only perform necessary IR
10661
+ // transformations (like specialization constant intrinsic lowering) and
10662
+ // output LLVMIR
10663
+ addArgs (PostLinkArgs, TCArgs, {" -ir-output-only" });
10664
+ }
10665
+ // specialization constants processing is mandatory
10666
+ if (SpecConsts)
10667
+ addArgs (PostLinkArgs, TCArgs, {" -spec-const=native" });
10668
+ else
10669
+ addArgs (PostLinkArgs, TCArgs, {" -spec-const=emulation" });
10668
10670
10669
10671
// See if device code splitting is requested. The logic here works along side
10670
10672
// the behavior in setOtherSYCLPostLinkOpts, where the option is added based
10671
10673
// on the user setting of-fsycl-device-code-split.
10672
- if (!( TCArgs.hasArg (options::OPT_fsycl_device_code_split_EQ) ||
10673
- Triple.getArchName () == " spir64_fpga" ))
10674
+ if (!TCArgs.hasArg (options::OPT_fsycl_device_code_split_EQ) &&
10675
+ (NewOffloadDriver || !( Triple.getArchName () == " spir64_fpga" ) ))
10674
10676
addArgs (PostLinkArgs, TCArgs, {" -split=auto" });
10675
10677
10676
10678
// On Intel targets we don't need non-kernel functions as entry points,
10677
10679
// because it only increases amount of code for device compiler to handle,
10678
10680
// without any actual benefits.
10679
10681
// TODO: Try to extend this feature for non-Intel GPUs.
10680
- if (!TCArgs.hasFlag (options::OPT_fno_sycl_remove_unused_external_funcs,
10681
- options::OPT_fsycl_remove_unused_external_funcs, false ) &&
10682
- !Triple.isNVPTX () && !Triple.isAMDGPU () && !isSYCLNativeCPU (TC))
10682
+ if ((!TCArgs.hasFlag (options::OPT_fno_sycl_remove_unused_external_funcs,
10683
+ options::OPT_fsycl_remove_unused_external_funcs,
10684
+ false ) &&
10685
+ !isSYCLNativeCPU (TC)) &&
10686
+ (NewOffloadDriver || (!Triple.isNVPTX () && !Triple.isAMDGPU ())))
10683
10687
addArgs (PostLinkArgs, TCArgs, {" -emit-only-kernels-as-entry-points" });
10684
10688
10685
- if (!( Triple.isAMDGCN () ))
10689
+ if (!NewOffloadDriver && ! Triple.isAMDGCN ())
10686
10690
addArgs (PostLinkArgs, TCArgs, {" -emit-param-info" });
10687
- // Enable PI program metadata
10688
- if (Triple.isNVPTX () || Triple.isAMDGCN () || isSYCLNativeCPU (TC))
10691
+ // Enable program metadata
10692
+ if ((!NewOffloadDriver && (Triple.isNVPTX () || Triple.isAMDGCN ())) ||
10693
+ isSYCLNativeCPU (TC))
10689
10694
addArgs (PostLinkArgs, TCArgs, {" -emit-program-metadata" });
10690
10695
if (OutputType != types::TY_LLVM_BC) {
10691
10696
assert (OutputType == types::TY_Tempfiletable);
10692
- bool SplitEsimdByDefault = Triple.isSPIROrSPIRV ();
10697
+ bool SplitEsimdByDefault = !NewOffloadDriver && Triple.isSPIROrSPIRV ();
10693
10698
bool SplitEsimd = TCArgs.hasFlag (
10694
10699
options::OPT_fsycl_device_code_split_esimd,
10695
10700
options::OPT_fno_sycl_device_code_split_esimd, SplitEsimdByDefault);
@@ -10701,14 +10706,14 @@ getTripleBasedSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
10701
10706
addArgs (PostLinkArgs, TCArgs, {" -split-esimd" });
10702
10707
addArgs (PostLinkArgs, TCArgs, {" -lower-esimd" });
10703
10708
}
10704
- bool isAOT = Triple.isNVPTX () || Triple.isAMDGCN () ||
10709
+ bool IsAOT = Triple.isNVPTX () || Triple.isAMDGCN () ||
10705
10710
Triple.getSubArch () == llvm::Triple::SPIRSubArch_fpga ||
10706
10711
Triple.getSubArch () == llvm::Triple::SPIRSubArch_gen ||
10707
10712
Triple.getSubArch () == llvm::Triple::SPIRSubArch_x86_64;
10708
10713
if (TCArgs.hasFlag (options::OPT_fsycl_add_default_spec_consts_image,
10709
10714
options::OPT_fno_sycl_add_default_spec_consts_image,
10710
10715
false ) &&
10711
- isAOT )
10716
+ (IsAOT || NewOffloadDriver) )
10712
10717
addArgs (PostLinkArgs, TCArgs,
10713
10718
{" -generate-device-image-default-spec-consts" });
10714
10719
}
@@ -10731,9 +10736,7 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
10731
10736
ArgStringList CmdArgs;
10732
10737
10733
10738
llvm::Triple T = getToolChain ().getTriple ();
10734
- getOtherSYCLPostLinkOpts (getToolChain (), JA, TCArgs, CmdArgs,
10735
- SYCLPostLink->getRTSetsSpecConstants (),
10736
- SYCLPostLink->getTrueType ());
10739
+ getNonTripleBasedSYCLPostLinkOpts (getToolChain (), JA, TCArgs, CmdArgs);
10737
10740
getTripleBasedSYCLPostLinkOpts (getToolChain (), JA, TCArgs, T, CmdArgs,
10738
10741
SYCLPostLink->getRTSetsSpecConstants (),
10739
10742
SYCLPostLink->getTrueType ());
@@ -11135,13 +11138,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
11135
11138
types::ID OutputType = TargetTriple.isSPIROrSPIRV () || IsSYCLNativeCPU
11136
11139
? types::TY_Tempfiletable
11137
11140
: types::TY_LLVM_BC;
11138
- // TODO: Items like native_cpu and Specialization Constants behaviors are
11139
- // dependent on each toolchain. Passing these along as 'general settings'
11140
- // for the clang-linker-wrapper causes for potential inconsistencies and
11141
- // would need to handled more at the device linking level.
11142
11141
bool SpecConsts = TargetTriple.isSPIROrSPIRV ();
11143
- getOtherSYCLPostLinkOpts (getToolChain (), JA, Args, PostLinkArgs, SpecConsts,
11144
- OutputType);
11142
+ getNonTripleBasedSYCLPostLinkOpts (getToolChain (), JA, Args, PostLinkArgs);
11143
+ // Some options like -spec-consts=* depend on target triple as well as some
11144
+ // user options. So, these options are partly computed here and then
11145
+ // updated inside the clang-linker-wrapper.
11145
11146
getTripleBasedSYCLPostLinkOpts (getToolChain (), JA, Args, TargetTriple,
11146
11147
PostLinkArgs, SpecConsts, OutputType);
11147
11148
for (const auto &A : PostLinkArgs)
0 commit comments