[llvm] [AArch64] Force dwarf unwind for MTE-tagged stack frames (PR #168530)

Dan Blackwell via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 04:54:26 PST 2025


https://github.com/DanBlackwell created https://github.com/llvm/llvm-project/pull/168530

Currently, on Darwin running with -fsanitize=memtag-stack generates compact-unwind exception unwinding that does not untag MTE-tagged memory on the way back up.

This patch forces dwarf unwinding on MTE-tagged frames.

rdar://162195539

>From 754f1caff6088bc90b6b345146dc30bd6de50aaf Mon Sep 17 00:00:00 2001
From: Dan Blackwell <dan_blackwell at apple.com>
Date: Tue, 18 Nov 2025 12:42:39 +0000
Subject: [PATCH] [AArch64] Force dwarf unwind for MTE-tagged stack frames

Currently, running with -fsanitize=memtag-stack generates CompactUnwind exception unwinding that does not untag MTE-tagged memory on the way back up on Darwin.

This patch forces dwarf unwinding on MTE-tagged frames.

rdar://162195539
---
 llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
index 7a2b6790f8a5b..1f9694cf98fec 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -586,6 +586,11 @@ class DarwinAArch64AsmBackend : public AArch64AsmBackend {
   /// Generate the compact unwind encoding from the CFI directives.
   uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
                                          const MCContext *Ctxt) const override {
+    // MTE-tagged frames must use DWARF unwinding because compact unwind
+    // doesn't handle MTE tags
+    if (FI->IsMTETaggedFrame)
+      return CU::UNWIND_ARM64_MODE_DWARF;
+
     ArrayRef<MCCFIInstruction> Instrs = FI->Instructions;
     if (Instrs.empty())
       return CU::UNWIND_ARM64_MODE_FRAMELESS;



More information about the llvm-commits mailing list