[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 04:47:01 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:
This PR should test the behaviour you are adding/changing. I believe that's "what does --triple do in conjunction with --mcpu=help and --mattr=help" and "what happens if we specify --mcpu=help if we don't specify a dumping option like -d". To further illustrate the first case, you should ensure there is test coverage for "what target does --mcpu=help print for when --triple is not specified" too. For the second case, we should ensure we don't break the behaviour for when we have specified other dumping options, by ensuring there is adequate test coverage of --mcpu=help + -d and --mcpu=help + --some-other-dump to show that we keep printing in these cases. Having thought more about it, I think it's important to ensure both these combinations exist separately, because of how we're special-casing requests for disassembly in this change.
https://github.com/llvm/llvm-project/pull/165661
More information about the llvm-commits
mailing list