AAArch64: disable asynchronous unwind by default for MachO.
authorTim Northover <tnorthover@apple.com>
Fri, 9 Sep 2022 09:46:23 +0000 (10:46 +0100)
committerTim Northover <tnorthover@apple.com>
Tue, 20 Sep 2022 09:47:18 +0000 (10:47 +0100)
AArch64 MachO has a compact unwind format where most functions' unwind info can
be represented in just 4 bytes. But this cannot represent any asynchronous CFI
function, so it's essentially disabled when that's used. This is a large
code-size hit that we'd rather not take unless explicitly requested.

clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/clang-translation.c

index e466ce9..50572ff 100644 (file)
@@ -2932,7 +2932,8 @@ ToolChain::UnwindTableLevel MachO::getDefaultUnwindTableLevel(const ArgList &Arg
       (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
        Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
                     true)))
-    return UnwindTableLevel::Asynchronous;
+    return getArch() == llvm::Triple::aarch64 ? UnwindTableLevel::Synchronous
+                                              : UnwindTableLevel::Asynchronous;
 
   return UnwindTableLevel::None;
 }
index c471c6a..ffa732c 100644 (file)
 
 // RUN: %clang -target arm64-apple-ios10 -### -S %s -arch arm64 2>&1 | \
 // RUN: FileCheck -check-prefix=ARM64-APPLE %s
-// ARM64-APPLE: -funwind-tables=2
+// ARM64-APPLE: -funwind-tables=1
+
+// RUN: %clang -target arm64-apple-ios10 -funwind-tables -### -S %s -arch arm64 2>&1 | \
+// RUN: FileCheck -check-prefix=ARM64-APPLE-UNWIND %s
+// ARM64-APPLE-UNWIND: -funwind-tables=1
 
 // RUN: %clang -target arm64-apple-ios10 -### -ffreestanding -S %s -arch arm64 2>&1 | \
 // RUN: FileCheck -check-prefix=ARM64-FREESTANDING-APPLE %s