From a1ab1a80a5aacc3e224d4785cee85eab47078184 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 22 Dec 2016 03:09:02 +0000 Subject: [PATCH] Driver: remove unnecessary parameter We can query the Triple and EffectiveTriple from the ToolChain. Avoid passing in the argument and query it in the function. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290304 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 445f13c95c..8b52f52576 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -3789,13 +3789,14 @@ static void addPS4ProfileRTArgs(const ToolChain &TC, const ArgList &Args, /// this compile should be using PIC mode or not. Returns a tuple of /// (RelocationModel, PICLevel, IsPIE). static std::tuple -ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &EffectiveTriple, - const ArgList &Args) { +ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) { + const llvm::Triple &EffectiveTriple = ToolChain.getEffectiveTriple(); + const llvm::Triple &Triple = ToolChain.getTriple(); + bool PIE = ToolChain.isPIEDefault(); bool PIC = PIE || ToolChain.isPICDefault(); // The Darwin/MachO default to use PIC does not apply when using -static. - if (ToolChain.getTriple().isOSBinFormatMachO() && - Args.hasArg(options::OPT_static)) + if (Triple.isOSBinFormatMachO() && Args.hasArg(options::OPT_static)) PIE = PIC = false; bool IsPICLevelTwo = PIC; @@ -3803,7 +3804,7 @@ ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &EffectiveTriple, Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext); // Android-specific defaults for PIC/PIE - if (ToolChain.getTriple().isAndroid()) { + if (Triple.isAndroid()) { switch (ToolChain.getArch()) { case llvm::Triple::arm: case llvm::Triple::armeb: @@ -3829,7 +3830,7 @@ ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &EffectiveTriple, } // OpenBSD-specific defaults for PIE - if (ToolChain.getTriple().getOS() == llvm::Triple::OpenBSD) { + if (Triple.getOS() == llvm::Triple::OpenBSD) { switch (ToolChain.getArch()) { case llvm::Triple::mips64: case llvm::Triple::mips64el: @@ -3888,7 +3889,7 @@ ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &EffectiveTriple, // Introduce a Darwin and PS4-specific hack. If the default is PIC, but the // PIC level would've been set to level 1, force it back to level 2 PIC // instead. - if (PIC && (ToolChain.getTriple().isOSDarwin() || EffectiveTriple.isPS4CPU())) + if (PIC && (Triple.isOSDarwin() || EffectiveTriple.isPS4CPU())) IsPICLevelTwo |= ToolChain.isPICDefault(); // This kernel flags are a trump-card: they will disable PIC/PIE @@ -3901,9 +3902,9 @@ ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &EffectiveTriple, if (Arg *A = Args.getLastArg(options::OPT_mdynamic_no_pic)) { // This is a very special mode. It trumps the other modes, almost no one // uses it, and it isn't even valid on any OS but Darwin. - if (!ToolChain.getTriple().isOSDarwin()) + if (!Triple.isOSDarwin()) ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target) - << A->getSpelling() << ToolChain.getTriple().str(); + << A->getSpelling() << Triple.str(); // FIXME: Warn when this flag trumps some other PIC or PIE flag. @@ -3933,14 +3934,14 @@ ParsePICArgs(const ToolChain &ToolChain, const llvm::Triple &EffectiveTriple, if (LastROPIArg && LastROPIArg->getOption().matches(options::OPT_fropi)) { if (!EmbeddedPISupported) ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target) - << LastROPIArg->getSpelling() << ToolChain.getTriple().str(); + << LastROPIArg->getSpelling() << Triple.str(); ROPI = true; } Arg *LastRWPIArg = Args.getLastArg(options::OPT_frwpi, options::OPT_fno_rwpi); if (LastRWPIArg && LastRWPIArg->getOption().matches(options::OPT_frwpi)) { if (!EmbeddedPISupported) ToolChain.getDriver().Diag(diag::err_drv_unsupported_opt_for_target) - << LastRWPIArg->getSpelling() << ToolChain.getTriple().str(); + << LastRWPIArg->getSpelling() << Triple.str(); RWPI = true; } @@ -3986,8 +3987,7 @@ static void AddAssemblerKPIC(const ToolChain &ToolChain, const ArgList &Args, llvm::Reloc::Model RelocationModel; unsigned PICLevel; bool IsPIE; - std::tie(RelocationModel, PICLevel, IsPIE) = - ParsePICArgs(ToolChain, ToolChain.getTriple(), Args); + std::tie(RelocationModel, PICLevel, IsPIE) = ParsePICArgs(ToolChain, Args); if (RelocationModel != llvm::Reloc::Static) CmdArgs.push_back("-KPIC"); @@ -4329,7 +4329,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, unsigned PICLevel; bool IsPIE; std::tie(RelocationModel, PICLevel, IsPIE) = - ParsePICArgs(getToolChain(), Triple, Args); + ParsePICArgs(getToolChain(), Args); const char *RMName = RelocationModelName(RelocationModel); @@ -7036,7 +7036,7 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, unsigned PICLevel; bool IsPIE; std::tie(RelocationModel, PICLevel, IsPIE) = - ParsePICArgs(getToolChain(), Triple, Args); + ParsePICArgs(getToolChain(), Args); const char *RMName = RelocationModelName(RelocationModel); if (RMName) { @@ -9666,15 +9666,13 @@ void gnutools::Assembler::ConstructJob(Compilation &C, const JobAction &JA, const char *LinkingOutput) const { claimNoWarnArgs(Args); - const llvm::Triple &Triple = getToolChain().getEffectiveTriple(); - ArgStringList CmdArgs; llvm::Reloc::Model RelocationModel; unsigned PICLevel; bool IsPIE; std::tie(RelocationModel, PICLevel, IsPIE) = - ParsePICArgs(getToolChain(), Triple, Args); + ParsePICArgs(getToolChain(), Args); switch (getToolChain().getArch()) { default: -- 2.40.0