[llvm] [llvm-objdump] Add triple support to `mcpu=help` (PR #165661)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 02:01:48 PST 2025


================
@@ -0,0 +1,64 @@
+# RUN: yaml2obj %s -o %t
+# REQUIRES: arm-registered-target,x86-registered-target
+
+
+# CHECK-HELP: Available CPUs for this target:
+# CHECK-ARM: arm
+# CHECK-X86: i386
+# CHECK-HELP: Available features for this target:
+## To check we still disassemble the file:
+# CHECK-DISASM: file format elf32-littlearm
+# CHECK-SECTION-HEADER: Sections:
+# CHECK-SECTION-HEADER: Idx Name            Size     VMA      Type
+## Don't check the OS-dependent message "No such file or directory".
+# CHECK-FILE-ISSUE: error: 'a.out':
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_ARM
+
+## 2. -d + --mcpu=help + a.out
+## Check the error if there is an issue with the file.
+# RUN: not llvm-objdump -d --mcpu=help 2>&1 \
+# RUN:   | FileCheck %s --check-prefix=CHECK-FILE-ISSUE
+# RUN: not llvm-objdump -d --mattr=help 2>&1 \
+# RUN:   | FileCheck %s --check-prefix=CHECK-FILE-ISSUE
+
+## Check if we can handle the default filename.
+# RUN: cp %t a.out
+# RUN: llvm-objdump -d --mcpu=help --section-headers 2>&1 \
+# RUN:   | FileCheck %s --check-prefixes=CHECK-HELP,CHECK-ARM,CHECK-DISASM,CHECK-SECTION-HEADER
+# RUN: llvm-objdump -d --mattr=help --section-headers 2>&1 \
+# RUN:   | FileCheck %s --check-prefixes=CHECK-HELP,CHECK-ARM,CHECK-DISASM,CHECK-SECTION-HEADER
+# RUN: rm a.out
----------------
jh7370 wrote:

These two test cases are rather missing the point of what I wanted to emphasise and aren't anything to do with the --triple option, so shouldn't be in this file, but rather belong in the original test file.

These test cases actually come under the behaviour of "a missing file should be reported if -d is specified, no input file is specified, and a.out is missing", to show that we try to read a.out if dumping options are requested even if --mcpu=help is specified. The counterpoint behaviour is that if --mcpu=help is specified without other dump options, we don't attempt to read an input file. Importantly, we are NOT testing that a.out is the default input file (that should have coverage elsewhere), nor are we testing the general behaviour that a missing file is reported. Rather, we are testing that --mcpu=help with other dump options doesn't suppress errors. We use the default input file as an interesting case, because you could imagine the behaviour being different in this case (it isn't from an explicitly specified file for what we actually do in this case).

https://github.com/llvm/llvm-project/pull/165661


More information about the llvm-commits mailing list