Skip to content

Commit

Permalink
[Driver] Avoid repeated ToolChain.getTriple() calls. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Mar 27, 2024
1 parent 70e8cf0 commit f18600c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,15 +758,15 @@ bool tools::isTLSDESCEnabled(const ToolChain &TC,
void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
ArgStringList &CmdArgs, const InputInfo &Output,
const InputInfo &Input, bool IsThinLTO) {
const bool IsOSAIX = ToolChain.getTriple().isOSAIX();
const bool IsAMDGCN = ToolChain.getTriple().isAMDGCN();
const llvm::Triple &Triple = ToolChain.getTriple();
const bool IsOSAIX = Triple.isOSAIX();
const bool IsAMDGCN = Triple.isAMDGCN();
const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
const Driver &D = ToolChain.getDriver();
const bool IsFatLTO = Args.hasArg(options::OPT_ffat_lto_objects);
const bool IsUnifiedLTO = Args.hasArg(options::OPT_funified_lto);
if (llvm::sys::path::filename(Linker) != "ld.lld" &&
llvm::sys::path::stem(Linker) != "ld.lld" &&
!ToolChain.getTriple().isOSOpenBSD()) {
llvm::sys::path::stem(Linker) != "ld.lld" && !Triple.isOSOpenBSD()) {
// Tell the linker to load the plugin. This has to come before
// AddLinkerInputs as gold requires -plugin and AIX ld requires -bplugin to
// come before any -plugin-opt/-bplugin_opt that -Wl might forward.
Expand Down Expand Up @@ -835,7 +835,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
// the plugin.

// Handle flags for selecting CPU variants.
std::string CPU = getCPUName(D, Args, ToolChain.getTriple());
std::string CPU = getCPUName(D, Args, Triple);
if (!CPU.empty())
CmdArgs.push_back(
Args.MakeArgString(Twine(PluginOptPrefix) + ExtraDash + "mcpu=" + CPU));
Expand Down Expand Up @@ -966,10 +966,9 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
bool HasRoptr = Args.hasFlag(options::OPT_mxcoff_roptr,
options::OPT_mno_xcoff_roptr, false);
StringRef OptStr = HasRoptr ? "-mxcoff-roptr" : "-mno-xcoff-roptr";

if (!IsOSAIX)
D.Diag(diag::err_drv_unsupported_opt_for_target)
<< OptStr << ToolChain.getTriple().str();
<< OptStr << Triple.str();

if (HasRoptr) {
// The data sections option is on by default on AIX. We only need to error
Expand Down Expand Up @@ -1032,7 +1031,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
}

if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
ToolChain.getTriple().hasDefaultEmulatedTLS())) {
Triple.hasDefaultEmulatedTLS())) {
CmdArgs.push_back(
Args.MakeArgString(Twine(PluginOptPrefix) + "-emulated-tls"));
}
Expand Down

0 comments on commit f18600c

Please sign in to comment.