r192413 - Add -fno-function-sections and -fno-data-sections. Since
Nick Lewycky
nicholas at mxc.ca
Thu Oct 10 20:35:10 PDT 2013
Author: nicholas
Date: Thu Oct 10 22:35:10 2013
New Revision: 192413
URL: http://llvm.org/viewvc/llvm-project?rev=192413&view=rev
Log:
Add -fno-function-sections and -fno-data-sections. Since
-f{function,data}-sections had no tests at all, add some, and verify that the
-fno variants work as well.
Added:
cfe/trunk/test/CodeGen/sections.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=192413&r1=192412&r2=192413&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 10 22:35:10 2013
@@ -832,10 +832,15 @@ def fwrapv : Flag<["-"], "fwrapv">, Grou
def fwritable_strings : Flag<["-"], "fwritable-strings">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Store string literals as writable data">;
def fzero_initialized_in_bss : Flag<["-"], "fzero-initialized-in-bss">, Group<f_Group>;
-def ffunction_sections: Flag <["-"], "ffunction-sections">, Group<f_Group>,
- Flags<[CC1Option]>, HelpText<"Place each function in its own section (ELF Only)">;
-def fdata_sections : Flag <["-"], "fdata-sections">, Group<f_Group>, Flags<[CC1Option]>,
- HelpText<"Place each data in its own section (ELF Only)">;
+def ffunction_sections : Flag<["-"], "ffunction-sections">, Group<f_Group>,
+ Flags<[CC1Option]>,
+ HelpText<"Place each function in its own section (ELF Only)">;
+def fno_function_sections : Flag<["-"], "fno-function-sections">,
+ Group<f_Group>, Flags<[CC1Option]>;
+def fdata_sections : Flag <["-"], "fdata-sections">, Group<f_Group>,
+ Flags<[CC1Option]>, HelpText<"Place each data in its own section (ELF Only)">;
+def fno_data_sections : Flag <["-"], "fno-data-sections">, Group<f_Group>,
+ Flags<[CC1Option]>;
def fdebug_types_section: Flag <["-"], "fdebug-types-section">, Group<f_Group>,
Flags<[CC1Option]>, HelpText<"Place debug types in their own section (ELF Only)">;
def g_Flag : Flag<["-"], "g">, Group<g_Group>,
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=192413&r1=192412&r2=192413&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Oct 10 22:35:10 2013
@@ -398,8 +398,10 @@ static bool ParseCodeGenArgs(CodeGenOpti
Opts.TrapFuncName = Args.getLastArgValue(OPT_ftrap_function_EQ);
Opts.UseInitArray = Args.hasArg(OPT_fuse_init_array);
- Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
- Opts.DataSections = Args.hasArg(OPT_fdata_sections);
+ Opts.FunctionSections = Args.hasFlag(OPT_ffunction_sections,
+ OPT_fno_function_sections, false);
+ Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
+ OPT_fno_data_sections, false);
Opts.VectorizeBB = Args.hasArg(OPT_vectorize_slp_aggressive);
Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
Added: cfe/trunk/test/CodeGen/sections.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sections.c?rev=192413&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/sections.c (added)
+++ cfe/trunk/test/CodeGen/sections.c Thu Oct 10 22:35:10 2013
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -ffunction-sections -fno-function-sections -o - < %s | FileCheck %s --check-prefix=PLAIN
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -ffunction-sections -o - < %s | FileCheck %s --check-prefix=FUNC_SECT
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-function-sections -ffunction-sections -o - < %s | FileCheck %s --check-prefix=FUNC_SECT
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-data-sections -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
+
+const int hello = 123;
+void world() {}
+
+// PLAIN-NOT: section
+// PLAIN: world:
+// PLAIN: section .rodata,
+// PLAIN: hello:
+
+// FUNC_SECT: section .text.world,
+// FUNC_SECT: world:
+// FUNC_SECT: section .rodata,
+// FUNC_SECT: hello:
+
+// DATA_SECT-NOT: section
+// DATA_SECT: world:
+// DATA_SECT: .section .rodata.hello,
+// DATA_SECT: hello:
More information about the cfe-commits
mailing list