[llvm] [llvm-objdump] Default to --mattr=+special for AVR (PR #174731)
Ruoyu Qiu via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 7 03:49:39 PST 2026
https://github.com/cabbaken updated https://github.com/llvm/llvm-project/pull/174731
>From aad76db8c3278e40c82b191504430f981bb0c9ca Mon Sep 17 00:00:00 2001
From: RuoyuQiu <cabbaken at outlook.com>
Date: Wed, 7 Jan 2026 09:56:57 +0000
Subject: [PATCH 1/2] GNU objdump disassembles all unknown instructions by
default. Match this user friendly behavior with the target feature "special"
designed for disassemblers.
Signed-off-by: RuoyuQiu <cabbaken at outlook.com>
---
llvm/include/llvm/TargetParser/Triple.h | 2 ++
llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s | 22 ++++++++++++++++++++
llvm/tools/llvm-objdump/llvm-objdump.cpp | 2 ++
3 files changed, 26 insertions(+)
create mode 100644 llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index e8aa43a2337c7..8320f2d569fc5 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -1043,6 +1043,8 @@ class Triple {
: PointerWidth == 64;
}
+ bool isAVR() const { return getArch() == Triple::avr; }
+
/// Tests whether the target is 32-bit LoongArch.
bool isLoongArch32() const { return getArch() == Triple::loongarch32; }
diff --git a/llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s b/llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s
new file mode 100644
index 0000000000000..e438095bc4a77
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s
@@ -0,0 +1,22 @@
+## When --mattr and --mcpu are both empty, disassemble all known instructions.
+# RUN: llvm-mc -filetype=obj -triple=avr -mattr=+special %s -o %t
+# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefixes=CHECK,ALL
+
+## If --mattr or --mcpu is specified, don't default to --mattr=+special.
+# RUN: llvm-objdump -d --no-show-raw-insn --mattr=+avr2 %t | FileCheck %s --check-prefixes=CHECK,UNKNOWN
+# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=avr2 %t | FileCheck %s --check-prefixes=CHECK,UNKNOWN
+
+# CHECK-LABEL: <_start>:
+# ALL-NEXT: call 0x0
+# ALL-NEXT: jmp 0x0
+# ALL-NEXT: rjmp .-2
+# UNKNOWN-COUNT-2: <unknown>
+# UNKNOWN: rjmp .-2
+
+.globl _start
+_start:
+; Valid in avr3, Invalid in avr2
+ call dummp_symbol
+ jmp dummp_symbol
+; Valid in both
+ rjmp dummp_symbol
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 29173b765f386..32599c809b864 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -2689,6 +2689,8 @@ static void disassembleObject(ObjectFile *Obj, bool InlineRelocs,
Features.AddFeature(MAttrs[I]);
} else if (MCPU.empty() && Obj->makeTriple().isAArch64()) {
Features.AddFeature("+all");
+ } else if (MCPU.empty() && Obj->makeTriple().isAVR()) {
+ Features.AddFeature("+special");
}
if (MCPU.empty())
>From 9602a5796c0d468239c5785d7bb6f2892c69858c Mon Sep 17 00:00:00 2001
From: Ruoyu Qiu <cabbaken at outlook.com>
Date: Wed, 7 Jan 2026 11:48:42 +0000
Subject: [PATCH 2/2] Fix misspelling
Signed-off-by: Ruoyu Qiu <cabbaken at outlook.com>
---
llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s b/llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s
index e438095bc4a77..512a899f02e16 100644
--- a/llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s
+++ b/llvm/test/tools/llvm-objdump/ELF/AVR/mattr.s
@@ -16,7 +16,7 @@
.globl _start
_start:
; Valid in avr3, Invalid in avr2
- call dummp_symbol
- jmp dummp_symbol
+ call foo
+ jmp foo
; Valid in both
- rjmp dummp_symbol
+ rjmp foo
More information about the llvm-commits
mailing list