@@ -10648,31 +10648,34 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
10648
10648
addArgs (PostLinkArgs, TCArgs, {" -lower-esimd-force-stateless-mem=false" });
10649
10649
}
10650
10650
10651
- // Add any sycl-post-link options that rely on a specific Triple.
10652
- static void
10653
- getTripleBasedSYCLPostLinkOpts (const ToolChain &TC, const JobAction &JA,
10654
- const llvm::opt::ArgList &TCArgs,
10655
- llvm::Triple Triple, ArgStringList &PostLinkArgs,
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)) {
10651
+ // Add any sycl-post-link options that rely on a specific Triple in addition
10652
+ // to user supplied options. This function is invoked only for the old
10653
+ // offloading model. For the new offloading model, a slightly modified version
10654
+ // of this function is called inside clang-linker-wrapper.
10655
+ // NOTE: Any changes made here should be reflected in the similarly named
10656
+ // function in clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp.
10657
+ static void getTripleBasedSYCLPostLinkOpts (const ToolChain &TC,
10658
+ const llvm::opt::ArgList &TCArgs,
10659
+ ArgStringList &PostLinkArgs,
10660
+ llvm::Triple Triple,
10661
+ bool SpecConstsSupported,
10662
+ types::ID OutputType) {
10663
+ if (OutputType == types::TY_LLVM_BC) {
10660
10664
// single file output requested - this means only perform necessary IR
10661
10665
// transformations (like specialization constant intrinsic lowering) and
10662
10666
// output LLVMIR
10663
10667
addArgs (PostLinkArgs, TCArgs, {" -ir-output-only" });
10664
10668
}
10665
- // specialization constants processing is mandatory
10666
- if (SpecConsts)
10669
+ if (SpecConstsSupported)
10667
10670
addArgs (PostLinkArgs, TCArgs, {" -spec-const=native" });
10668
10671
else
10669
10672
addArgs (PostLinkArgs, TCArgs, {" -spec-const=emulation" });
10670
10673
10671
10674
// See if device code splitting is requested. The logic here works along side
10672
- // the behavior in setOtherSYCLPostLinkOpts , where the option is added based
10673
- // on the user setting of-fsycl-device-code-split.
10675
+ // the behavior in getNonTripleBasedSYCLPostLinkOpts , where the option is
10676
+ // added based on the user setting of -fsycl-device-code-split.
10674
10677
if (!TCArgs.hasArg (options::OPT_fsycl_device_code_split_EQ) &&
10675
- (NewOffloadDriver || !( Triple.getArchName () == " spir64_fpga" ) ))
10678
+ (Triple.getArchName () != " spir64_fpga" ))
10676
10679
addArgs (PostLinkArgs, TCArgs, {" -split=auto" });
10677
10680
10678
10681
// On Intel targets we don't need non-kernel functions as entry points,
@@ -10683,18 +10686,17 @@ getTripleBasedSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
10683
10686
options::OPT_fsycl_remove_unused_external_funcs,
10684
10687
false ) &&
10685
10688
!isSYCLNativeCPU (TC)) &&
10686
- (NewOffloadDriver || ( !Triple.isNVPTX () && !Triple.isAMDGPU ()) ))
10689
+ !Triple.isNVPTX () && !Triple.isAMDGPU ())
10687
10690
addArgs (PostLinkArgs, TCArgs, {" -emit-only-kernels-as-entry-points" });
10688
10691
10689
- if (!NewOffloadDriver && ! Triple.isAMDGCN ())
10692
+ if (!Triple.isAMDGCN ())
10690
10693
addArgs (PostLinkArgs, TCArgs, {" -emit-param-info" });
10691
10694
// Enable program metadata
10692
- if ((!NewOffloadDriver && (Triple.isNVPTX () || Triple.isAMDGCN ())) ||
10693
- isSYCLNativeCPU (TC))
10695
+ if (Triple.isNVPTX () || Triple.isAMDGCN () || isSYCLNativeCPU (TC))
10694
10696
addArgs (PostLinkArgs, TCArgs, {" -emit-program-metadata" });
10695
10697
if (OutputType != types::TY_LLVM_BC) {
10696
10698
assert (OutputType == types::TY_Tempfiletable);
10697
- bool SplitEsimdByDefault = !NewOffloadDriver && Triple.isSPIROrSPIRV ();
10699
+ bool SplitEsimdByDefault = Triple.isSPIROrSPIRV ();
10698
10700
bool SplitEsimd = TCArgs.hasFlag (
10699
10701
options::OPT_fsycl_device_code_split_esimd,
10700
10702
options::OPT_fno_sycl_device_code_split_esimd, SplitEsimdByDefault);
@@ -10714,7 +10716,7 @@ getTripleBasedSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
10714
10716
if (TCArgs.hasFlag (options::OPT_fsycl_add_default_spec_consts_image,
10715
10717
options::OPT_fno_sycl_add_default_spec_consts_image,
10716
10718
false ) &&
10717
- ( IsAOT || NewOffloadDriver) )
10719
+ IsAOT)
10718
10720
addArgs (PostLinkArgs, TCArgs,
10719
10721
{" -generate-device-image-default-spec-consts" });
10720
10722
}
@@ -10738,7 +10740,7 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
10738
10740
10739
10741
llvm::Triple T = getToolChain ().getTriple ();
10740
10742
getNonTripleBasedSYCLPostLinkOpts (getToolChain (), JA, TCArgs, CmdArgs);
10741
- getTripleBasedSYCLPostLinkOpts (getToolChain (), JA, TCArgs, T, CmdArgs ,
10743
+ getTripleBasedSYCLPostLinkOpts (getToolChain (), TCArgs, CmdArgs, T ,
10742
10744
SYCLPostLink->getRTSetsSpecConstants (),
10743
10745
SYCLPostLink->getTrueType ());
10744
10746
@@ -10749,8 +10751,6 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
10749
10751
if (T.getSubArch () == llvm::Triple::SPIRSubArch_gen && Device.data ())
10750
10752
OutputArg = (" intel_gpu_" + Device + " ," + OutputArg).str ();
10751
10753
10752
- addArgs (CmdArgs, TCArgs, {" -o" , OutputArg});
10753
-
10754
10754
const toolchains::SYCLToolChain &TC =
10755
10755
static_cast <const toolchains::SYCLToolChain &>(getToolChain ());
10756
10756
@@ -10759,6 +10759,8 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
10759
10759
options::OPT_Xdevice_post_link_EQ,
10760
10760
JA.getOffloadingArch ());
10761
10761
10762
+ addArgs (CmdArgs, TCArgs, {" -o" , OutputArg});
10763
+
10762
10764
// Add input file
10763
10765
assert (Inputs.size () == 1 && Inputs.front ().isFilename () &&
10764
10766
" single input file expected" );
@@ -11111,24 +11113,14 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
11111
11113
// --sycl-post-link-options="options" provides a string of options to be
11112
11114
// passed along to the sycl-post-link tool during device link.
11113
11115
SmallString<128 > PostLinkOptString;
11114
- if (Args.hasArg (options::OPT_Xdevice_post_link)) {
11115
- for (const auto &A : Args.getAllArgValues (options::OPT_Xdevice_post_link))
11116
- appendOption (PostLinkOptString, A);
11117
- }
11118
11116
ArgStringList PostLinkArgs;
11119
- bool IsSYCLNativeCPU = driver::isSYCLNativeCPU (Args);
11120
- types::ID OutputType = TargetTriple.isSPIROrSPIRV () || IsSYCLNativeCPU
11121
- ? types::TY_Tempfiletable
11122
- : types::TY_LLVM_BC;
11123
- bool SpecConsts = TargetTriple.isSPIROrSPIRV ();
11124
11117
getNonTripleBasedSYCLPostLinkOpts (getToolChain (), JA, Args, PostLinkArgs);
11125
- // Some options like -spec-consts=* depend on target triple as well as some
11126
- // user options. So, these options are partly computed here and then
11127
- // updated inside the clang-linker-wrapper.
11128
- getTripleBasedSYCLPostLinkOpts (getToolChain (), JA, Args, TargetTriple,
11129
- PostLinkArgs, SpecConsts, OutputType);
11130
11118
for (const auto &A : PostLinkArgs)
11131
11119
appendOption (PostLinkOptString, A);
11120
+ if (Args.hasArg (options::OPT_Xdevice_post_link)) {
11121
+ for (const auto &A : Args.getAllArgValues (options::OPT_Xdevice_post_link))
11122
+ appendOption (PostLinkOptString, A);
11123
+ }
11132
11124
if (!PostLinkOptString.empty ())
11133
11125
CmdArgs.push_back (
11134
11126
Args.MakeArgString (" --sycl-post-link-options=" + PostLinkOptString));
0 commit comments