Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions llvm/test/CodeGen/AArch64/memtag-compact-unwind.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; RUN: llc -mtriple=arm64-apple-macosx -mattr=+mte %s -filetype=obj -o %t.o
; RUN: llvm-objdump --unwind-info %t.o | FileCheck %s

; Frames with MTE stack tagging must use DWARF unwinding because compact unwind
; doesn't handle MTE tag untagging during exception unwinding.

; MTE-tagged frame should use DWARF mode (0x03000000)
; CHECK-LABEL: Contents of __compact_unwind section:
; CHECK: compact encoding: 0x03000000

; Normal frame should NOT use DWARF mode
; CHECK-NOT: compact encoding: 0x03000000
; CHECK: compact encoding: 0x{{[0-9a-f]+}}

define void @mte_tagged_frame() sanitize_memtag "frame-pointer"="all" {
%x = alloca i32, align 4
store i32 42, ptr %x
call void asm sideeffect "", "r"(ptr %x)
ret void
}

define void @normal_frame() "frame-pointer"="all" {
%x = alloca i32, align 4
store i32 42, ptr %x
call void asm sideeffect "", "r"(ptr %x)
ret void
}