From f670c5aeeef09cd7b88e72cf8c1f2505d044a8ea Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Wed, 8 Sep 2021 07:26:08 -0700 Subject: [PATCH] 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 --- clang/include/clang/Basic/CodeGenOptions.def | 5 ++++ clang/include/clang/Basic/CodeGenOptions.h | 7 +++++ clang/include/clang/Driver/Options.td | 7 +++++ clang/lib/CodeGen/BackendUtil.cpp | 15 ++++++++++ clang/lib/Driver/ToolChains/Clang.cpp | 2 ++ clang/test/CodeGen/swift-async-extended-fp.c | 44 ++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+) create mode 100644 clang/test/CodeGen/swift-async-extended-fp.c diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 737d2d7..37900bf 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -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 diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 617c255..6a0bce0 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -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. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 84b22df..f0932a0 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1275,6 +1275,13 @@ def fprofile_list_EQ : Joined<["-"], "fprofile-list=">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Filename defining the list of functions/files to instrument">, MarshallingInfoStringVector>; +def fswift_async_fp_EQ : Joined<["-"], "fswift-async-fp=">, + Group, Flags<[CC1Option, CC1AsOption, CoreOption]>, MetaVarName<"