Skip to content

Commit 4f1eb5e

Browse files
committed
Address review comments
Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent ac744f5 commit 4f1eb5e

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10649,23 +10649,24 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1064910649
}
1065010650

1065110651
// 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.
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.
1065510655
// NOTE: Any changes made here should be reflected in the similarly named
1065610656
// function in clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp.
1065710657
static void getTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1065810658
const llvm::opt::ArgList &TCArgs,
1065910659
ArgStringList &PostLinkArgs,
10660-
llvm::Triple Triple, bool SpecConsts,
10660+
llvm::Triple Triple,
10661+
bool SpecConstsSupported,
1066110662
types::ID OutputType) {
1066210663
if (OutputType == types::TY_LLVM_BC) {
1066310664
// single file output requested - this means only perform necessary IR
1066410665
// transformations (like specialization constant intrinsic lowering) and
1066510666
// output LLVMIR
1066610667
addArgs(PostLinkArgs, TCArgs, {"-ir-output-only"});
1066710668
}
10668-
if (SpecConsts)
10669+
if (SpecConstsSupported)
1066910670
addArgs(PostLinkArgs, TCArgs, {"-spec-const=native"});
1067010671
else
1067110672
addArgs(PostLinkArgs, TCArgs, {"-spec-const=emulation"});
@@ -10674,7 +10675,7 @@ static void getTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1067410675
// the behavior in getNonTripleBasedSYCLPostLinkOpts, where the option is
1067510676
// added based on the user setting of -fsycl-device-code-split.
1067610677
if (!TCArgs.hasArg(options::OPT_fsycl_device_code_split_EQ) &&
10677-
(!(Triple.getArchName() == "spir64_fpga")))
10678+
(Triple.getArchName() != "spir64_fpga"))
1067810679
addArgs(PostLinkArgs, TCArgs, {"-split=auto"});
1067910680

1068010681
// On Intel targets we don't need non-kernel functions as entry points,

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,15 @@ getTripleBasedSYCLPostLinkOpts(const ArgList &Args,
532532
const llvm::Triple Triple) {
533533
const llvm::Triple HostTriple(Args.getLastArgValue(OPT_host_triple_EQ));
534534
bool SYCLNativeCPU = (HostTriple == Triple);
535-
bool SpecConsts = !(Triple.isNVPTX() || Triple.isAMDGCN() ||
536-
Triple.isSPIRAOT() || SYCLNativeCPU);
537-
if (SpecConsts)
535+
bool SpecConstsSupported = (!Triple.isNVPTX() && !Triple.isAMDGCN() ||
536+
!Triple.isSPIRAOT() && !SYCLNativeCPU);
537+
if (SpecConstsSupported)
538538
PostLinkArgs.push_back("-spec-const=native");
539539
else
540540
PostLinkArgs.push_back("-spec-const=emulation");
541541

542-
// See if device code splitting is requested. The logic here works along side
543-
// the behavior in getNonTripleBasedSYCLPostLinkOpts, where the option is
544-
// added based on the user setting of -fsycl-device-code-split.
542+
// See if device code splitting is already requested. If not requested, then
543+
// set -split=auto for non-FPGA targets.
545544
bool NoSplit = true;
546545
for (auto Arg : PostLinkArgs)
547546
if (Arg.contains("-split=")) {
@@ -580,10 +579,7 @@ getTripleBasedSYCLPostLinkOpts(const ArgList &Args,
580579
PostLinkArgs.push_back("-split-esimd");
581580
PostLinkArgs.push_back("-lower-esimd");
582581

583-
bool IsAOT = Triple.isNVPTX() || Triple.isAMDGCN() ||
584-
Triple.getSubArch() == llvm::Triple::SPIRSubArch_fpga ||
585-
Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen ||
586-
Triple.getSubArch() == llvm::Triple::SPIRSubArch_x86_64;
582+
bool IsAOT = Triple.isNVPTX() || Triple.isAMDGCN() || Triple.isSPIRAOT();
587583
if (Args.hasFlag(OPT_sycl_add_default_spec_consts_image,
588584
OPT_no_sycl_add_default_spec_consts_image, false) &&
589585
IsAOT)

clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def llvm_spirv_options_EQ : Joined<["--", "-"], "llvm-spirv-options=">,
172172
HelpText<"Options that will control llvm-spirv step">;
173173

174174
// Extra SYCL options to help generate sycl-post-link options that also depend
175-
// on target triple.
175+
// on the target triple.
176176
def sycl_remove_unused_external_funcs : Flag<["--", "-"], "sycl-remove-unused-external-funcs">,
177177
Flags<[WrapperOnlyOption, HelpHidden]>;
178178
def no_sycl_remove_unused_external_funcs : Flag<["--", "-"], "no-sycl-remove-unused-external-funcs">,

0 commit comments

Comments
 (0)