[cfe-commits] r101108 - in /cfe/trunk: include/clang/CodeGen/CodeGenOptions.h include/clang/Driver/CC1Options.td lib/Frontend/CodeGenAction.cpp lib/Frontend/CompilerInvocation.cpp

Chris Lattner sabre at nondot.org
Mon Apr 12 17:38:24 PDT 2010


Author: lattner
Date: Mon Apr 12 19:38:24 2010
New Revision: 101108

URL: http://llvm.org/viewvc/llvm-project?rev=101108&view=rev
Log:
add frontend support for -fdata-sections and -ffunction-sections,
patch by Sylvere Teissier!

Modified:
    cfe/trunk/include/clang/CodeGen/CodeGenOptions.h
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/lib/Frontend/CodeGenAction.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/CodeGen/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenOptions.h?rev=101108&r1=101107&r2=101108&view=diff
==============================================================================
--- cfe/trunk/include/clang/CodeGen/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenOptions.h Mon Apr 12 19:38:24 2010
@@ -32,6 +32,7 @@
   unsigned CXAAtExit         : 1; /// Use __cxa_atexit for calling destructors.
   unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker
                                   /// aliases to base ctors when possible.
+  unsigned DataSections      : 1; /// Set when -fdata-sections is enabled
   unsigned DebugInfo         : 1; /// Should generate deubg info (-g).
   unsigned DisableFPElim     : 1; /// Set when -fomit-frame-pointer is enabled.
   unsigned DisableLLVMOpts   : 1; /// Don't run any optimizations, for use in
@@ -39,6 +40,7 @@
                                   /// internal state before optimizations are
                                   /// done.
   unsigned DisableRedZone    : 1; /// Set when -mno-red-zone is enabled.
+  unsigned FunctionSections  : 1; /// Set when -ffunction-sections is enabled
   unsigned MergeAllConstants : 1; /// Merge identical constants.
   unsigned NoCommon          : 1; /// Set when -fno-common or C++ is enabled.
   unsigned NoImplicitFloat   : 1; /// Set when -mno-implicit-float is enabled.
@@ -88,10 +90,12 @@
     AsmVerbose = 0;
     CXAAtExit = 1;
     CXXCtorDtorAliases = 0;
+    DataSections = 0;
     DebugInfo = 0;
     DisableFPElim = 0;
     DisableLLVMOpts = 0;
     DisableRedZone = 0;
+    FunctionSections = 0;
     MergeAllConstants = 1;
     NoCommon = 0;
     NoImplicitFloat = 0;

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=101108&r1=101107&r2=101108&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Apr 12 19:38:24 2010
@@ -123,6 +123,10 @@
   HelpText<"Do not emit code to make initialization of local statics thread safe">;
 def fdump_vtable_layouts : Flag<"-fdump-vtable-layouts">,
   HelpText<"Dump the layouts of all vtables that will be emitted in a translation unit">;
+def ffunction_sections : Flag<"-ffunction-sections">,
+  HelpText<"Place each function in its own section (ELF Only)">;
+def fdata_sections : Flag<"-fdata-sections">,
+  HelpText<"Place each data in its own section (ELF Only)">;
 def masm_verbose : Flag<"-masm-verbose">,
   HelpText<"Generate verbose assembly output">;
 def mcode_model : Separate<"-mcode-model">,

Modified: cfe/trunk/lib/Frontend/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CodeGenAction.cpp?rev=101108&r1=101107&r2=101108&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/Frontend/CodeGenAction.cpp Mon Apr 12 19:38:24 2010
@@ -261,6 +261,9 @@
 
   TargetMachine::setAsmVerbosityDefault(CodeGenOpts.AsmVerbose);
 
+  TargetMachine::setFunctionSections(CodeGenOpts.FunctionSections);
+  TargetMachine::setDataSections    (CodeGenOpts.DataSections);
+
   // FIXME: Parse this earlier.
   if (CodeGenOpts.RelocationModel == "static") {
     TargetMachine::setRelocationModel(llvm::Reloc::Static);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=101108&r1=101107&r2=101108&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Apr 12 19:38:24 2010
@@ -148,6 +148,10 @@
   // VerifyModule is only derived.
   // Inlining is only derived.
 
+  if (Opts.DataSections)
+    Res.push_back("-fdata-sections");
+  if (Opts.FunctionSections)
+    Res.push_back("-ffunction-sections");
   if (Opts.AsmVerbose)
     Res.push_back("-masm-verbose");
   if (!Opts.CodeModel.empty()) {
@@ -803,6 +807,9 @@
   Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
   Opts.RelocationModel = getLastArgValue(Args, OPT_mrelocation_model, "pic");
 
+  Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
+  Opts.DataSections = Args.hasArg(OPT_fdata_sections);
+
   Opts.MainFileName = getLastArgValue(Args, OPT_main_file_name);
   Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
 }





More information about the cfe-commits mailing list