[PATCH] D128030: [llvm-objdump] Default to --mattr=+all for AArch64

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 22:46:01 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: chill, DavidSpickett, dmgreen, jhenderson, SjoerdMeijer, tmatheson, pirama, srhines.
Herald added subscribers: StephenFan, rupprecht, kristof.beyls, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

GNU objdump disassembles all unknown instructions by default. Match this user
friendly behavior with the target feature "all" (D128029 <https://reviews.llvm.org/D128029>).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128030

Files:
  llvm/docs/CommandGuide/llvm-objdump.rst
  llvm/test/tools/llvm-objdump/ELF/AArch64/mattr.s
  llvm/tools/llvm-objdump/llvm-objdump.cpp


Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1690,9 +1690,12 @@
 
   // Package up features to be passed to target/subtarget
   SubtargetFeatures Features = Obj->getFeatures();
-  if (!MAttrs.empty())
+  if (!MAttrs.empty()) {
     for (unsigned I = 0; I != MAttrs.size(); ++I)
       Features.AddFeature(MAttrs[I]);
+  } else if (MCPU.empty() && Obj->getArch() == llvm::Triple::aarch64) {
+    Features.AddFeature("+all");
+  }
 
   std::unique_ptr<const MCRegisterInfo> MRI(
       TheTarget->createMCRegInfo(TripleName));
Index: llvm/test/tools/llvm-objdump/ELF/AArch64/mattr.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/ELF/AArch64/mattr.s
@@ -0,0 +1,18 @@
+## When --mattr and --mcpu are both empty, disassemble all known instructions.
+# RUN: llvm-mc -filetype=obj -triple=aarch64 -mattr=+all %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=+all.
+# RUN: llvm-objdump -d --no-show-raw-insn --mattr=+v8a %t | FileCheck %s --check-prefixes=CHECK,UNKNOWN
+# RUN: llvm-objdump -d --no-show-raw-insn --mcpu=generic %t | FileCheck %s --check-prefixes=CHECK,UNKNOWN
+
+# CHECK:    <_start>:
+# ALL-NEXT:   bc.eq 0x4
+# ALL-NEXT:   irg x0, x1
+# UNKNOWN-COUNT-2: <unknown>
+# CHECK-EMPTY:
+
+.globl _start
+_start:
+  bc.eq #4
+  irg x0, x1
Index: llvm/docs/CommandGuide/llvm-objdump.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-objdump.rst
+++ llvm/docs/CommandGuide/llvm-objdump.rst
@@ -27,7 +27,11 @@
 
 .. option:: -d, --disassemble
 
-  Disassemble all executable sections found in the input files.
+  Disassemble all executable sections found in the input files. On some
+  architectures (AArch64, x86), all known instructions are disassembled by
+  default. On the others, :option:`--mattr` or :option:`--mattr` is needed to
+  enable some instruction sets. Disabled instructions are displayed as
+  ``<unknown>``.
 
 .. option:: -D, --disassemble-all
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128030.437798.patch
Type: text/x-patch
Size: 2270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220617/88320def/attachment.bin>


More information about the llvm-commits mailing list