Skip to content

Commit 439d0ca

Browse files
committed
Expose separate function sections option to compiler
1 parent a8baeb3 commit 439d0ca

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ class IRGenOptions {
146146
/// objects.
147147
unsigned EmitStackPromotionChecks : 1;
148148

149+
/// Emit functions to separate sections.
150+
unsigned FunctionSections : 1;
151+
149152
/// The maximum number of bytes used on a stack frame for stack promotion
150153
/// (includes alloc_stack allocations).
151154
unsigned StackPromotionSizeLimit = 1024;
@@ -249,7 +252,7 @@ class IRGenOptions {
249252
IntegratedREPL(false), DisableLLVMOptzns(false),
250253
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
251254
DisableFPElim(true), Playground(false), EmitStackPromotionChecks(false),
252-
PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
255+
FunctionSections(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
253256
HasValueNamesSetting(false), ValueNames(false),
254257
EnableReflectionMetadata(true), EnableReflectionNames(true),
255258
EnableAnonymousContextMangledNames(false), ForcePublicLinkage(false),

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ def disable_reflection_names : Flag<["-"], "disable-reflection-names">,
334334
HelpText<"Disable emission of names of stored properties and enum cases in"
335335
"reflection metadata">;
336336

337+
def function_sections: Flag<["-"], "function-sections">,
338+
Flags<[FrontendOption, NoInteractiveOption]>,
339+
HelpText<"Emit functions to separate sections.">;
340+
337341
def stack_promotion_checks : Flag<["-"], "emit-stack-promotion-checks">,
338342
HelpText<"Emit runtime checks for correct stack promotion of objects.">;
339343

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
11361136
Opts.StackPromotionSizeLimit = limit;
11371137
}
11381138

1139+
Opts.FunctionSections = Args.hasArg(OPT_function_sections);
1140+
11391141
if (Args.hasArg(OPT_autolink_force_load))
11401142
Opts.ForceLoadSymbolName = Args.getLastArgValue(OPT_module_link_name);
11411143

lib/IRGen/IRGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ swift::getIRTargetOptions(IRGenOptions &Opts, ASTContext &Ctx) {
162162
// Explicitly request debugger tuning for LLDB which is the default
163163
// on Darwin platforms but not on others.
164164
TargetOpts.DebuggerTuning = llvm::DebuggerKind::LLDB;
165+
TargetOpts.FunctionSections = Opts.FunctionSections;
165166

166167
auto *Clang = static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
167168
clang::TargetOptions &ClangOpts = Clang->getTargetInfo().getTargetOpts();

0 commit comments

Comments
 (0)