aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CommandFlags.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2024-05-07 09:18:55 -0700
committerGitHub <noreply@github.com>2024-05-07 09:18:55 -0700
commit8bcb0737056163686e967821bea7f9e87c57cdfc (patch)
treed7dfa658e2947f31c0c32aeee7aeeea1ca47a0f7 /llvm/lib/CodeGen/CommandFlags.cpp
parente74a7a9fd79a74073277471243a44527c71eb4a9 (diff)
downloadllvm-8bcb0737056163686e967821bea7f9e87c57cdfc.zip
llvm-8bcb0737056163686e967821bea7f9e87c57cdfc.tar.gz
llvm-8bcb0737056163686e967821bea7f9e87c57cdfc.tar.bz2
[Clang] -fseparate-named-sections option (#91028)
When set, the compiler will use separate unique sections for global symbols in named special sections (e.g. symbols that are annotated with __attribute__((section(...)))). Doing so enables linker GC to collect unused symbols without having to use a different section per-symbol.
Diffstat (limited to 'llvm/lib/CodeGen/CommandFlags.cpp')
-rw-r--r--llvm/lib/CodeGen/CommandFlags.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp
index 14ac4b21..677460a 100644
--- a/llvm/lib/CodeGen/CommandFlags.cpp
+++ b/llvm/lib/CodeGen/CommandFlags.cpp
@@ -96,6 +96,7 @@ CGOPT_EXP(bool, EmulatedTLS)
CGOPT_EXP(bool, EnableTLSDESC)
CGOPT(bool, UniqueSectionNames)
CGOPT(bool, UniqueBasicBlockSectionNames)
+CGOPT(bool, SeparateNamedSections)
CGOPT(EABI, EABIVersion)
CGOPT(DebuggerKind, DebuggerTuningOpt)
CGOPT(bool, EnableStackSizeSection)
@@ -419,6 +420,12 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
cl::init(false));
CGBINDOPT(UniqueBasicBlockSectionNames);
+ static cl::opt<bool> SeparateNamedSections(
+ "separate-named-sections",
+ cl::desc("Use separate unique sections for named sections"),
+ cl::init(false));
+ CGBINDOPT(SeparateNamedSections);
+
static cl::opt<EABI> EABIVersion(
"meabi", cl::desc("Set EABI type (default depends on triple):"),
cl::init(EABI::Default),
@@ -569,6 +576,7 @@ codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) {
Options.BBSections = getBBSectionsMode(Options);
Options.UniqueSectionNames = getUniqueSectionNames();
Options.UniqueBasicBlockSectionNames = getUniqueBasicBlockSectionNames();
+ Options.SeparateNamedSections = getSeparateNamedSections();
Options.TLSSize = getTLSSize();
Options.EmulatedTLS =
getExplicitEmulatedTLS().value_or(TheTriple.hasDefaultEmulatedTLS());