mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add option to disable leaf frame pointer elimination
This commit is contained in:
@@ -191,6 +191,7 @@ public:
|
||||
unsigned DisableLLVMSLPVectorizer : 1;
|
||||
|
||||
/// Disable frame pointer elimination?
|
||||
unsigned DisableFPElimLeaf : 1;
|
||||
unsigned DisableFPElim : 1;
|
||||
|
||||
/// Special codegen for playgrounds.
|
||||
@@ -319,6 +320,7 @@ public:
|
||||
DisableClangModuleSkeletonCUs(false), UseJIT(false),
|
||||
DisableLLVMOptzns(false),
|
||||
DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
|
||||
DisableFPElimLeaf(false),
|
||||
DisableFPElim(true), Playground(false), EmitStackPromotionChecks(false),
|
||||
FunctionSections(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
|
||||
HasValueNamesSetting(false), ValueNames(false),
|
||||
|
||||
@@ -1010,6 +1010,10 @@ def enable_private_imports : Flag<["-"], "enable-private-imports">,
|
||||
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
|
||||
HelpText<"Allows this module's internal and private API to be accessed">;
|
||||
|
||||
def disable_leaf_frame_pointer_elim : Flag<["-"], "no-omit-leaf-frame-pointer">,
|
||||
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
|
||||
HelpText<"Don't omit the frame pointer for leaf functions">;
|
||||
|
||||
def sanitize_EQ : CommaJoined<["-"], "sanitize=">,
|
||||
Flags<[FrontendOption, NoInteractiveOption]>, MetaVarName<"<check>">,
|
||||
HelpText<"Turn on runtime checks for erroneous behavior.">;
|
||||
|
||||
@@ -287,6 +287,8 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
|
||||
arguments.push_back("-enable-anonymous-context-mangled-names");
|
||||
}
|
||||
|
||||
inputArgs.AddLastArg(arguments, options::OPT_disable_leaf_frame_pointer_elim);
|
||||
|
||||
// Pass through any subsystem flags.
|
||||
inputArgs.AddAllArgs(arguments, options::OPT_Xllvm);
|
||||
inputArgs.AddAllArgs(arguments, options::OPT_Xcc);
|
||||
|
||||
@@ -1511,6 +1511,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
getRuntimeCompatVersion();
|
||||
}
|
||||
|
||||
if (Args.hasArg(OPT_disable_leaf_frame_pointer_elim))
|
||||
Opts.DisableFPElimLeaf = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -988,7 +988,8 @@ bool swift::irgen::shouldRemoveTargetFeature(StringRef feature) {
|
||||
|
||||
void IRGenModule::setHasFramePointer(llvm::AttrBuilder &Attrs,
|
||||
bool HasFramePointer) {
|
||||
Attrs.addAttribute("frame-pointer", HasFramePointer ? "non-leaf" : "none");
|
||||
auto UseFramePointer = IRGen.Opts.DisableFPElimLeaf ? "all" : "non-leaf";
|
||||
Attrs.addAttribute("frame-pointer", HasFramePointer ? UseFramePointer : "none");
|
||||
}
|
||||
|
||||
void IRGenModule::setHasFramePointer(llvm::Function *F,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=CHECK
|
||||
// RUN: %target-swift-frontend -primary-file %s -emit-ir -no-omit-leaf-frame-pointer| %FileCheck %s --check-prefix=CHECK-ALL
|
||||
// RUN: %target-swift-frontend -primary-file %s -S | %FileCheck %s --check-prefix=CHECKASM --check-prefix=CHECKASM-%target-os-%target-cpu
|
||||
|
||||
sil_stage canonical
|
||||
@@ -30,6 +31,19 @@ entry(%i : $Int32):
|
||||
|
||||
// CHECK: attributes [[ATTR]] = {{{.*}}"frame-pointer"="non-leaf"
|
||||
|
||||
// CHECK-ALL: define{{.*}} swiftcc i32 @leaf_function_no_frame_pointer(i32 %0) [[ATTR:#.*]] {
|
||||
// CHECK-ALL: entry:
|
||||
// CHECK-ALL: ret i32 %0
|
||||
// CHECK-ALL: }
|
||||
|
||||
// CHECK-ALL: define{{.*}} swiftcc i32 @non_leaf_function_with_frame_pointer(i32 %0) [[ATTR]] {
|
||||
// CHECK-ALL: entry:
|
||||
// CHECK-ALL: %1 = call swiftcc i32 @leaf_function_no_frame_pointer(i32 %0)
|
||||
// CHECK-ALL: ret i32 %1
|
||||
// CHECK-ALL: }
|
||||
|
||||
// CHECK-ALL: attributes [[ATTR]] = {{{.*}}"frame-pointer"="all"
|
||||
|
||||
// Silence other os-archs.
|
||||
// CHECKASM: {{.*}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user