AArch64: take compact unwind frame size from last CFI instruction.
authorTim Northover <tnorthover@apple.com>
Mon, 7 Mar 2022 15:12:57 +0000 (15:12 +0000)
committerTim Northover <tnorthover@apple.com>
Mon, 11 Apr 2022 11:24:48 +0000 (12:24 +0100)
Asynchronous exception support for the prologue means that there can be
multiple .cfi_def_cfa_offset instructions in a single function, which tripped
up an assertion in the compact unwind generator.

In reality the compact unwind format is far too restrictive to represent
asynchronous frames so if we ever wanted that on Darwin we'd fall back to DWARF
(possibly keeping compact unwind around for synchronous users). So the compact
format should continue to represent the synchronous situation, and the
assertion can be removed.

llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
llvm/test/CodeGen/AArch64/compact-unwind-async.ll [new file with mode: 0644]
llvm/test/MC/AArch64/arm64-compact-unwind-fallback.s

index 85b2212..04d9b49 100644 (file)
@@ -621,8 +621,6 @@ public:
         break;
       }
       case MCCFIInstruction::OpDefCfaOffset: {
-        if (StackSize != 0)
-          return CU::UNWIND_ARM64_MODE_DWARF;
         StackSize = std::abs(Inst.getOffset());
         break;
       }
diff --git a/llvm/test/CodeGen/AArch64/compact-unwind-async.ll b/llvm/test/CodeGen/AArch64/compact-unwind-async.ll
new file mode 100644 (file)
index 0000000..f1d0935
--- /dev/null
@@ -0,0 +1,11 @@
+; RUN: llc -mtriple=arm64-apple-macosx %s -filetype=obj -o - | llvm-objdump --unwind-info - | FileCheck %s
+
+; CHECK: Contents of __compact_unwind section
+; CHECK: compact encoding: 0x02021010
+
+; 0x02|021|010 => frameless, stack size 0x21 * 16 = 528, x27 & x28 saved
+
+define void @func() {
+  alloca i8, i32 512
+  ret void
+}
index 12525b7..d2a0787 100644 (file)
@@ -5,21 +5,11 @@
 
 // CHECK: Contents of __compact_unwind section:
 // CHECK: compact encoding:     0x03000000
-// CHECK: compact encoding:     0x03000000
 
 // CHECK: .eh_frame contents:
 // CHECK: DW_CFA_def_cfa: reg1 +32
 
-//  DW_CFA_def_cfa_offset: +32
-//  DW_CFA_def_cfa_offset: +64
-
 _cfi_dwarf0:
  .cfi_startproc
  .cfi_def_cfa x1, 32;
  .cfi_endproc
-
-_cfi_dwarf1:
- .cfi_startproc
- .cfi_def_cfa_offset 32
- .cfi_def_cfa_offset 64
- .cfi_endproc