[PATCH] D134691: [MC] Don't emit redundant compact unwind entries

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 19:15:55 PDT 2022


int3 updated this revision to Diff 463075.
int3 added a comment.

update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134691/new/

https://reviews.llvm.org/D134691

Files:
  llvm/lib/MC/MCStreamer.cpp
  llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_compact_unwind.s
  llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
  llvm/test/MC/AArch64/arm64_32-compact-unwind.s


Index: llvm/test/MC/AArch64/arm64_32-compact-unwind.s
===================================================================
--- llvm/test/MC/AArch64/arm64_32-compact-unwind.s
+++ llvm/test/MC/AArch64/arm64_32-compact-unwind.s
@@ -5,11 +5,12 @@
 ; references to addresses (function, personality, LSDA) are pointer-sized.
 
 ; CHECK: Contents of section __LD,__compact_unwind:
-; CHECK-NEXT:  0004 00000000 04000000 00000002 00000000
+; CHECK-NEXT:  0004 00000000 04000000 00100002 00000000
 ; CHECK-NEXT:  0014 00000000
         .globl  _test_compact_unwind
         .align  2
 _test_compact_unwind:
         .cfi_startproc
+        .cfi_def_cfa_offset 16
         ret
         .cfi_endproc
Index: llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
===================================================================
--- llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
+++ llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
@@ -6,18 +6,14 @@
 
 # CHECK:      Contents of __compact_unwind section:
 # CHECK-NEXT:   Entry at offset 0x0:
-# CHECK-NEXT:     start:                0x0 ltmp0
-# CHECK-NEXT:     length:               0x8
-# CHECK-NEXT:     compact encoding:     0x02000000
-# CHECK-NEXT:   Entry at offset 0x20:
 # CHECK-NEXT:     start:                0x8 _foo2
 # CHECK-NEXT:     length:               0x40
 # CHECK-NEXT:     compact encoding:     0x02009000
-# CHECK-NEXT:   Entry at offset 0x40:
+# CHECK-NEXT:   Entry at offset 0x20:
 # CHECK-NEXT:     start:                0x48 _foo3
 # CHECK-NEXT:     length:               0xd4
 # CHECK-NEXT:     compact encoding:     0x0200400f
-# CHECK-NEXT:   Entry at offset 0x60:
+# CHECK-NEXT:   Entry at offset 0x40:
 # CHECK-NEXT:     start:                0x11c _foo4
 # CHECK-NEXT:     length:               0x54
 # CHECK-NEXT:     compact encoding:     0x02021010
Index: llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_compact_unwind.s
===================================================================
--- llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_compact_unwind.s
+++ llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_compact_unwind.s
@@ -13,6 +13,7 @@
 	.p2align	2
 _main:
 	.cfi_startproc
+  .cfi_def_cfa_offset 16
 	ret
 	.cfi_endproc
 
Index: llvm/lib/MC/MCStreamer.cpp
===================================================================
--- llvm/lib/MC/MCStreamer.cpp
+++ llvm/lib/MC/MCStreamer.cpp
@@ -124,9 +124,12 @@
 void MCStreamer::emitExplicitComments() {}
 
 void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) {
-  for (auto &FI : DwarfFrameInfos)
+  for (auto &FI : DwarfFrameInfos) {
+    if (!MAB || FI.Instructions.empty() && !FI.Personality && !FI.Lsda)
+      continue;
     FI.CompactUnwindEncoding =
-        (MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0);
+        MAB->generateCompactUnwindEncoding(FI.Instructions);
+  }
 }
 
 /// EmitIntValue - Special case of EmitValue that avoids the client having to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134691.463075.patch
Type: text/x-patch
Size: 2945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220927/b4e8acd1/attachment.bin>


More information about the llvm-commits mailing list