Author: rafael Date: Fri Feb 20 12:08:57 2015 New Revision: 230031 URL: http://llvm.org/viewvc/llvm-project?rev=230031&view=rev Log: Add -funique-section-names and -fno-unique-section-names options.
For now -funique-section-names is the default, so no change in default behavior. The total .o size in a build of llvm and clang goes from 241687775 to 230649031 bytes if -fno-unique-section-names is used. Added: cfe/trunk/test/CodeGen/funique-sections.c Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Driver/function-sections.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=230031&r1=230030&r2=230031&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Feb 20 12:08:57 2015 @@ -1004,6 +1004,14 @@ def fdata_sections : Flag <["-"], "fdata 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 funique_section_names : Flag <["-"], "funique-section-names">, + Group<f_Group>, Flags<[CC1Option]>, + HelpText<"Use unique names for text and data sections (ELF Only)">; +def fno_unique_section_names : Flag <["-"], "fno-unique-section-names">, + 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 fno_debug_types_section: Flag<["-"], "fno-debug-types-section">, Group<f_Group>, Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=230031&r1=230030&r2=230031&view=diff ============================================================================== --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Feb 20 12:08:57 2015 @@ -40,6 +40,7 @@ CODEGENOPT(CXAAtExit , 1, 1) /// CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker ///< aliases to base ctors when possible. CODEGENOPT(DataSections , 1, 0) ///< Set when -fdata-sections is enabled. +CODEGENOPT(UniqueSectionNames, 1, 1) ///< Set for -funique-section-names. CODEGENOPT(DisableFPElim , 1, 0) ///< Set when -fomit-frame-pointer is enabled. CODEGENOPT(DisableFree , 1, 0) ///< Don't free memory. CODEGENOPT(DisableGCov , 1, 0) ///< Don't run the GCov pass, for testing. Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=230031&r1=230030&r2=230031&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Feb 20 12:08:57 2015 @@ -527,6 +527,7 @@ TargetMachine *EmitAssemblyHelper::Creat Options.PositionIndependentExecutable = LangOpts.PIELevel != 0; Options.FunctionSections = CodeGenOpts.FunctionSections; Options.DataSections = CodeGenOpts.DataSections; + Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames; Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll; Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels; Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=230031&r1=230030&r2=230031&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Fri Feb 20 12:08:57 2015 @@ -3316,6 +3316,10 @@ void Clang::ConstructJob(Compilation &C, CmdArgs.push_back("-fdata-sections"); } + if (!Args.hasFlag(options::OPT_funique_section_names, + options::OPT_fno_unique_section_names, true)) + CmdArgs.push_back("-fno-unique-section-names"); + Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions); if (Args.hasArg(options::OPT_fprofile_instr_generate) && Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=230031&r1=230030&r2=230031&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Feb 20 12:08:57 2015 @@ -472,6 +472,9 @@ static bool ParseCodeGenArgs(CodeGenOpti OPT_fno_function_sections, false); Opts.DataSections = Args.hasFlag(OPT_fdata_sections, OPT_fno_data_sections, false); + Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names, + OPT_fno_unique_section_names, true); + Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions); Opts.MSVolatile = Args.hasArg(OPT_fms_volatile); Added: cfe/trunk/test/CodeGen/funique-sections.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/funique-sections.c?rev=230031&view=auto ============================================================================== --- cfe/trunk/test/CodeGen/funique-sections.c (added) +++ cfe/trunk/test/CodeGen/funique-sections.c Fri Feb 20 12:08:57 2015 @@ -0,0 +1,13 @@ +// REQUIRES: x86-registered-target + +// RUN: %clang_cc1 -triple x86_64-pc-linux -S -ffunction-sections -fdata-sections -fno-unique-section-names -o - < %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux -S -ffunction-sections -fdata-sections -o - < %s | FileCheck %s --check-prefix=UNIQUE + +const int hello = 123; +void world() {} + +// CHECK: .section .text,"ax",@progbits,unique +// CHECK: .section .rodata,"a",@progbits,unique + +// UNIQUE: .section .text.world,"ax",@progbits +// UNIQUE: .section .rodata.hello,"a",@progbits Modified: cfe/trunk/test/Driver/function-sections.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/function-sections.c?rev=230031&r1=230030&r2=230031&view=diff ============================================================================== --- cfe/trunk/test/Driver/function-sections.c (original) +++ cfe/trunk/test/Driver/function-sections.c Fri Feb 20 12:08:57 2015 @@ -4,6 +4,8 @@ // CHECK-NOFS-NOT: -ffunction-sections // CHECK-DS: -fdata-sections // CHECK-NODS-NOT: -fdata-sections +// CHECK-US-NOT: -fno-unique-section-names +// CHECK-NOUS: -fno-unique-section-names // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ // RUN: -target i386-unknown-linux \ @@ -60,3 +62,13 @@ // RUN: -fdata-sections -fno-data-sections -fdata-sections \ // RUN: | FileCheck --check-prefix=CHECK-DS %s + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: -funique-section-names \ +// RUN: | FileCheck --check-prefix=CHECK-US %s + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: -fno-unique-section-names \ +// RUN: | FileCheck --check-prefix=CHECK-NOUS %s _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits