[PATCH] D134640: Unwind-tables: move back to original logic outline for kind.
Tim Northover via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 26 06:23:20 PDT 2022
t.p.northover created this revision.
t.p.northover added a reviewer: abrachet.
Herald added a subscriber: mcrosier.
Herald added a project: All.
t.p.northover requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.
There are lots of options interacting in complex ways here, and when moving to `getDefaultUnwindTableLevel` I had refactored this and changed behaviour in some cases (see tests added). So this reverts the basic structure of the logic back to the original (prior to 4388b56d52 <https://reviews.llvm.org/rG4388b56d525c08ce3cf941cfbad2428b0e1695b0>), while leaving the hook in the new style so targets remain simpler.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134640
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/clang-translation.c
Index: clang/test/Driver/clang-translation.c
===================================================================
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -99,6 +99,17 @@
//
// ARM64-EXPLICIT-UWTABLE-APPLE: -funwind-tables
+// RUN: %clang -target arm64-apple-macosx -### -ffreestanding -fasynchronous-unwind-tables %s 2>&1 | \
+// RUN: FileCheck --check-prefix=ASYNC-UNWIND-FREESTANDING %s
+//
+// ASYNC-UNWIND-FREESTANDING: -funwind-tables=2
+
+// Quite weird behaviour, but it's a long-standing default.
+// RUN: %clang -target x86_64-apple-macosx -### -fno-unwind-tables %s 2>&1 |\
+// RUN: FileCheck --check-prefix=NOUNWIND-IGNORED %s
+//
+// NOUNWIND-IGNORED: -funwind-tables=2
+
// RUN: %clang -target arm64-apple-ios10 -fno-exceptions -### -S %s -arch arm64 2>&1 | \
// RUN: FileCheck -check-prefix=ARM64-APPLE-EXCEP %s
// ARM64-APPLE-EXCEP-NOT: -funwind-tables
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5472,27 +5472,24 @@
// -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
// complicated ways.
auto SanitizeArgs = TC.getSanitizerArgs(Args);
- auto UnwindTables = TC.getDefaultUnwindTableLevel(Args);
-
- const bool HasSyncUnwindTables = Args.hasFlag(
- options::OPT_funwind_tables, options::OPT_fno_unwind_tables, false);
- if (Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
- options::OPT_fno_asynchronous_unwind_tables,
- SanitizeArgs.needsUnwindTables()) &&
- !Freestanding)
- UnwindTables = ToolChain::UnwindTableLevel::Asynchronous;
- else if (HasSyncUnwindTables)
- UnwindTables = ToolChain::UnwindTableLevel::Synchronous;
- else if (Args.hasFlag(options::OPT_fno_unwind_tables,
- options::OPT_fno_asynchronous_unwind_tables,
- options::OPT_funwind_tables, false) || Freestanding)
- UnwindTables = ToolChain::UnwindTableLevel::None;
-
-
- if (UnwindTables == ToolChain::UnwindTableLevel::Synchronous)
- CmdArgs.push_back("-funwind-tables=1");
- else if (UnwindTables == ToolChain::UnwindTableLevel::Asynchronous)
+
+ bool IsAsyncUnwindTablesDefault =
+ TC.getDefaultUnwindTableLevel(Args) == ToolChain::UnwindTableLevel::Asynchronous;
+ bool IsSyncUnwindTablesDefault =
+ TC.getDefaultUnwindTableLevel(Args) == ToolChain::UnwindTableLevel::Synchronous;
+
+ bool AsyncUnwindTables = Args.hasFlag(
+ options::OPT_fasynchronous_unwind_tables,
+ options::OPT_fno_asynchronous_unwind_tables,
+ (IsAsyncUnwindTablesDefault || SanitizeArgs.needsUnwindTables()) &&
+ !Freestanding);
+ bool UnwindTables =
+ Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
+ IsSyncUnwindTablesDefault && !Freestanding);
+ if (AsyncUnwindTables)
CmdArgs.push_back("-funwind-tables=2");
+ else if (UnwindTables)
+ CmdArgs.push_back("-funwind-tables=1");
// Prepare `-aux-target-cpu` and `-aux-target-feature` unless
// `--gpu-use-aux-triple-only` is specified.
@@ -7318,7 +7315,7 @@
CmdArgs.push_back("-faddrsig");
if ((Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
- (EH || UnwindTables != ToolChain::UnwindTableLevel::None ||
+ (EH || UnwindTables || AsyncUnwindTables ||
DebugInfoKind != codegenoptions::NoDebugInfo))
CmdArgs.push_back("-D__GCC_HAVE_DWARF2_CFI_ASM=1");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134640.462886.patch
Type: text/x-patch
Size: 3569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220926/6c25735b/attachment.bin>
More information about the cfe-commits
mailing list