forked from OSchip/llvm-project
Add a new frontend flag `-fswift-async-fp={auto|always|never}`
Summary: Introduce a new frontend flag `-fswift-async-fp={auto|always|never}` that controls how code generation sets the Swift extended async frame info bit. There are three possibilities: * `auto`: which determines how to set the bit based on deployment target, either statically or dynamically via `swift_async_extendedFramePointerFlags`. * `always`: default, always set the bit statically, regardless of deployment target. * `never`: never set the bit, regardless of deployment target. Differential Revision: https://reviews.llvm.org/D109451
This commit is contained in:
parent
cfc7402419
commit
f670c5aeee
|
@ -440,6 +440,11 @@ CODEGENOPT(AAPCSBitfieldWidth, 1, 1)
|
|||
/// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only)
|
||||
CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1)
|
||||
|
||||
// Whether to emit Swift Async function extended frame information: auto,
|
||||
// never, always.
|
||||
ENUM_CODEGENOPT(SwiftAsyncFramePointer, SwiftAsyncFramePointerKind, 2,
|
||||
SwiftAsyncFramePointerKind::Always)
|
||||
|
||||
#undef CODEGENOPT
|
||||
#undef ENUM_CODEGENOPT
|
||||
#undef VALUE_CODEGENOPT
|
||||
|
|
|
@ -125,6 +125,13 @@ public:
|
|||
All, // Keep all frame pointers.
|
||||
};
|
||||
|
||||
enum class SwiftAsyncFramePointerKind {
|
||||
Auto, // Choose Swift async extended frame info based on deployment target.
|
||||
Always, // Unconditionally emit Swift async extended frame info.
|
||||
Never, // Don't emit Swift async extended frame info.
|
||||
Default = Always,
|
||||
};
|
||||
|
||||
enum FiniteLoopsKind {
|
||||
Language, // Not specified, use language standard.
|
||||
Always, // All loops are assumed to be finite.
|
||||
|
|
|
@ -1275,6 +1275,13 @@ def fprofile_list_EQ : Joined<["-"], "fprofile-list=">,
|
|||
Group<f_Group>, Flags<[CC1Option, CoreOption]>,
|
||||
HelpText<"Filename defining the list of functions/files to instrument">,
|
||||
MarshallingInfoStringVector<LangOpts<"ProfileListFiles">>;
|
||||
def fswift_async_fp_EQ : Joined<["-"], "fswift-async-fp=">,
|
||||
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, MetaVarName<"<option>">,
|
||||
HelpText<"Control emission of Swift async extended frame info (option: auto, always, never)">,
|
||||
Values<"auto,always,never">,
|
||||
NormalizedValuesScope<"CodeGenOptions::SwiftAsyncFramePointerKind">,
|
||||
NormalizedValues<["Auto", "Always", "Never"]>,
|
||||
MarshallingInfoEnum<CodeGenOpts<"SwiftAsyncFramePointer">, "Always">;
|
||||
|
||||
defm addrsig : BoolFOption<"addrsig",
|
||||
CodeGenOpts<"Addrsig">, DefaultFalse,
|
||||
|
|
|
@ -582,6 +582,21 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
|
|||
Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
|
||||
Options.LoopAlignment = CodeGenOpts.LoopAlignment;
|
||||
|
||||
switch (CodeGenOpts.getSwiftAsyncFramePointer()) {
|
||||
case CodeGenOptions::SwiftAsyncFramePointerKind::Auto:
|
||||
Options.SwiftAsyncFramePointer =
|
||||
SwiftAsyncFramePointerMode::DeploymentBased;
|
||||
break;
|
||||
|
||||
case CodeGenOptions::SwiftAsyncFramePointerKind::Always:
|
||||
Options.SwiftAsyncFramePointer = SwiftAsyncFramePointerMode::Always;
|
||||
break;
|
||||
|
||||
case CodeGenOptions::SwiftAsyncFramePointerKind::Never:
|
||||
Options.SwiftAsyncFramePointer = SwiftAsyncFramePointerMode::Never;
|
||||
break;
|
||||
}
|
||||
|
||||
Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
|
||||
Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
|
||||
Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
|
||||
|
|
|
@ -5912,6 +5912,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
RenderSCPOptions(TC, Args, CmdArgs);
|
||||
RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);
|
||||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_fswift_async_fp_EQ);
|
||||
|
||||
// Translate -mstackrealign
|
||||
if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
|
||||
false))
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
// RUN: %clang_cc1 -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
|
||||
// RUN: %clang_cc1 -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
|
||||
// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=NEVER-X86
|
||||
// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=NEVER-X86
|
||||
// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=AUTO-X86
|
||||
// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
|
||||
// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple x86_64-apple-darwin10 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
|
||||
// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple x86_64-apple-darwin12 -target-cpu core2 -S -o - %s | FileCheck %s --check-prefix=ALWAYS-X86
|
||||
|
||||
// RUN: %clang_cc1 -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
|
||||
// RUN: %clang_cc1 -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
|
||||
// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=AUTO-ARM64
|
||||
// RUN: %clang_cc1 -fswift-async-fp=auto -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
|
||||
// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=NEVER-ARM64
|
||||
// RUN: %clang_cc1 -fswift-async-fp=never -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=NEVER-ARM64
|
||||
// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple arm64-apple-ios9 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
|
||||
// RUN: %clang_cc1 -fswift-async-fp=always -mframe-pointer=all -triple arm64-apple-ios15 -target-cpu cyclone -S -o - %s | FileCheck %s --check-prefix=ALWAYS-ARM64
|
||||
|
||||
// REQUIRES: aarch64-registered-target,x86-registered-target
|
||||
|
||||
#define SWIFTASYNCCALL __attribute__((swiftasynccall))
|
||||
#define ASYNC_CONTEXT __attribute__((swift_async_context))
|
||||
|
||||
SWIFTASYNCCALL void async_context_1(ASYNC_CONTEXT void *ctx) {}
|
||||
|
||||
// AUTO-X86: _async_context_1:
|
||||
// AUTO-X86: _swift_async_extendedFramePointerFlags
|
||||
|
||||
// ALWAYS-X86: _async_context_1:
|
||||
// ALWAYS-X86: btsq $60
|
||||
|
||||
// NEVER-X86: _async_context_1:
|
||||
// NEVER-X86-NOT: _swift_async_extendedFramePointerFlags
|
||||
// NEVER-X86-NOT: btsq $60
|
||||
|
||||
// AUTO-ARM64: _async_context_1
|
||||
// AUTO-ARM64: _swift_async_extendedFramePointerFlags
|
||||
|
||||
// ALWAYS-ARM64: _async_context_1
|
||||
// ALWAYS-ARM64: orr x29, x29, #0x1000000000000000
|
||||
|
||||
// NEVER-ARM64: _async_context_1:
|
||||
// NEVER-ARM64-NOT: _swift_async_extendedFramePointerFlags
|
||||
// NEVER-ARM64-NOT: orr x29, x29, #0x1000000000000000
|
Loading…
Reference in New Issue