[PATCH] D47593: [MC] Fallback on DWARF when generating compact unwind on AArch64

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 31 09:37:34 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL333667: [MC] Fallback on DWARF when generating compact unwind on AArch64 (authored by thegameg, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47593?vs=149301&id=149306#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47593

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


Index: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
===================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -455,9 +455,17 @@
         return CU::UNWIND_ARM64_MODE_DWARF;
       case MCCFIInstruction::OpDefCfa: {
         // Defines a frame pointer.
-        assert(getXRegFromWReg(MRI.getLLVMRegNum(Inst.getRegister(), true)) ==
-                   AArch64::FP &&
-               "Invalid frame pointer!");
+        unsigned XReg =
+            getXRegFromWReg(MRI.getLLVMRegNum(Inst.getRegister(), true));
+
+        // Other CFA registers than FP are not supported by compact unwind.
+        // Fallback on DWARF.
+        // FIXME: When opt-remarks are supported in MC, add a remark to notify
+        // the user.
+        if (XReg != AArch64::FP)
+          return CU::UNWIND_ARM64_MODE_DWARF;
+
+        assert(XReg == AArch64::FP && "Invalid frame pointer!");
         assert(i + 2 < e && "Insufficient CFI instructions to define a frame!");
 
         const MCCFIInstruction &LRPush = Instrs[++i];
Index: llvm/trunk/test/MC/AArch64/arm64-compact-unwind-fallback.s
===================================================================
--- llvm/trunk/test/MC/AArch64/arm64-compact-unwind-fallback.s
+++ llvm/trunk/test/MC/AArch64/arm64-compact-unwind-fallback.s
@@ -0,0 +1,15 @@
+// RUN: llvm-mc -triple=arm64-apple-ios -filetype=obj %s -o %t
+// RUN: llvm-objdump -macho -unwind-info -dwarf=frames %t | FileCheck %s
+
+// Check that we fallback on DWARF instead of asserting.
+
+// CHECK: Contents of __compact_unwind section:
+// CHECK: compact encoding:     0x03000000
+
+// CHECK: .eh_frame contents:
+// CHECK: DW_CFA_def_cfa: reg1 +32
+
+_cfi_dwarf:
+ .cfi_startproc
+ .cfi_def_cfa x1, 32;
+ .cfi_endproc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47593.149306.patch
Type: text/x-patch
Size: 1890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180531/4550711c/attachment.bin>


More information about the llvm-commits mailing list