[llvm] a6d2385 - [AArch64] Fallback to DWARF when trying to emit compact unwind info with multiple CFA offset adjustments

Momchil Velikov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 08:34:07 PDT 2022


Author: Momchil Velikov
Date: 2022-03-23T15:32:42Z
New Revision: a6d238536d95e5c9c49ef2acf1916c95ab087240

URL: https://github.com/llvm/llvm-project/commit/a6d238536d95e5c9c49ef2acf1916c95ab087240
DIFF: https://github.com/llvm/llvm-project/commit/a6d238536d95e5c9c49ef2acf1916c95ab087240.diff

LOG: [AArch64] Fallback to DWARF when trying to emit compact unwind info with multiple CFA offset adjustments

Instead of asserting, fallback to emitting DWARF unwind info when an
attempt is made to output compact unwind info for a function with
multiple adjustments to the CFA offset.

Multiple adjustments of SP are common and with instruction precise
unwind tables these may translate into multiple `.cfi_def_cfa_offset`
directives.

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=1302998

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D121017

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
    llvm/test/MC/AArch64/arm64-compact-unwind-fallback.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
index 83d33ac59e21f..85b221286ecd0 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -621,7 +621,8 @@ class DarwinAArch64AsmBackend : public AArch64AsmBackend {
         break;
       }
       case MCCFIInstruction::OpDefCfaOffset: {
-        assert(StackSize == 0 && "We already have the CFA offset!");
+        if (StackSize != 0)
+          return CU::UNWIND_ARM64_MODE_DWARF;
         StackSize = std::abs(Inst.getOffset());
         break;
       }

diff  --git a/llvm/test/MC/AArch64/arm64-compact-unwind-fallback.s b/llvm/test/MC/AArch64/arm64-compact-unwind-fallback.s
index f4bb9147464d7..12525b78a274b 100644
--- a/llvm/test/MC/AArch64/arm64-compact-unwind-fallback.s
+++ b/llvm/test/MC/AArch64/arm64-compact-unwind-fallback.s
@@ -5,11 +5,21 @@
 
 // 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
 
-_cfi_dwarf:
+//  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


        


More information about the llvm-commits mailing list