r192817 - Driver: Factor duplicated code.
Benjamin Kramer
benny.kra at googlemail.com
Wed Oct 16 10:42:40 PDT 2013
Author: d0k
Date: Wed Oct 16 12:42:39 2013
New Revision: 192817
URL: http://llvm.org/viewvc/llvm-project?rev=192817&view=rev
Log:
Driver: Factor duplicated code.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=192817&r1=192816&r2=192817&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Oct 16 12:42:39 2013
@@ -1785,30 +1785,36 @@ static void addDfsanRTLinux(const ToolCh
addSanitizerRTLinkFlagsLinux(TC, Args, CmdArgs, "dfsan", true);
}
+static bool shouldUseFramePointerForTarget(const ArgList &Args,
+ const llvm::Triple &Triple) {
+ switch (Triple.getArch()) {
+ // Don't use a frame pointer on linux if optimizing for certain targets.
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::systemz:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ if (Triple.isOSLinux())
+ if (Arg *A = Args.getLastArg(options::OPT_O_Group))
+ if (!A->getOption().matches(options::OPT_O0))
+ return false;
+ return true;
+ case llvm::Triple::xcore:
+ return false;
+ default:
+ return true;
+ }
+}
+
static bool shouldUseFramePointer(const ArgList &Args,
const llvm::Triple &Triple) {
if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
return A->getOption().matches(options::OPT_fno_omit_frame_pointer);
- // Don't use a frame pointer on linux x86, x86_64 and z if optimizing.
- if ((Triple.getArch() == llvm::Triple::x86_64 ||
- Triple.getArch() == llvm::Triple::x86 ||
- Triple.getArch() == llvm::Triple::systemz ||
- Triple.getArch() == llvm::Triple::mips ||
- Triple.getArch() == llvm::Triple::mipsel ||
- Triple.getArch() == llvm::Triple::mips64 ||
- Triple.getArch() == llvm::Triple::mips64el) &&
- Triple.isOSLinux()) {
- if (Arg *A = Args.getLastArg(options::OPT_O_Group))
- if (!A->getOption().matches(options::OPT_O0))
- return false;
- }
-
- if (Triple.getArch() == llvm::Triple::xcore)
- return false;
-
- return true;
+ return shouldUseFramePointerForTarget(Args, Triple);
}
static bool shouldUseLeafFramePointer(const ArgList &Args,
@@ -1817,24 +1823,7 @@ static bool shouldUseLeafFramePointer(co
options::OPT_momit_leaf_frame_pointer))
return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
- // Don't use a leaf frame pointer on linux x86, x86_64 and z if optimizing.
- if ((Triple.getArch() == llvm::Triple::x86_64 ||
- Triple.getArch() == llvm::Triple::x86 ||
- Triple.getArch() == llvm::Triple::systemz ||
- Triple.getArch() == llvm::Triple::mips ||
- Triple.getArch() == llvm::Triple::mipsel ||
- Triple.getArch() == llvm::Triple::mips64 ||
- Triple.getArch() == llvm::Triple::mips64el) &&
- Triple.isOSLinux()) {
- if (Arg *A = Args.getLastArg(options::OPT_O_Group))
- if (!A->getOption().matches(options::OPT_O0))
- return false;
- }
-
- if (Triple.getArch() == llvm::Triple::xcore)
- return false;
-
- return true;
+ return shouldUseFramePointerForTarget(Args, Triple);
}
/// Add a CC1 option to specify the debug compilation directory.
More information about the cfe-commits
mailing list