@@ -10648,31 +10648,33 @@ 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 old offloading
10653
+ // model. For new offloading model, a slightly modified version of this
10654
+ // 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, bool SpecConsts,
10661
+ types::ID OutputType) {
10662
+ if (OutputType == types::TY_LLVM_BC) {
10660
10663
// single file output requested - this means only perform necessary IR
10661
10664
// transformations (like specialization constant intrinsic lowering) and
10662
10665
// output LLVMIR
10663
10666
addArgs (PostLinkArgs, TCArgs, {" -ir-output-only" });
10664
10667
}
10665
- // specialization constants processing is mandatory
10666
10668
if (SpecConsts)
10667
10669
addArgs (PostLinkArgs, TCArgs, {" -spec-const=native" });
10668
10670
else
10669
10671
addArgs (PostLinkArgs, TCArgs, {" -spec-const=emulation" });
10670
10672
10671
10673
// 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.
10674
+ // the behavior in getNonTripleBasedSYCLPostLinkOpts , where the option is
10675
+ // added based on the user setting of -fsycl-device-code-split.
10674
10676
if (!TCArgs.hasArg (options::OPT_fsycl_device_code_split_EQ) &&
10675
- (NewOffloadDriver || !(Triple.getArchName () == " spir64_fpga" )))
10677
+ (!(Triple.getArchName () == " spir64_fpga" )))
10676
10678
addArgs (PostLinkArgs, TCArgs, {" -split=auto" });
10677
10679
10678
10680
// On Intel targets we don't need non-kernel functions as entry points,
@@ -10683,18 +10685,17 @@ getTripleBasedSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
10683
10685
options::OPT_fsycl_remove_unused_external_funcs,
10684
10686
false ) &&
10685
10687
!isSYCLNativeCPU (TC)) &&
10686
- (NewOffloadDriver || ( !Triple.isNVPTX () && !Triple.isAMDGPU ()) ))
10688
+ !Triple.isNVPTX () && !Triple.isAMDGPU ())
10687
10689
addArgs (PostLinkArgs, TCArgs, {" -emit-only-kernels-as-entry-points" });
10688
10690
10689
- if (!NewOffloadDriver && ! Triple.isAMDGCN ())
10691
+ if (!Triple.isAMDGCN ())
10690
10692
addArgs (PostLinkArgs, TCArgs, {" -emit-param-info" });
10691
10693
// Enable program metadata
10692
- if ((!NewOffloadDriver && (Triple.isNVPTX () || Triple.isAMDGCN ())) ||
10693
- isSYCLNativeCPU (TC))
10694
+ if (Triple.isNVPTX () || Triple.isAMDGCN () || isSYCLNativeCPU (TC))
10694
10695
addArgs (PostLinkArgs, TCArgs, {" -emit-program-metadata" });
10695
10696
if (OutputType != types::TY_LLVM_BC) {
10696
10697
assert (OutputType == types::TY_Tempfiletable);
10697
- bool SplitEsimdByDefault = !NewOffloadDriver && Triple.isSPIROrSPIRV ();
10698
+ bool SplitEsimdByDefault = Triple.isSPIROrSPIRV ();
10698
10699
bool SplitEsimd = TCArgs.hasFlag (
10699
10700
options::OPT_fsycl_device_code_split_esimd,
10700
10701
options::OPT_fno_sycl_device_code_split_esimd, SplitEsimdByDefault);
@@ -10714,7 +10715,7 @@ getTripleBasedSYCLPostLinkOpts(const ToolChain &TC, const JobAction &JA,
10714
10715
if (TCArgs.hasFlag (options::OPT_fsycl_add_default_spec_consts_image,
10715
10716
options::OPT_fno_sycl_add_default_spec_consts_image,
10716
10717
false ) &&
10717
- ( IsAOT || NewOffloadDriver) )
10718
+ IsAOT)
10718
10719
addArgs (PostLinkArgs, TCArgs,
10719
10720
{" -generate-device-image-default-spec-consts" });
10720
10721
}
@@ -10737,8 +10738,16 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
10737
10738
ArgStringList CmdArgs;
10738
10739
10739
10740
llvm::Triple T = getToolChain ().getTriple ();
10741
+ const toolchains::SYCLToolChain &TC =
10742
+ static_cast <const toolchains::SYCLToolChain &>(getToolChain ());
10743
+
10744
+ // Handle -Xdevice-post-link
10745
+ TC.TranslateTargetOpt (T, TCArgs, CmdArgs, options::OPT_Xdevice_post_link,
10746
+ options::OPT_Xdevice_post_link_EQ,
10747
+ JA.getOffloadingArch ());
10748
+
10740
10749
getNonTripleBasedSYCLPostLinkOpts (getToolChain (), JA, TCArgs, CmdArgs);
10741
- getTripleBasedSYCLPostLinkOpts (getToolChain (), JA, TCArgs, T, CmdArgs ,
10750
+ getTripleBasedSYCLPostLinkOpts (getToolChain (), TCArgs, CmdArgs, T ,
10742
10751
SYCLPostLink->getRTSetsSpecConstants (),
10743
10752
SYCLPostLink->getTrueType ());
10744
10753
@@ -10751,14 +10760,6 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
10751
10760
10752
10761
addArgs (CmdArgs, TCArgs, {" -o" , OutputArg});
10753
10762
10754
- const toolchains::SYCLToolChain &TC =
10755
- static_cast <const toolchains::SYCLToolChain &>(getToolChain ());
10756
-
10757
- // Handle -Xdevice-post-link
10758
- TC.TranslateTargetOpt (T, TCArgs, CmdArgs, options::OPT_Xdevice_post_link,
10759
- options::OPT_Xdevice_post_link_EQ,
10760
- JA.getOffloadingArch ());
10761
-
10762
10763
// Add input file
10763
10764
assert (Inputs.size () == 1 && Inputs.front ().isFilename () &&
10764
10765
" single input file expected" );
@@ -11116,17 +11117,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
11116
11117
appendOption (PostLinkOptString, A);
11117
11118
}
11118
11119
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
11120
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
11121
for (const auto &A : PostLinkArgs)
11131
11122
appendOption (PostLinkOptString, A);
11132
11123
if (!PostLinkOptString.empty ())
0 commit comments