Author: Sriraman Tallam
Date: 2021-02-17T12:37:50-08:00
New Revision: e74191633036905388245818f54553813c880f83

URL: 
https://github.com/llvm/llvm-project/commit/e74191633036905388245818f54553813c880f83
DIFF: 
https://github.com/llvm/llvm-project/commit/e74191633036905388245818f54553813c880f83.diff

LOG: Basic block sections should enable not function sections implicitly.

Basic block sections enables function sections implicitly, this is not needed
and is inefficient with "=list" option.

We had basic block sections enable function sections implicitly in clang. This
is particularly inefficient with "=list" option as it places functions that do
not have any basic block sections in separate sections. This causes unnecessary
object file overhead for large applications.

This patch disables this implicit behavior. It only creates function sections
for those functions that require basic block sections.

This patch is the second of two patches and this patch removes the implicit
enabling of function sections with basic block sections in clang.

Differential Revision: https://reviews.llvm.org/D93876

Added: 
    

Modified: 
    clang/lib/Frontend/CompilerInvocation.cpp
    clang/test/CodeGen/basic-block-sections.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f92964732688..a49c97860324 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1383,8 +1383,7 @@ void CompilerInvocation::GenerateCodeGenArgs(
       GenerateArg(Args, OPT_ftime_report, SA);
   }
 
-  if (Opts.FunctionSections &&
-      (Opts.BBSections == "none" || Opts.BBSections == "labels"))
+  if (Opts.FunctionSections)
     GenerateArg(Args, OPT_ffunction_sections, SA);
 
   if (Opts.PrepareForLTO && !Opts.PrepareForThinLTO)
@@ -1678,9 +1677,7 @@ bool 
CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,
   }
 
   // Basic Block Sections implies Function Sections.
-  Opts.FunctionSections =
-      Args.hasArg(OPT_ffunction_sections) ||
-      (Opts.BBSections != "none" && Opts.BBSections != "labels");
+  Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.PrepareForThinLTO = false;

diff  --git a/clang/test/CodeGen/basic-block-sections.c 
b/clang/test/CodeGen/basic-block-sections.c
index ee0dc90e2d02..a61b8dd4ac37 100644
--- a/clang/test/CodeGen/basic-block-sections.c
+++ b/clang/test/CodeGen/basic-block-sections.c
@@ -32,10 +32,9 @@ int another(int a) {
 // BB_WORLD: world:
 // BB_WORLD: .section .text.world,"ax",@progbits,unique
 // BB_WORLD: world.__part.1:
-// BB_WORLD: .section .text.another,"ax",@progbits
-// BB_ALL: .section .text.another,"ax",@progbits,unique
+// BB_ALL: .section .text.another,"ax",@progbits
 // BB_ALL: another.__part.1:
-// BB_LIST-NOT: .section .text.another,"ax",@progbits,unique
+// BB_LIST-NOT: .section .text.another,"ax",@progbits
 // BB_LIST: another:
 // BB_LIST-NOT: another.__part.1:
 //


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to