[cfe-commits] r130697 - /cfe/trunk/lib/Driver/Tools.cpp

Rafael Espindola rafael.espindola at gmail.com
Mon May 2 10:43:33 PDT 2011


Author: rafael
Date: Mon May  2 12:43:32 2011
New Revision: 130697

URL: http://llvm.org/viewvc/llvm-project?rev=130697&view=rev
Log:
Disable CFI if not using the integrated assembler. We should probably do this only for
OS X, but it is probably not all that important.

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=130697&r1=130696&r2=130697&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon May  2 12:43:32 2011
@@ -905,6 +905,25 @@
     CmdArgs.push_back("-fexceptions");
 }
 
+static bool ShouldDisableCFI(const ArgList &Args,
+                             const ToolChain &TC) {
+
+  // FIXME: Duplicated code with ToolChains.cpp
+  // FIXME: This doesn't belong here, but ideally we will support static soon
+  // anyway.
+  bool HasStatic = (Args.hasArg(options::OPT_mkernel) ||
+                    Args.hasArg(options::OPT_static) ||
+                    Args.hasArg(options::OPT_fapple_kext));
+  bool IsIADefault = TC.IsIntegratedAssemblerDefault() && !HasStatic;
+  bool UseIntegratedAs = Args.hasFlag(options::OPT_integrated_as,
+                                      options::OPT_no_integrated_as,
+                                      IsIADefault);
+  bool UseCFI = Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
+                             options::OPT_fno_dwarf2_cfi_asm,
+                             UseIntegratedAs);
+  return !UseCFI;
+}
+
 void Clang::ConstructJob(Compilation &C, const JobAction &JA,
                          const InputInfo &Output,
                          const InputInfoList &Inputs,
@@ -1375,11 +1394,8 @@
       CmdArgs.push_back("-fno-gnu-keywords");
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_fdwarf2_cfi_asm,
-                               options::OPT_fno_dwarf2_cfi_asm)) {
-    if (A->getOption().matches(options::OPT_fno_dwarf2_cfi_asm))
-      CmdArgs.push_back("-fno-dwarf2-cfi-asm");
-  }
+  if (ShouldDisableCFI(Args, getToolChain()))
+    CmdArgs.push_back("-fno-dwarf2-cfi-asm");
 
   if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_)) {
     CmdArgs.push_back("-ftemplate-depth");





More information about the cfe-commits mailing list