r275895 - [Driver] Compute effective target triples once per job (NFCI)

Eric Christopher via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 19 15:38:50 PDT 2016


On Tue, Jul 19, 2016 at 3:24 PM Vedant Kumar <vsk at apple.com> wrote:

>
> > On Jul 19, 2016, at 3:02 PM, Eric Christopher <echristo at gmail.com>
> wrote:
> >
> > ... this is pretty crazy. I think that you needed to plumb the effective
> triple through everything means that it really needs to be owned somewhere
> else and cached.
> >
> > Can you rethink this? In general it doesn't make sense to have
> everything need this passed down.
>
> This came up during review.
>

I couldn't find a thread anywhere - and there's not one in the phab
revision.


>
> I did try to find a suitable place to cache the effective triple, but did
> not
> see one. I still don't, and am open to suggestions / willing to revert for
> more
> review if you'd like.
>
> Initially I thought it would be possible to cache the triple in the Tool or
> ToolChain, but that seems like it could break use-cases in which jobs are
> constructed from different threads.
>
>
Where do we do that? As far as I know we don't have a case where this
applies and I'd consider all of this infrastructure to be internal for any
external tools.


> Caching the triple in the Compilation seems like it would have have the
> same
> issue. I'm not sure how much of a problem this is in practice. We could try
> setting the effective triple in the Compilation with a RAII wrapper, e.g:
>
>   {
>     RegisterEffectiveTriple TripleRAII(C, EffectiveTriple);
>     T->ConstructJob(...);
>   } // Effective triple cleared from the Compilation.
>
> Let me know if you have alternate suggestions, and how you'd like to move
> forward.
>
>
Adding Justin here a bit since he's looked at it more recently, but my
general case would be to cache in the ToolChain. Anything that has problems
with that caching will need to be fixed to deal (either anything depending
on ToolChain in clang or external code).

-eric


> thanks,
> vedant
>
>
> >
> > Thanks!
> >
> > -eric
> >
> > On Mon, Jul 18, 2016 at 1:04 PM Vedant Kumar via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
> > Author: vedantk
> > Date: Mon Jul 18 14:56:38 2016
> > New Revision: 275895
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=275895&view=rev
> > Log:
> > [Driver] Compute effective target triples once per job (NFCI)
> >
> > Compute an effective target triple exactly once in ConstructJob(), and
> > then simply pass around references to it. This eliminates wasteful
> > re-computation of effective triples (e.g in getARMFloatABI()).
> >
> > Differential Revision: https://reviews.llvm.org/D22290
> >
> > Modified:
> >     cfe/trunk/docs/ReleaseNotes.rst
> >     cfe/trunk/include/clang/Driver/SanitizerArgs.h
> >     cfe/trunk/include/clang/Driver/Tool.h
> >     cfe/trunk/include/clang/Driver/ToolChain.h
> >     cfe/trunk/lib/Driver/Driver.cpp
> >     cfe/trunk/lib/Driver/SanitizerArgs.cpp
> >     cfe/trunk/lib/Driver/ToolChain.cpp
> >     cfe/trunk/lib/Driver/ToolChains.cpp
> >     cfe/trunk/lib/Driver/ToolChains.h
> >     cfe/trunk/lib/Driver/Tools.cpp
> >     cfe/trunk/lib/Driver/Tools.h
> >
> > Modified: cfe/trunk/docs/ReleaseNotes.rst
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/docs/ReleaseNotes.rst (original)
> > +++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul 18 14:56:38 2016
> > @@ -121,7 +121,8 @@ These are major API changes that have ha
> >  Clang. If upgrading an external codebase that uses Clang as a library,
> >  this section should help get you past the largest hurdles of upgrading.
> >
> > --  ...
> > +- Classes which inherit from ``driver::Tool`` must be updated to use
> effective
> > +  target triples when constructing jobs.
> >
> >  AST Matchers
> >  ------------
> >
> > Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
> > +++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Mon Jul 18 14:56:38
> 2016
> > @@ -16,6 +16,10 @@
> >  #include <string>
> >  #include <vector>
> >
> > +namespace llvm {
> > +class Triple;
> > +}
> > +
> >  namespace clang {
> >  namespace driver {
> >
> > @@ -66,7 +70,8 @@ class SanitizerArgs {
> >    bool requiresPIE() const;
> >    bool needsUnwindTables() const;
> >    bool linkCXXRuntimes() const { return LinkCXXRuntimes; }
> > -  void addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
> > +  void addArgs(const ToolChain &TC, const llvm::Triple &EffectiveTriple,
> > +               const llvm::opt::ArgList &Args,
> >                 llvm::opt::ArgStringList &CmdArgs, types::ID InputType)
> const;
> >  };
> >
> >
> > Modified: cfe/trunk/include/clang/Driver/Tool.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Tool.h?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/Driver/Tool.h (original)
> > +++ cfe/trunk/include/clang/Driver/Tool.h Mon Jul 18 14:56:38 2016
> > @@ -14,6 +14,7 @@
> >  #include "llvm/Support/Program.h"
> >
> >  namespace llvm {
> > +class Triple;
> >  namespace opt {
> >    class ArgList;
> >  }
> > @@ -127,6 +128,7 @@ public:
> >    virtual void ConstructJob(Compilation &C, const JobAction &JA,
> >                              const InputInfo &Output,
> >                              const InputInfoList &Inputs,
> > +                            const llvm::Triple &EffectiveTriple,
> >                              const llvm::opt::ArgList &TCArgs,
> >                              const char *LinkingOutput) const = 0;
> >  };
> >
> > Modified: cfe/trunk/include/clang/Driver/ToolChain.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/Driver/ToolChain.h (original)
> > +++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Jul 18 14:56:38 2016
> > @@ -260,11 +260,13 @@ public:
> >      return ToolChain::CST_Libstdcxx;
> >    }
> >
> > -  virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
> > +  virtual std::string getCompilerRT(const llvm::Triple &EffectiveTriple,
> > +                                    const llvm::opt::ArgList &Args,
> >                                      StringRef Component,
> >                                      bool Shared = false) const;
> >
> > -  const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
> > +  const char *getCompilerRTArgString(const llvm::Triple
> &EffectiveTriple,
> > +                                     const llvm::opt::ArgList &Args,
> >                                       StringRef Component,
> >                                       bool Shared = false) const;
> >    /// needsProfileRT - returns true if instrumentation profile is on.
> > @@ -410,7 +412,8 @@ public:
> >        const llvm::opt::ArgList &Args, llvm::opt::ArgStringList
> &CmdArgs) const;
> >    /// addProfileRTLibs - When -fprofile-instr-profile is specified, try
> to pass
> >    /// a suitable profile runtime library to the linker.
> > -  virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
> > +  virtual void addProfileRTLibs(const llvm::Triple &EffectiveTriple,
> > +                                const llvm::opt::ArgList &Args,
> >                                  llvm::opt::ArgStringList &CmdArgs)
> const;
> >
> >    /// \brief Add arguments to use system-specific CUDA includes.
> >
> > Modified: cfe/trunk/lib/Driver/Driver.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Driver/Driver.cpp (original)
> > +++ cfe/trunk/lib/Driver/Driver.cpp Mon Jul 18 14:56:38 2016
> > @@ -2256,7 +2256,21 @@ InputInfo Driver::BuildJobsForActionNoCa
> >
>  TC->getTriple().normalize()),
> >                         BaseInput);
> >
> > +  llvm::Triple EffectiveTriple;
> > +  const ArgList &Args = C.getArgsForToolChain(TC, BoundArch);
> > +  if (InputInfos.size() != 1) {
> > +    EffectiveTriple = llvm::Triple(
> > +        T->getToolChain().ComputeEffectiveClangTriple(Args));
> > +  } else {
> > +    // Pass along the input type if it can be unambiguously determined.
> > +    EffectiveTriple =
> > +        llvm::Triple(T->getToolChain().ComputeEffectiveClangTriple(
> > +            Args, InputInfos[0].getType()));
> > +  }
> > +
> >    if (CCCPrintBindings && !CCGenDiagnostics) {
> > +    // FIXME: We should be able to use the effective triple here, but
> doing so
> > +    // breaks some multi-arch tests.
> >      llvm::errs() << "# \"" << T->getToolChain().getTripleString() << '"'
> >                   << " - \"" << T->getName() << "\", inputs: [";
> >      for (unsigned i = 0, e = InputInfos.size(); i != e; ++i) {
> > @@ -2266,7 +2280,7 @@ InputInfo Driver::BuildJobsForActionNoCa
> >      }
> >      llvm::errs() << "], output: " << Result.getAsString() << "\n";
> >    } else {
> > -    T->ConstructJob(C, *JA, Result, InputInfos,
> > +    T->ConstructJob(C, *JA, Result, InputInfos, EffectiveTriple,
> >                      C.getArgsForToolChain(TC, BoundArch),
> LinkingOutput);
> >    }
> >    return Result;
> >
> > Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
> > +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon Jul 18 14:56:38 2016
> > @@ -602,7 +602,9 @@ static void addIncludeLinkerOption(const
> >    CmdArgs.push_back(Args.MakeArgString(LinkerOptionFlag));
> >  }
> >
> > -void SanitizerArgs::addArgs(const ToolChain &TC, const
> llvm::opt::ArgList &Args,
> > +void SanitizerArgs::addArgs(const ToolChain &TC,
> > +                            const llvm::Triple &EffectiveTriple,
> > +                            const llvm::opt::ArgList &Args,
> >                              llvm::opt::ArgStringList &CmdArgs,
> >                              types::ID InputType) const {
> >    // Translate available CoverageFeatures to corresponding clang-cc1
> flags.
> > @@ -626,21 +628,24 @@ void SanitizerArgs::addArgs(const ToolCh
> >      // Instruct the code generator to embed linker directives in the
> object file
> >      // that cause the required runtime libraries to be linked.
> >      CmdArgs.push_back(Args.MakeArgString(
> > -        "--dependent-lib=" + TC.getCompilerRT(Args,
> "ubsan_standalone")));
> > +        "--dependent-lib=" +
> > +        TC.getCompilerRT(EffectiveTriple, Args, "ubsan_standalone")));
> >      if (types::isCXX(InputType))
> >        CmdArgs.push_back(Args.MakeArgString(
> > -          "--dependent-lib=" + TC.getCompilerRT(Args,
> "ubsan_standalone_cxx")));
> > +          "--dependent-lib=" +
> > +          TC.getCompilerRT(EffectiveTriple, Args,
> "ubsan_standalone_cxx")));
> >    }
> >    if (TC.getTriple().isOSWindows() && needsStatsRt()) {
> > -    CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
> > -                                         TC.getCompilerRT(Args,
> "stats_client")));
> > +    CmdArgs.push_back(Args.MakeArgString(
> > +        "--dependent-lib=" +
> > +        TC.getCompilerRT(EffectiveTriple, Args, "stats_client")));
> >
> >      // The main executable must export the stats runtime.
> >      // FIXME: Only exporting from the main executable (e.g. based on
> whether the
> >      // translation unit defines main()) would save a little space, but
> having
> >      // multiple copies of the runtime shouldn't hurt.
> > -    CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
> > -                                         TC.getCompilerRT(Args,
> "stats")));
> > +    CmdArgs.push_back(Args.MakeArgString(
> > +        "--dependent-lib=" + TC.getCompilerRT(EffectiveTriple, Args,
> "stats")));
> >      addIncludeLinkerOption(TC, Args, CmdArgs,
> "__sanitizer_stats_register");
> >    }
> >
> >
> > Modified: cfe/trunk/lib/Driver/ToolChain.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Driver/ToolChain.cpp (original)
> > +++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Jul 18 14:56:38 2016
> > @@ -267,46 +267,52 @@ Tool *ToolChain::getTool(Action::ActionC
> >    llvm_unreachable("Invalid tool kind.");
> >  }
> >
> > -static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
> > -                                             const ArgList &Args) {
> > -  const llvm::Triple &Triple = TC.getTriple();
> > -  bool IsWindows = Triple.isOSWindows();
> > +static StringRef
> > +getArchNameForCompilerRTLib(const ToolChain &TC,
> > +                            const llvm::Triple &EffectiveTriple,
> > +                            const ArgList &Args) {
> > +  bool IsWindows = EffectiveTriple.isOSWindows();
> >
> > -  if (Triple.isWindowsMSVCEnvironment() && TC.getArch() ==
> llvm::Triple::x86)
> > +  if (EffectiveTriple.isWindowsMSVCEnvironment() &&
> > +      TC.getArch() == llvm::Triple::x86)
> >      return "i386";
> >
> >    if (TC.getArch() == llvm::Triple::arm || TC.getArch() ==
> llvm::Triple::armeb)
> > -    return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard &&
> !IsWindows)
> > +    return (arm::getARMFloatABI(TC, EffectiveTriple, Args) ==
> > +                arm::FloatABI::Hard &&
> > +            !IsWindows)
> >                 ? "armhf"
> >                 : "arm";
> >
> >    return TC.getArchName();
> >  }
> >
> > -std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef
> Component,
> > +std::string ToolChain::getCompilerRT(const llvm::Triple
> &EffectiveTriple,
> > +                                     const ArgList &Args, StringRef
> Component,
> >                                       bool Shared) const {
> > -  const llvm::Triple &TT = getTriple();
> > -  const char *Env = TT.isAndroid() ? "-android" : "";
> > -  bool IsITANMSVCWindows =
> > -      TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
> > +  const char *Env = EffectiveTriple.isAndroid() ? "-android" : "";
> > +  bool IsITANMSVCWindows = EffectiveTriple.isWindowsMSVCEnvironment() ||
> > +
>  EffectiveTriple.isWindowsItaniumEnvironment();
> >
> > -  StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
> > +  StringRef Arch = getArchNameForCompilerRTLib(*this, EffectiveTriple,
> Args);
> >    const char *Prefix = IsITANMSVCWindows ? "" : "lib";
> > -  const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
> > +  const char *Suffix = Shared ? (EffectiveTriple.isOSWindows() ? ".dll"
> : ".so")
> >                                : (IsITANMSVCWindows ? ".lib" : ".a");
> >
> >    SmallString<128> Path(getDriver().ResourceDir);
> > -  StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();
> > +  StringRef OSLibName = EffectiveTriple.isOSFreeBSD() ? "freebsd" :
> getOS();
> >    llvm::sys::path::append(Path, "lib", OSLibName);
> >    llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component
> + "-" +
> >                                      Arch + Env + Suffix);
> >    return Path.str();
> >  }
> >
> > -const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList
> &Args,
> > -                                              StringRef Component,
> > -                                              bool Shared) const {
> > -  return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
> > +const char *
> > +ToolChain::getCompilerRTArgString(const llvm::Triple &EffectiveTriple,
> > +                                  const llvm::opt::ArgList &Args,
> > +                                  StringRef Component, bool Shared)
> const {
> > +  return Args.MakeArgString(
> > +      getCompilerRT(EffectiveTriple, Args, Component, Shared));
> >  }
> >
> >  bool ToolChain::needsProfileRT(const ArgList &Args) {
> > @@ -517,11 +523,13 @@ void ToolChain::addClangTargetOptions(co
> >
> >  void ToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {}
> >
> > -void ToolChain::addProfileRTLibs(const llvm::opt::ArgList &Args,
> > +void ToolChain::addProfileRTLibs(const llvm::Triple &EffectiveTriple,
> > +                                 const llvm::opt::ArgList &Args,
> >                                   llvm::opt::ArgStringList &CmdArgs)
> const {
> > -  if (!needsProfileRT(Args)) return;
> > +  if (!needsProfileRT(Args))
> > +    return;
> >
> > -  CmdArgs.push_back(getCompilerRTArgString(Args, "profile"));
> > +  CmdArgs.push_back(getCompilerRTArgString(EffectiveTriple, Args,
> "profile"));
> >  }
> >
> >  ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
> >
> > Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> > +++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Jul 18 14:56:38 2016
> > @@ -380,13 +380,16 @@ StringRef Darwin::getOSLibraryNameSuffix
> >    llvm_unreachable("Unsupported platform");
> >  }
> >
> > -void Darwin::addProfileRTLibs(const ArgList &Args,
> > +void Darwin::addProfileRTLibs(const llvm::Triple &EffectiveTriple,
> > +                              const ArgList &Args,
> >                                ArgStringList &CmdArgs) const {
> > -  if (!needsProfileRT(Args)) return;
> > +  if (!needsProfileRT(Args))
> > +    return;
> >
> > -  AddLinkRuntimeLib(Args, CmdArgs, (Twine("libclang_rt.profile_") +
> > -       getOSLibraryNameSuffix() + ".a").str(),
> > -                    /*AlwaysLink*/ true);
> > +  AddLinkRuntimeLib(
> > +      Args, CmdArgs,
> > +      (Twine("libclang_rt.profile_") + getOSLibraryNameSuffix() +
> ".a").str(),
> > +      /*AlwaysLink*/ true);
> >  }
> >
> >  void DarwinClang::AddLinkSanitizerLibArgs(const ArgList &Args,
> > @@ -400,7 +403,8 @@ void DarwinClang::AddLinkSanitizerLibArg
> >        /*AddRPath*/ true);
> >  }
> >
> > -void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
> > +void DarwinClang::AddLinkRuntimeLibArgs(const llvm::Triple
> &EffectiveTriple,
> > +                                        const ArgList &Args,
> >                                          ArgStringList &CmdArgs) const {
> >    // Darwin only supports the compiler-rt based runtime libraries.
> >    switch (GetRuntimeLibType(Args)) {
> > @@ -1012,16 +1016,17 @@ DerivedArgList *MachO::TranslateArgs(con
> >    return DAL;
> >  }
> >
> > -void MachO::AddLinkRuntimeLibArgs(const ArgList &Args,
> > +void MachO::AddLinkRuntimeLibArgs(const llvm::Triple &EffectiveTriple,
> > +                                  const ArgList &Args,
> >                                    ArgStringList &CmdArgs) const {
> >    // Embedded targets are simple at the moment, not supporting
> sanitizers and
> >    // with different libraries for each member of the product { static,
> PIC } x
> >    // { hard-float, soft-float }
> >    llvm::SmallString<32> CompilerRT = StringRef("libclang_rt.");
> > -  CompilerRT +=
> > -      (tools::arm::getARMFloatABI(*this, Args) ==
> tools::arm::FloatABI::Hard)
> > -          ? "hard"
> > -          : "soft";
> > +  CompilerRT += (tools::arm::getARMFloatABI(*this, EffectiveTriple,
> Args) ==
> > +                 tools::arm::FloatABI::Hard)
> > +                    ? "hard"
> > +                    : "soft";
> >    CompilerRT += Args.hasArg(options::OPT_fPIC) ? "_pic.a" : "_static.a";
> >
> >    AddLinkRuntimeLib(Args, CmdArgs, CompilerRT, false, true);
> > @@ -2858,9 +2863,10 @@ void MipsLLVMToolChain::AddCXXStdlibLibA
> >    CmdArgs.push_back("-lunwind");
> >  }
> >
> > -std::string MipsLLVMToolChain::getCompilerRT(const ArgList &Args,
> > -                                             StringRef Component,
> > -                                             bool Shared) const {
> > +std::string
> > +MipsLLVMToolChain::getCompilerRT(const llvm::Triple &EffectiveTriple,
> > +                                 const ArgList &Args, StringRef
> Component,
> > +                                 bool Shared) const {
> >    SmallString<128> Path(getDriver().ResourceDir);
> >    llvm::sys::path::append(Path, SelectedMultilib.osSuffix(), "lib" +
> LibSuffix,
> >                            getOS());
> > @@ -4237,9 +4243,9 @@ std::string Linux::getDynamicLinker(cons
> >    case llvm::Triple::thumb:
> >    case llvm::Triple::armeb:
> >    case llvm::Triple::thumbeb: {
> > -    const bool HF =
> > -        Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
> > -        tools::arm::getARMFloatABI(*this, Args) ==
> tools::arm::FloatABI::Hard;
> > +    const bool HF = Triple.getEnvironment() == llvm::Triple::GNUEABIHF
> ||
> > +                    tools::arm::getARMFloatABI(*this, Triple, Args) ==
> > +                        tools::arm::FloatABI::Hard;
> >
> >      LibDir = "lib";
> >      Loader = HF ? "ld-linux-armhf.so.3" : "ld-linux.so.3";
> > @@ -4631,16 +4637,18 @@ SanitizerMask Linux::getSupportedSanitiz
> >    return Res;
> >  }
> >
> > -void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
> > +void Linux::addProfileRTLibs(const llvm::Triple &EffectiveTriple,
> > +                             const llvm::opt::ArgList &Args,
> >                               llvm::opt::ArgStringList &CmdArgs) const {
> > -  if (!needsProfileRT(Args)) return;
> > +  if (!needsProfileRT(Args))
> > +    return;
> >
> >    // Add linker option -u__llvm_runtime_variable to cause runtime
> >    // initialization module to be linked in.
> >    if (!Args.hasArg(options::OPT_coverage))
> >      CmdArgs.push_back(Args.MakeArgString(
> >          Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
> > -  ToolChain::addProfileRTLibs(Args, CmdArgs);
> > +  ToolChain::addProfileRTLibs(EffectiveTriple, Args, CmdArgs);
> >  }
> >
> >  /// DragonFly - DragonFly tool chain which can call as(1) and ld(1)
> directly.
> >
> > Modified: cfe/trunk/lib/Driver/ToolChains.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Driver/ToolChains.h (original)
> > +++ cfe/trunk/lib/Driver/ToolChains.h Mon Jul 18 14:56:38 2016
> > @@ -279,7 +279,8 @@ public:
> >                                llvm::opt::ArgStringList &CmdArgs) const
> {}
> >
> >    /// Add the linker arguments to link the compiler runtime library.
> > -  virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
> > +  virtual void AddLinkRuntimeLibArgs(const llvm::Triple
> &EffectiveTriple,
> > +                                     const llvm::opt::ArgList &Args,
> >                                       llvm::opt::ArgStringList &CmdArgs)
> const;
> >
> >    virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
> > @@ -303,7 +304,8 @@ public:
> >
> >    /// Add any profiling runtime libraries that are needed. This is
> essentially a
> >    /// MachO specific version of addProfileRT in Tools.cpp.
> > -  void addProfileRTLibs(const llvm::opt::ArgList &Args,
> > +  void addProfileRTLibs(const llvm::Triple &EffectiveTriple,
> > +                        const llvm::opt::ArgList &Args,
> >                          llvm::opt::ArgStringList &CmdArgs) const
> override {
> >      // There aren't any profiling libs for embedded targets currently.
> >    }
> > @@ -417,7 +419,8 @@ public:
> >              !isTargetWatchOS());
> >    }
> >
> > -  void addProfileRTLibs(const llvm::opt::ArgList &Args,
> > +  void addProfileRTLibs(const llvm::Triple &EffectiveTriple,
> > +                        const llvm::opt::ArgList &Args,
> >                          llvm::opt::ArgStringList &CmdArgs) const
> override;
> >
> >  protected:
> > @@ -572,7 +575,8 @@ public:
> >    /// @name Apple ToolChain Implementation
> >    /// {
> >
> > -  void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
> > +  void AddLinkRuntimeLibArgs(const llvm::Triple &EffectiveTriple,
> > +                             const llvm::opt::ArgList &Args,
> >                               llvm::opt::ArgStringList &CmdArgs) const
> override;
> >
> >    void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
> > @@ -838,7 +842,8 @@ public:
> >                             llvm::opt::ArgStringList &CC1Args) const
> override;
> >    bool isPIEDefault() const override;
> >    SanitizerMask getSupportedSanitizers() const override;
> > -  void addProfileRTLibs(const llvm::opt::ArgList &Args,
> > +  void addProfileRTLibs(const llvm::Triple &EffectiveTriple,
> > +                        const llvm::opt::ArgList &Args,
> >                          llvm::opt::ArgStringList &CmdArgs) const
> override;
> >    virtual std::string computeSysRoot() const;
> >
> > @@ -902,7 +907,8 @@ public:
> >    void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
> >                             llvm::opt::ArgStringList &CmdArgs) const
> override;
> >
> > -  std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef
> Component,
> > +  std::string getCompilerRT(const llvm::Triple &EffectiveTriple,
> > +                            const llvm::opt::ArgList &Args, StringRef
> Component,
> >                              bool Shared = false) const override;
> >
> >    std::string computeSysRoot() const override;
> >
> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275895&r1=275894&r2=275895&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> > +++ cfe/trunk/lib/Driver/Tools.cpp Mon Jul 18 14:56:38 2016
> > @@ -771,10 +771,11 @@ static bool useAAPCSForMachO(const llvm:
> >
> >  // Select the float ABI as determined by -msoft-float, -mhard-float, and
> >  // -mfloat-abi=.
> > -arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList
> &Args) {
> > +arm::FloatABI arm::getARMFloatABI(const ToolChain &TC,
> > +                                  const llvm::Triple &EffectiveTriple,
> > +                                  const ArgList &Args) {
> >    const Driver &D = TC.getDriver();
> > -  const llvm::Triple Triple(TC.ComputeEffectiveClangTriple(Args));
> > -  auto SubArch = getARMSubArchVersionNumber(Triple);
> > +  auto SubArch = getARMSubArchVersionNumber(EffectiveTriple);
> >    arm::FloatABI ABI = FloatABI::Invalid;
> >    if (Arg *A =
> >            Args.getLastArg(options::OPT_msoft_float,
> options::OPT_mhard_float,
> > @@ -797,23 +798,23 @@ arm::FloatABI arm::getARMFloatABI(const
> >
> >      // It is incorrect to select hard float ABI on MachO platforms if
> the ABI is
> >      // "apcs-gnu".
> > -    if (Triple.isOSBinFormatMachO() && !useAAPCSForMachO(Triple) &&
> > -        ABI == FloatABI::Hard) {
> > -      D.Diag(diag::err_drv_unsupported_opt_for_target) <<
> A->getAsString(Args)
> > -                                                       <<
> Triple.getArchName();
> > +    if (EffectiveTriple.isOSBinFormatMachO() &&
> > +        !useAAPCSForMachO(EffectiveTriple) && ABI == FloatABI::Hard) {
> > +      D.Diag(diag::err_drv_unsupported_opt_for_target)
> > +          << A->getAsString(Args) << EffectiveTriple.getArchName();
> >      }
> >    }
> >
> >    // If unspecified, choose the default based on the platform.
> >    if (ABI == FloatABI::Invalid) {
> > -    switch (Triple.getOS()) {
> > +    switch (EffectiveTriple.getOS()) {
> >      case llvm::Triple::Darwin:
> >      case llvm::Triple::MacOSX:
> >      case llvm::Triple::IOS:
> >      case llvm::Triple::TvOS: {
> >        // Darwin defaults to "softfp" for v6 and v7.
> >        ABI = (SubArch == 6 || SubArch == 7) ? FloatABI::SoftFP :
> FloatABI::Soft;
> > -      ABI = Triple.isWatchABI() ? FloatABI::Hard : ABI;
> > +      ABI = EffectiveTriple.isWatchABI() ? FloatABI::Hard : ABI;
> >        break;
> >      }
> >      case llvm::Triple::WatchOS:
> > @@ -826,7 +827,7 @@ arm::FloatABI arm::getARMFloatABI(const
> >        break;
> >
> >      case llvm::Triple::FreeBSD:
> > -      switch (Triple.getEnvironment()) {
> > +      switch (EffectiveTriple.getEnvironment()) {
> >        case llvm::Triple::GNUEABIHF:
> >          ABI = FloatABI::Hard;
> >          break;
> > @@ -838,7 +839,7 @@ arm::FloatABI arm::getARMFloatABI(const
> >        break;
> >
> >      default:
> > -      switch (Triple.getEnvironment()) {
> > +      switch (EffectiveTriple.getEnvironment()) {
> >        case llvm::Triple::GNUEABIHF:
> >        case llvm::Triple::MuslEABIHF:
> >        case llvm::Triple::EABIHF:
> > @@ -855,14 +856,14 @@ arm::FloatABI arm::getARMFloatABI(const
> >          break;
> >        default:
> >          // Assume "soft", but warn the user we are guessing.
> > -        if (Triple.isOSBinFormatMachO() &&
> > -            Triple.getSubArch() == llvm::Triple::ARMSubArch_v7em)
> > +        if (EffectiveTriple.isOSBinFormatMachO() &&
> > +            EffectiveTriple.getSubArch() ==
> llvm::Triple::ARMSubArch_v7em)
> >            ABI = FloatABI::Hard;
> >          else
> >            ABI = FloatABI::Soft;
> >
> > -        if (Triple.getOS() != llvm::Triple::UnknownOS ||
> > -            !Triple.isOSBinFormatMachO())
> > +        if (EffectiveTriple.getOS() != llvm::Triple::UnknownOS ||
> > +            !EffectiveTriple.isOSBinFormatMachO())
> >            D.Diag(diag::warn_drv_assuming_mfloat_abi_is) << "soft";
> >          break;
> >        }
> > @@ -882,7 +883,7 @@ static void getARMTargetFeatures(const T
> >
> >    bool KernelOrKext =
> >        Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
> > -  arm::FloatABI ABI = arm::getARMFloatABI(TC, Args);
> > +  arm::FloatABI ABI = arm::getARMFloatABI(TC, Triple, Args);
> >    const Arg *WaCPU = nullptr, *WaFPU = nullptr;
> >    const Arg *WaHDiv = nullptr, *WaArch = nullptr;
> >
> > @@ -1011,7 +1012,7 @@ static void getARMTargetFeatures(const T
> >        Features.push_back("+long-calls");
> >    } else if (KernelOrKext && (!Triple.isiOS() ||
> Triple.isOSVersionLT(6)) &&
> >               !Triple.isWatchOS()) {
> > -      Features.push_back("+long-calls");
> > +    Features.push_back("+long-calls");
> >    }
> >
> >    // Kernel code has more strict alignment requirements.
> > @@ -1025,7 +1026,8 @@ static void getARMTargetFeatures(const T
> >          D.Diag(diag::err_target_unsupported_unaligned) << "v6m";
> >        // v8M Baseline follows on from v6M, so doesn't support unaligned
> memory
> >        // access either.
> > -      else if (Triple.getSubArch() ==
> llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
> > +      else if (Triple.getSubArch() ==
> > +               llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
> >          D.Diag(diag::err_target_unsupported_unaligned) << "v8m.base";
> >      } else
> >        Features.push_back("+strict-align");
> > @@ -1111,7 +1113,7 @@ void Clang::AddARMTargetArgs(const llvm:
> >    CmdArgs.push_back(ABIName);
> >
> >    // Determine floating point ABI from the options & target defaults.
> > -  arm::FloatABI ABI = arm::getARMFloatABI(getToolChain(), Args);
> > +  arm::FloatABI ABI = arm::getARMFloatABI(getToolChain(), Triple, Args);
> >    if (ABI == arm::FloatABI::Soft) {
> >      // Floating point operations and argument passing are soft.
> >      // FIXME: This changes CPP defines, we need -target-soft-float.
> > @@ -1172,11 +1174,9 @@ static std::string getAArch64TargetCPU(c
> >    return "generic";
> >  }
> >
> > -void Clang::AddAArch64TargetArgs(const ArgList &Args,
> > +void Clang::AddAArch64TargetArgs(const llvm::Triple &EffectiveTriple,
> > +                                 const ArgList &Args,
> >                                   ArgStringList &CmdArgs) const {
> > -  std::string TripleStr =
> getToolChain().ComputeEffectiveClangTriple(Args);
> > -  llvm::Triple Triple(TripleStr);
> > -
> >    if (!Args.hasFlag(options::OPT_mred_zone, options::OPT_mno_red_zone,
> true) ||
> >        Args.hasArg(options::OPT_mkernel) ||
> >        Args.hasArg(options::OPT_fapple_kext))
> > @@ -1189,7 +1189,7 @@ void Clang::AddAArch64TargetArgs(const A
> >    const char *ABIName = nullptr;
> >    if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
> >      ABIName = A->getValue();
> > -  else if (Triple.isOSDarwin())
> > +  else if (EffectiveTriple.isOSDarwin())
> >      ABIName = "darwinpcs";
> >    else
> >      ABIName = "aapcs";
> > @@ -1204,7 +1204,7 @@ void Clang::AddAArch64TargetArgs(const A
> >        CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=1");
> >      else
> >        CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=0");
> > -  } else if (Triple.isAndroid()) {
> > +  } else if (EffectiveTriple.isAndroid()) {
> >      // Enabled A53 errata (835769) workaround by default on android
> >      CmdArgs.push_back("-backend-option");
> >      CmdArgs.push_back("-aarch64-fix-cortex-a53-835769=1");
> > @@ -2999,9 +2999,10 @@ static void CollectArgsForIntegratedAsse
> >  // This adds the static libclang_rt.builtins-arch.a directly to the
> command line
> >  // FIXME: Make sure we can also emit shared objects if they're requested
> >  // and available, check for possible errors, etc.
> > -static void addClangRT(const ToolChain &TC, const ArgList &Args,
> > -                       ArgStringList &CmdArgs) {
> > -  CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
> > +static void addClangRT(const ToolChain &TC, const llvm::Triple
> &EffectiveTriple,
> > +                       const ArgList &Args, ArgStringList &CmdArgs) {
> > +  CmdArgs.push_back(
> > +      TC.getCompilerRTArgString(EffectiveTriple, Args, "builtins"));
> >  }
> >
> >  namespace {
> > @@ -3075,22 +3076,27 @@ static void addOpenMPRuntime(ArgStringLi
> >    }
> >  }
> >
> > -static void addSanitizerRuntime(const ToolChain &TC, const ArgList
> &Args,
> > -                                ArgStringList &CmdArgs, StringRef
> Sanitizer,
> > -                                bool IsShared, bool IsWhole) {
> > +static void addSanitizerRuntime(const ToolChain &TC,
> > +                                const llvm::Triple &EffectiveTriple,
> > +                                const ArgList &Args, ArgStringList
> &CmdArgs,
> > +                                StringRef Sanitizer, bool IsShared,
> > +                                bool IsWhole) {
> >    // Wrap any static runtimes that must be forced into executable in
> >    // whole-archive.
> >    if (IsWhole) CmdArgs.push_back("-whole-archive");
> > -  CmdArgs.push_back(TC.getCompilerRTArgString(Args, Sanitizer,
> IsShared));
> > -  if (IsWhole) CmdArgs.push_back("-no-whole-archive");
> > +  CmdArgs.push_back(
> > +      TC.getCompilerRTArgString(EffectiveTriple, Args, Sanitizer,
> IsShared));
> > +  if (IsWhole)
> > +    CmdArgs.push_back("-no-whole-archive");
> >  }
> >
> >  // Tries to use a file with the list of dynamic symbols that need to be
> exported
> >  // from the runtime library. Returns true if the file was found.
> > -static bool addSanitizerDynamicList(const ToolChain &TC, const ArgList
> &Args,
> > -                                    ArgStringList &CmdArgs,
> > +static bool addSanitizerDynamicList(const ToolChain &TC,
> > +                                    const llvm::Triple &EffectiveTriple,
> > +                                    const ArgList &Args, ArgStringList
> &CmdArgs,
> >                                      StringRef Sanitizer) {
> > -  SmallString<128> SanRT(TC.getCompilerRT(Args, Sanitizer));
> > +  SmallString<128> SanRT(TC.getCompilerRT(EffectiveTriple, Args,
> Sanitizer));
> >    if (llvm::sys::fs::exists(SanRT + ".syms")) {
> >      CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT +
> ".syms"));
> >      return true;
> > @@ -3179,25 +3185,28 @@ collectSanitizerRuntimes(const ToolChain
> >
> >  // Should be called before we add system libraries (C++ ABI,
> libstdc++/libc++,
> >  // C runtime, etc). Returns true if sanitizer system deps need to be
> linked in.
> > -static bool addSanitizerRuntimes(const ToolChain &TC, const ArgList
> &Args,
> > -                                 ArgStringList &CmdArgs) {
> > +static bool addSanitizerRuntimes(const ToolChain &TC,
> > +                                 const llvm::Triple &EffectiveTriple,
> > +                                 const ArgList &Args, ArgStringList
> &CmdArgs) {
> >    SmallVector<StringRef, 4> SharedRuntimes, StaticRuntimes,
> >        NonWholeStaticRuntimes, HelperStaticRuntimes, RequiredSymbols;
> >    collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
> >                             NonWholeStaticRuntimes, HelperStaticRuntimes,
> >                             RequiredSymbols);
> >    for (auto RT : SharedRuntimes)
> > -    addSanitizerRuntime(TC, Args, CmdArgs, RT, true, false);
> > +    addSanitizerRuntime(TC, EffectiveTriple, Args, CmdArgs, RT, true,
> false);
> >    for (auto RT : HelperStaticRuntimes)
> > -    addSanitizerRuntime(TC, Args, CmdArgs, RT, false, true);
> > +    addSanitizerRuntime(TC, EffectiveTriple, Args, CmdArgs, RT, false,
> true);
> >    bool AddExportDynamic = false;
> >    for (auto RT : StaticRuntimes) {
> > -    addSanitizerRuntime(TC, Args, CmdArgs, RT, false, true);
> > -    AddExportDynamic |= !addSanitizerDynamicList(TC, Args, CmdArgs, RT);
> > +    addSanitizerRuntime(TC, EffectiveTriple, Args, CmdArgs, RT, false,
> true);
> > +    AddExportDynamic |=
> > +        !addSanitizerDynamicList(TC, EffectiveTriple, Args, CmdArgs,
> RT);
> >    }
> >    for (auto RT : NonWholeStaticRuntimes) {
> > -    addSanitizerRuntime(TC, Args, CmdArgs, RT, false, false);
> > -    AddExportDynamic |= !addSanitizerDynamicList(TC, Args, CmdArgs, RT);
> > +    addSanitizerRuntime(TC, EffectiveTriple, Args, CmdArgs, RT, false,
> false);
> > +    AddExportDynamic |=
> > +        !addSanitizerDynamicList(TC, EffectiveTriple, Args, CmdArgs,
> RT);
> >    }
> >    for (auto S : RequiredSymbols) {
> >      CmdArgs.push_back("-u");
> > @@ -3210,12 +3219,14 @@ static bool addSanitizerRuntimes(const T
> >    return !StaticRuntimes.empty();
> >  }
> >
> > -static bool addXRayRuntime(const ToolChain &TC, const ArgList &Args,
> > -                           ArgStringList &CmdArgs) {
> > +static bool addXRayRuntime(const ToolChain &TC,
> > +                           const llvm::Triple &EffectiveTriple,
> > +                           const ArgList &Args, ArgStringList &CmdArgs)
> {
> >    if (Args.hasFlag(options::OPT_fxray_instrument,
> >                     options::OPT_fnoxray_instrument, false)) {
> >      CmdArgs.push_back("-whole-archive");
> > -    CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
> > +    CmdArgs.push_back(
> > +        TC.getCompilerRTArgString(EffectiveTriple, Args, "xray",
> false));
> >      CmdArgs.push_back("-no-whole-archive");
> >      return true;
> >    }
> > @@ -3825,9 +3836,9 @@ static void AddAssemblerKPIC(const ToolC
> >
> >  void Clang::ConstructJob(Compilation &C, const JobAction &JA,
> >                           const InputInfo &Output, const InputInfoList
> &Inputs,
> > +                         const llvm::Triple &EffectiveTriple,
> >                           const ArgList &Args, const char
> *LinkingOutput) const {
> > -  std::string TripleStr =
> getToolChain().ComputeEffectiveClangTriple(Args);
> > -  const llvm::Triple Triple(TripleStr);
> > +  std::string TripleStr = EffectiveTriple.str();
> >
> >    bool KernelOrKext =
> >        Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
> > @@ -3880,13 +3891,14 @@ void Clang::ConstructJob(Compilation &C,
> >      CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
> >    }
> >
> > -  if (Triple.isOSWindows() && (Triple.getArch() == llvm::Triple::arm ||
> > -                               Triple.getArch() ==
> llvm::Triple::thumb)) {
> > -    unsigned Offset = Triple.getArch() == llvm::Triple::arm ? 4 : 6;
> > +  if (EffectiveTriple.isOSWindows() &&
> > +      (EffectiveTriple.getArch() == llvm::Triple::arm ||
> > +       EffectiveTriple.getArch() == llvm::Triple::thumb)) {
> > +    unsigned Offset = EffectiveTriple.getArch() == llvm::Triple::arm ?
> 4 : 6;
> >      unsigned Version;
> > -    Triple.getArchName().substr(Offset).getAsInteger(10, Version);
> > +    EffectiveTriple.getArchName().substr(Offset).getAsInteger(10,
> Version);
> >      if (Version < 7)
> > -      D.Diag(diag::err_target_unsupported_arch) << Triple.getArchName()
> > +      D.Diag(diag::err_target_unsupported_arch) <<
> EffectiveTriple.getArchName()
> >                                                  << TripleStr;
> >    }
> >
> > @@ -4088,7 +4100,7 @@ void Clang::ConstructJob(Compilation &C,
> >    unsigned PICLevel;
> >    bool IsPIE;
> >    std::tie(RelocationModel, PICLevel, IsPIE) =
> > -      ParsePICArgs(getToolChain(), Triple, Args);
> > +      ParsePICArgs(getToolChain(), EffectiveTriple, Args);
> >
> >    const char *RMName = RelocationModelName(RelocationModel);
> >    if (RMName) {
> > @@ -4187,8 +4199,7 @@ void Clang::ConstructJob(Compilation &C,
> >                     false))
> >      CmdArgs.push_back("-fstrict-enums");
> >    if (Args.hasFlag(options::OPT_fstrict_vtable_pointers,
> > -                   options::OPT_fno_strict_vtable_pointers,
> > -                   false))
> > +                   options::OPT_fno_strict_vtable_pointers, false))
> >      CmdArgs.push_back("-fstrict-vtable-pointers");
> >    if (!Args.hasFlag(options::OPT_foptimize_sibling_calls,
> >                      options::OPT_fno_optimize_sibling_calls))
> > @@ -4403,7 +4414,7 @@ void Clang::ConstructJob(Compilation &C,
> >    }
> >
> >    // Add the target cpu
> > -  std::string CPU = getCPUName(Args, Triple, /*FromAs*/ false);
> > +  std::string CPU = getCPUName(Args, EffectiveTriple, /*FromAs*/ false);
> >    if (!CPU.empty()) {
> >      CmdArgs.push_back("-target-cpu");
> >      CmdArgs.push_back(Args.MakeArgString(CPU));
> > @@ -4415,7 +4426,7 @@ void Clang::ConstructJob(Compilation &C,
> >    }
> >
> >    // Add the target features
> > -  getTargetFeatures(getToolChain(), Triple, Args, CmdArgs, false);
> > +  getTargetFeatures(getToolChain(), EffectiveTriple, Args, CmdArgs,
> false);
> >
> >    // Add target specific flags.
> >    switch (getToolChain().getArch()) {
> > @@ -4427,12 +4438,12 @@ void Clang::ConstructJob(Compilation &C,
> >    case llvm::Triple::thumb:
> >    case llvm::Triple::thumbeb:
> >      // Use the effective triple, which takes into account the
> deployment target.
> > -    AddARMTargetArgs(Triple, Args, CmdArgs, KernelOrKext);
> > +    AddARMTargetArgs(EffectiveTriple, Args, CmdArgs, KernelOrKext);
> >      break;
> >
> >    case llvm::Triple::aarch64:
> >    case llvm::Triple::aarch64_be:
> > -    AddAArch64TargetArgs(Args, CmdArgs);
> > +    AddAArch64TargetArgs(EffectiveTriple, Args, CmdArgs);
> >      break;
> >
> >    case llvm::Triple::mips:
> > @@ -4553,8 +4564,8 @@ void Clang::ConstructJob(Compilation &C,
> >    }
> >
> >    // If a debugger tuning argument appeared, remember it.
> > -  if (Arg *A = Args.getLastArg(options::OPT_gTune_Group,
> > -                               options::OPT_ggdbN_Group)) {
> > +  if (Arg *A =
> > +          Args.getLastArg(options::OPT_gTune_Group,
> options::OPT_ggdbN_Group)) {
> >      if (A->getOption().matches(options::OPT_glldb))
> >        DebuggerTuning = llvm::DebuggerKind::LLDB;
> >      else if (A->getOption().matches(options::OPT_gsce))
> > @@ -4583,7 +4594,7 @@ void Clang::ConstructJob(Compilation &C,
> >
> >    // PS4 defaults to no column info
> >    if (Args.hasFlag(options::OPT_gcolumn_info,
> options::OPT_gno_column_info,
> > -                   /*Default=*/ !IsPS4CPU))
> > +                   /*Default=*/!IsPS4CPU))
> >      CmdArgs.push_back("-dwarf-column-info");
> >
> >    // FIXME: Move backend command line options to the module.
> > @@ -4637,9 +4648,10 @@ void Clang::ConstructJob(Compilation &C,
> >
> >    // CloudABI and WebAssembly use -ffunction-sections and
> -fdata-sections by
> >    // default.
> > -  bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI ||
> > -                             Triple.getArch() == llvm::Triple::wasm32 ||
> > -                             Triple.getArch() == llvm::Triple::wasm64;
> > +  bool UseSeparateSections =
> > +      EffectiveTriple.getOS() == llvm::Triple::CloudABI ||
> > +      EffectiveTriple.getArch() == llvm::Triple::wasm32 ||
> > +      EffectiveTriple.getArch() == llvm::Triple::wasm64;
> >
> >    if (Args.hasFlag(options::OPT_ffunction_sections,
> >                     options::OPT_fno_function_sections,
> UseSeparateSections)) {
> > @@ -5008,7 +5020,8 @@ void Clang::ConstructJob(Compilation &C,
> >    Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
> >    // Emulated TLS is enabled by default on Android, and can be enabled
> manually
> >    // with -femulated-tls.
> > -  bool EmulatedTLSDefault = Triple.isAndroid() ||
> Triple.isWindowsCygwinEnvironment();
> > +  bool EmulatedTLSDefault = EffectiveTriple.isAndroid() ||
> > +
> EffectiveTriple.isWindowsCygwinEnvironment();
> >    if (Args.hasFlag(options::OPT_femulated_tls,
> options::OPT_fno_emulated_tls,
> >                     EmulatedTLSDefault))
> >      CmdArgs.push_back("-femulated-tls");
> > @@ -5049,7 +5062,7 @@ void Clang::ConstructJob(Compilation &C,
> >    }
> >
> >    const SanitizerArgs &Sanitize = getToolChain().getSanitizerArgs();
> > -  Sanitize.addArgs(getToolChain(), Args, CmdArgs, InputType);
> > +  Sanitize.addArgs(getToolChain(), EffectiveTriple, Args, CmdArgs,
> InputType);
> >
> >    // Report an error for -faltivec on anything other than PowerPC.
> >    if (const Arg *A = Args.getLastArg(options::OPT_faltivec)) {
> > @@ -5191,9 +5204,9 @@ void Clang::ConstructJob(Compilation &C,
> >        CmdArgs.push_back("-backend-option");
> >        CmdArgs.push_back("-arm-no-restrict-it");
> >      }
> > -  } else if (Triple.isOSWindows() &&
> > -             (Triple.getArch() == llvm::Triple::arm ||
> > -              Triple.getArch() == llvm::Triple::thumb)) {
> > +  } else if (EffectiveTriple.isOSWindows() &&
> > +             (EffectiveTriple.getArch() == llvm::Triple::arm ||
> > +              EffectiveTriple.getArch() == llvm::Triple::thumb)) {
> >      // Windows on ARM expects restricted IT blocks
> >      CmdArgs.push_back("-backend-option");
> >      CmdArgs.push_back("-arm-restrict-it");
> > @@ -5546,7 +5559,7 @@ void Clang::ConstructJob(Compilation &C,
> >    if (Args.hasArg(options::OPT_fno_inline))
> >      CmdArgs.push_back("-fno-inline");
> >
> > -  if (Arg* InlineArg = Args.getLastArg(options::OPT_finline_functions,
> > +  if (Arg *InlineArg = Args.getLastArg(options::OPT_finline_functions,
> >
>  options::OPT_finline_hint_functions,
> >
>  options::OPT_fno_inline_functions))
> >      InlineArg->render(Args, CmdArgs);
> > @@ -5608,7 +5621,6 @@ void Clang::ConstructJob(Compilation &C,
> >                       options::OPT_fno_objc_arc_exceptions,
> >                       /*default*/ types::isCXX(InputType)))
> >        CmdArgs.push_back("-fobjc-arc-exceptions");
> > -
> >    }
> >
> >    // -fobjc-infer-related-result-type is the default, except in the
> Objective-C
> > @@ -5634,8 +5646,8 @@ void Clang::ConstructJob(Compilation &C,
> >
> >    // Pass down -fobjc-weak or -fno-objc-weak if present.
> >    if (types::isObjC(InputType)) {
> > -    auto WeakArg = Args.getLastArg(options::OPT_fobjc_weak,
> > -                                   options::OPT_fno_objc_weak);
> > +    auto WeakArg =
> > +        Args.getLastArg(options::OPT_fobjc_weak,
> options::OPT_fno_objc_weak);
> >      if (!WeakArg) {
> >        // nothing to do
> >      } else if (GCArg) {
> > @@ -5805,7 +5817,7 @@ void Clang::ConstructJob(Compilation &C,
> >        StringRef Value(A->getValue());
> >        if (Value != "always" && Value != "never" && Value != "auto")
> >          getToolChain().getDriver().Diag(diag::err_drv_clang_unsupported)
> > -              << ("-fdiagnostics-color=" + Value).str();
> > +            << ("-fdiagnostics-color=" + Value).str();
> >      }
> >      A->claim();
> >    }
> > @@ -6476,6 +6488,7 @@ void ClangAs::AddX86TargetArgs(const Arg
> >
> >  void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
> >                             const InputInfo &Output, const InputInfoList
> &Inputs,
> > +                           const llvm::Triple &EffectiveTriple,
> >                             const ArgList &Args,
> >                             const char *LinkingOutput) const {
> >    ArgStringList CmdArgs;
> > @@ -6483,9 +6496,7 @@ void ClangAs::ConstructJob(Compilation &
> >    assert(Inputs.size() == 1 && "Unexpected number of inputs.");
> >    const InputInfo &Input = Inputs[0];
> >
> > -  std::string TripleStr =
> > -      getToolChain().ComputeEffectiveClangTriple(Args, Input.getType());
> > -  const llvm::Triple Triple(TripleStr);
> > +  std::string TripleStr = EffectiveTriple.str();
> >
> >    // Don't warn about "clang -w -c foo.s"
> >    Args.ClaimAllArgs(options::OPT_w);
> > @@ -6514,14 +6525,14 @@ void ClangAs::ConstructJob(Compilation &
> >    CmdArgs.push_back(Clang::getBaseInputName(Args, Input));
> >
> >    // Add the target cpu
> > -  std::string CPU = getCPUName(Args, Triple, /*FromAs*/ true);
> > +  std::string CPU = getCPUName(Args, EffectiveTriple, /*FromAs*/ true);
> >    if (!CPU.empty()) {
> >      CmdArgs.push_back("-target-cpu");
> >      CmdArgs.push_back(Args.MakeArgString(CPU));
> >    }
> >
> >    // Add the target features
> > -  getTargetFeatures(getToolChain(), Triple, Args, CmdArgs, true);
> > +  getTargetFeatures(getToolChain(), EffectiveTriple, Args, CmdArgs,
> true);
> >
> >    // Ignore explicit -force_cpusubtype_ALL option.
> >    (void)Args.hasArg(options::OPT_force__cpusubtype__ALL);
> > @@ -6580,7 +6591,7 @@ void ClangAs::ConstructJob(Compilation &
> >    unsigned PICLevel;
> >    bool IsPIE;
> >    std::tie(RelocationModel, PICLevel, IsPIE) =
> > -      ParsePICArgs(getToolChain(), Triple, Args);
> > +      ParsePICArgs(getToolChain(), EffectiveTriple, Args);
> >
> >    const char *RMName = RelocationModelName(RelocationModel);
> >    if (RMName) {
> > @@ -6663,7 +6674,9 @@ void GnuTool::anchor() {}
> >
> >  void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
> >                                 const InputInfo &Output,
> > -                               const InputInfoList &Inputs, const
> ArgList &Args,
> > +                               const InputInfoList &Inputs,
> > +                               const llvm::Triple &EffectiveTriple,
> > +                               const ArgList &Args,
> >                                 const char *LinkingOutput) const {
> >    const Driver &D = getToolChain().getDriver();
> >    ArgStringList CmdArgs;
> > @@ -6830,6 +6843,7 @@ void hexagon::Assembler::RenderExtraTool
> >  void hexagon::Assembler::ConstructJob(Compilation &C, const JobAction
> &JA,
> >                                        const InputInfo &Output,
> >                                        const InputInfoList &Inputs,
> > +                                      const llvm::Triple
> &EffectiveTriple,
> >                                        const ArgList &Args,
> >                                        const char *LinkingOutput) const {
> >    claimNoWarnArgs(Args);
> > @@ -7073,6 +7087,7 @@ constructHexagonLinkArgs(Compilation &C,
> >  void hexagon::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                     const InputInfo &Output,
> >                                     const InputInfoList &Inputs,
> > +                                   const llvm::Triple &EffectiveTriple,
> >                                     const ArgList &Args,
> >                                     const char *LinkingOutput) const {
> >    auto &HTC = static_cast<const
> toolchains::HexagonToolChain&>(getToolChain());
> > @@ -7090,6 +7105,7 @@ void hexagon::Linker::ConstructJob(Compi
> >  void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                    const InputInfo &Output,
> >                                    const InputInfoList &Inputs,
> > +                                  const llvm::Triple &EffectiveTriple,
> >                                    const ArgList &Args,
> >                                    const char *LinkingOutput) const {
> >
> > @@ -7118,6 +7134,7 @@ bool wasm::Linker::hasIntegratedCPP() co
> >  void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                  const InputInfo &Output,
> >                                  const InputInfoList &Inputs,
> > +                                const llvm::Triple &EffectiveTriple,
> >                                  const ArgList &Args,
> >                                  const char *LinkingOutput) const {
> >
> > @@ -7193,7 +7210,8 @@ const std::string arm::getARMArch(String
> >      std::string CPU = llvm::sys::getHostCPUName();
> >      if (CPU != "generic") {
> >        // Translate the native cpu into the architecture suffix for that
> CPU.
> > -      StringRef Suffix = arm::getLLVMArchSuffixForARM(CPU, MArch,
> Triple);
> > +      StringRef Suffix =
> > +          arm::getLLVMArchSuffixForARM(CPU, MArch, Triple);
> >        // If there is no valid architecture suffix for this CPU we don't
> know how
> >        // to handle it, so return no architecture.
> >        if (Suffix.empty())
> > @@ -7453,6 +7471,7 @@ const char *Clang::getDependencyFileName
> >  void cloudabi::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                      const InputInfo &Output,
> >                                      const InputInfoList &Inputs,
> > +                                    const llvm::Triple &EffectiveTriple,
> >                                      const ArgList &Args,
> >                                      const char *LinkingOutput) const {
> >    const ToolChain &ToolChain = getToolChain();
> > @@ -7521,6 +7540,7 @@ void cloudabi::Linker::ConstructJob(Comp
> >  void darwin::Assembler::ConstructJob(Compilation &C, const JobAction
> &JA,
> >                                       const InputInfo &Output,
> >                                       const InputInfoList &Inputs,
> > +                                     const llvm::Triple
> &EffectiveTriple,
> >                                       const ArgList &Args,
> >                                       const char *LinkingOutput) const {
> >    ArgStringList CmdArgs;
> > @@ -7818,6 +7838,7 @@ void darwin::Linker::AddLinkArgs(Compila
> >  void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                    const InputInfo &Output,
> >                                    const InputInfoList &Inputs,
> > +                                  const llvm::Triple &EffectiveTriple,
> >                                    const ArgList &Args,
> >                                    const char *LinkingOutput) const {
> >    assert(Output.getType() == types::TY_Image && "Invalid linker output
> type.");
> > @@ -7919,7 +7940,7 @@ void darwin::Linker::ConstructJob(Compil
> >    if (Args.hasArg(options::OPT_fnested_functions))
> >      CmdArgs.push_back("-allow_stack_execute");
> >
> > -  getMachOToolChain().addProfileRTLibs(Args, CmdArgs);
> > +  getMachOToolChain().addProfileRTLibs(EffectiveTriple, Args, CmdArgs);
> >
> >    if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
> >      if (getToolChain().getDriver().CCCIsCXX())
> > @@ -7928,7 +7949,7 @@ void darwin::Linker::ConstructJob(Compil
> >      // link_ssp spec is empty.
> >
> >      // Let the tool chain choose which runtime library to link.
> > -    getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
> > +    getMachOToolChain().AddLinkRuntimeLibArgs(EffectiveTriple, Args,
> CmdArgs);
> >    }
> >
> >    if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
> > @@ -7961,6 +7982,7 @@ void darwin::Linker::ConstructJob(Compil
> >  void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
> >                                  const InputInfo &Output,
> >                                  const InputInfoList &Inputs,
> > +                                const llvm::Triple &EffectiveTriple,
> >                                  const ArgList &Args,
> >                                  const char *LinkingOutput) const {
> >    ArgStringList CmdArgs;
> > @@ -7983,6 +8005,7 @@ void darwin::Lipo::ConstructJob(Compilat
> >  void darwin::Dsymutil::ConstructJob(Compilation &C, const JobAction &JA,
> >                                      const InputInfo &Output,
> >                                      const InputInfoList &Inputs,
> > +                                    const llvm::Triple &EffectiveTriple,
> >                                      const ArgList &Args,
> >                                      const char *LinkingOutput) const {
> >    ArgStringList CmdArgs;
> > @@ -8003,6 +8026,7 @@ void darwin::Dsymutil::ConstructJob(Comp
> >  void darwin::VerifyDebug::ConstructJob(Compilation &C, const JobAction
> &JA,
> >                                         const InputInfo &Output,
> >                                         const InputInfoList &Inputs,
> > +                                       const llvm::Triple
> &EffectiveTriple,
> >                                         const ArgList &Args,
> >                                         const char *LinkingOutput) const
> {
> >    ArgStringList CmdArgs;
> > @@ -8026,6 +8050,7 @@ void darwin::VerifyDebug::ConstructJob(C
> >  void solaris::Assembler::ConstructJob(Compilation &C, const JobAction
> &JA,
> >                                        const InputInfo &Output,
> >                                        const InputInfoList &Inputs,
> > +                                      const llvm::Triple
> &EffectiveTriple,
> >                                        const ArgList &Args,
> >                                        const char *LinkingOutput) const {
> >    claimNoWarnArgs(Args);
> > @@ -8046,6 +8071,7 @@ void solaris::Assembler::ConstructJob(Co
> >  void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                     const InputInfo &Output,
> >                                     const InputInfoList &Inputs,
> > +                                   const llvm::Triple &EffectiveTriple,
> >                                     const ArgList &Args,
> >                                     const char *LinkingOutput) const {
> >    ArgStringList CmdArgs;
> > @@ -8115,7 +8141,7 @@ void solaris::Linker::ConstructJob(Compi
> >    }
> >
> CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
> >
> > -  getToolChain().addProfileRTLibs(Args, CmdArgs);
> > +  getToolChain().addProfileRTLibs(EffectiveTriple, Args, CmdArgs);
> >
> >    const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
> >    C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs,
> Inputs));
> > @@ -8124,6 +8150,7 @@ void solaris::Linker::ConstructJob(Compi
> >  void openbsd::Assembler::ConstructJob(Compilation &C, const JobAction
> &JA,
> >                                        const InputInfo &Output,
> >                                        const InputInfoList &Inputs,
> > +                                      const llvm::Triple
> &EffectiveTriple,
> >                                        const ArgList &Args,
> >                                        const char *LinkingOutput) const {
> >    claimNoWarnArgs(Args);
> > @@ -8195,6 +8222,7 @@ void openbsd::Assembler::ConstructJob(Co
> >  void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                     const InputInfo &Output,
> >                                     const InputInfoList &Inputs,
> > +                                   const llvm::Triple &EffectiveTriple,
> >                                     const ArgList &Args,
> >                                     const char *LinkingOutput) const {
> >    const Driver &D = getToolChain().getDriver();
> > @@ -8317,6 +8345,7 @@ void openbsd::Linker::ConstructJob(Compi
> >  void bitrig::Assembler::ConstructJob(Compilation &C, const JobAction
> &JA,
> >                                       const InputInfo &Output,
> >                                       const InputInfoList &Inputs,
> > +                                     const llvm::Triple
> &EffectiveTriple,
> >                                       const ArgList &Args,
> >                                       const char *LinkingOutput) const {
> >    claimNoWarnArgs(Args);
> > @@ -8337,6 +8366,7 @@ void bitrig::Assembler::ConstructJob(Com
> >  void bitrig::Linker::ConstructJob(Compilation &C, const JobAction &JA,
> >                                    const InputInfo &Output,
> >                                    const InputInfoList &Inputs,
> > +                                  const llvm::Triple &EffectiveTriple,
> >                                    const ArgList &Args,
> >                                    const char *LinkingOutput) const {
> >    const Driver &D = getToolChain().getDriver();
> > @@ -8446,6 +8476,7 @@ void bitrig::Linker::ConstructJob(Compil
> >  void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction
> &JA,
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160719/75d2d84a/attachment-0001.html>


More information about the cfe-commits mailing list