Author: Matt Arsenault Date: 2026-05-05T22:46:14Z New Revision: bc2253a74974ddf2d4df0ec417230bb39bcaaee8
URL: https://github.com/llvm/llvm-project/commit/bc2253a74974ddf2d4df0ec417230bb39bcaaee8 DIFF: https://github.com/llvm/llvm-project/commit/bc2253a74974ddf2d4df0ec417230bb39bcaaee8.diff LOG: clang: Add BoundArch argument to ComputeEffectiveClangTriple (#195955) This will eventually be used to adjust the amdgpu triple to use subarches. Added: Modified: clang/include/clang/Driver/ToolChain.h clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/Darwin.h clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/Fuchsia.h clang/lib/Driver/ToolChains/Linux.cpp clang/lib/Driver/ToolChains/Linux.h clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/MSVC.h Removed: ################################################################################ diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 8bda212312aee..25f5f83ad7b98 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -681,7 +681,7 @@ class ToolChain { /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking /// command line arguments into account. virtual std::string - ComputeLLVMTriple(const llvm::opt::ArgList &Args, + ComputeLLVMTriple(const llvm::opt::ArgList &Args, StringRef BoundArch = {}, types::ID InputType = types::TY_INVALID) const; /// ComputeEffectiveClangTriple - Return the Clang triple to use for this @@ -689,9 +689,10 @@ class ToolChain { /// example, on Darwin the -mmacos-version-min= command line argument (which /// sets the deployment target) determines the version in the triple passed to /// Clang. - virtual std::string ComputeEffectiveClangTriple( - const llvm::opt::ArgList &Args, - types::ID InputType = types::TY_INVALID) const; + virtual std::string + ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, + StringRef BoundArch = {}, + types::ID InputType = types::TY_INVALID) const; /// getDefaultObjCRuntime - Return the default Objective-C runtime /// for this platform. diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 4db80c0a16725..d2c6b46f1aa06 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6226,11 +6226,12 @@ InputInfoList Driver::BuildJobsForActionNoCache( const ArgList &Args = C.getArgsForToolChain(TC, BoundArch, A->getOffloadingDeviceKind()); if (InputInfos.size() != 1) { - EffectiveTriple = llvm::Triple(ToolTC.ComputeEffectiveClangTriple(Args)); + EffectiveTriple = + llvm::Triple(ToolTC.ComputeEffectiveClangTriple(Args, BoundArch)); } else { // Pass along the input type if it can be unambiguously determined. - EffectiveTriple = llvm::Triple( - ToolTC.ComputeEffectiveClangTriple(Args, InputInfos[0].getType())); + EffectiveTriple = llvm::Triple(ToolTC.ComputeEffectiveClangTriple( + Args, BoundArch, InputInfos[0].getType())); } RegisterEffectiveTriple TripleRAII(ToolTC, EffectiveTriple); diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 996c4ab217c23..98936b25ce650 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1352,6 +1352,7 @@ bool ToolChain::isThreadModelSupported(const StringRef Model) const { } std::string ToolChain::ComputeLLVMTriple(const ArgList &Args, + StringRef BoundArch, types::ID InputType) const { switch (getTriple().getArch()) { default: @@ -1405,8 +1406,9 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args, } std::string ToolChain::ComputeEffectiveClangTriple(const ArgList &Args, + StringRef BoundArch, types::ID InputType) const { - return ComputeLLVMTriple(Args, InputType); + return ComputeLLVMTriple(Args, BoundArch, InputType); } std::string ToolChain::computeSysRoot() const { diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 79b0544457650..232e6a4e574aa 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1247,8 +1247,9 @@ void Darwin::VerifyTripleForSDK(const llvm::opt::ArgList &Args, } std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args, + llvm::StringRef BoundArch, types::ID InputType) const { - llvm::Triple Triple(ComputeLLVMTriple(Args, InputType)); + llvm::Triple Triple(ComputeLLVMTriple(Args, BoundArch, InputType)); // If the target isn't initialized (e.g., an unknown Darwin platform, return // the default triple). Note: we intentionally do NOT call diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index 89177b0455aca..6d1da017d3df1 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -403,6 +403,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public AppleMachO { ~Darwin() override; std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, + llvm::StringRef BoundArch, types::ID InputType) const override; /// @name Darwin Specific Toolchain Implementation diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp index 55d41b25a05db..d4bc589ad4137 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -331,8 +331,9 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple, } std::string Fuchsia::ComputeEffectiveClangTriple(const ArgList &Args, + llvm::StringRef BoundArch, types::ID InputType) const { - llvm::Triple Triple(ComputeLLVMTriple(Args, InputType)); + llvm::Triple Triple(ComputeLLVMTriple(Args, BoundArch, InputType)); return Triple.str(); } diff --git a/clang/lib/Driver/ToolChains/Fuchsia.h b/clang/lib/Driver/ToolChains/Fuchsia.h index 619968f585024..eb4c8f560d3c0 100644 --- a/clang/lib/Driver/ToolChains/Fuchsia.h +++ b/clang/lib/Driver/ToolChains/Fuchsia.h @@ -81,6 +81,7 @@ class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain { } std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, + llvm::StringRef BoundArch, types::ID InputType) const override; SanitizerMask getSupportedSanitizers() const override; diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index a5acc943464d5..99bcae9bb9598 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -484,9 +484,10 @@ static void setPAuthABIInTriple(const Driver &D, const ArgList &Args, } std::string Linux::ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, + llvm::StringRef BoundArch, types::ID InputType) const { std::string TripleString = - Generic_ELF::ComputeEffectiveClangTriple(Args, InputType); + Generic_ELF::ComputeEffectiveClangTriple(Args, BoundArch, InputType); if (getTriple().isAArch64()) { llvm::Triple Triple(TripleString); setPAuthABIInTriple(getDriver(), Args, Triple); diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h index b4bdc1b1206b1..cc3f3cc21210f 100644 --- a/clang/lib/Driver/ToolChains/Linux.h +++ b/clang/lib/Driver/ToolChains/Linux.h @@ -55,7 +55,7 @@ class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF { void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; std::string ComputeEffectiveClangTriple( - const llvm::opt::ArgList &Args, + const llvm::opt::ArgList &Args, llvm::StringRef BoundArch = {}, types::ID InputType = types::TY_INVALID) const override; std::string computeSysRoot() const override; void diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index f57440855fce4..2ab954ff61414 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -819,9 +819,8 @@ VersionTuple MSVCToolChain::computeMSVCVersion(const Driver *D, return MSVT; } -std::string -MSVCToolChain::ComputeEffectiveClangTriple(const ArgList &Args, - types::ID InputType) const { +std::string MSVCToolChain::ComputeEffectiveClangTriple( + const ArgList &Args, llvm::StringRef BoundArch, types::ID InputType) const { // The MSVC version doesn't care about the architecture, even though it // may look at the triple internally. VersionTuple MSVT = computeMSVCVersion(/*D=*/nullptr, Args); @@ -830,7 +829,8 @@ MSVCToolChain::ComputeEffectiveClangTriple(const ArgList &Args, // For the rest of the triple, however, a computed architecture name may // be needed. - llvm::Triple Triple(ToolChain::ComputeEffectiveClangTriple(Args, InputType)); + llvm::Triple Triple( + ToolChain::ComputeEffectiveClangTriple(Args, BoundArch, InputType)); if (Triple.getEnvironment() == llvm::Triple::MSVC) { StringRef ObjFmt = Triple.getEnvironmentName().split('-').second; if (ObjFmt.empty()) diff --git a/clang/lib/Driver/ToolChains/MSVC.h b/clang/lib/Driver/ToolChains/MSVC.h index 80a6cbd9bc15b..c8e49963a472e 100644 --- a/clang/lib/Driver/ToolChains/MSVC.h +++ b/clang/lib/Driver/ToolChains/MSVC.h @@ -114,6 +114,7 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain { const llvm::opt::ArgList &Args) const override; std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, + llvm::StringRef BoundArch, types::ID InputType) const override; SanitizerMask getSupportedSanitizers() const override; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
