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

Ruoyu Qiu via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 31 03:06:54 PDT 2025


================
@@ -3826,6 +3841,10 @@ int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) {
       !DisassembleSymbols.empty())
     Disassemble = true;
 
+  if (!Disassemble && MCPU == "help") {
+    return MCPUHelp();
+  }
----------------
cabbaken wrote:

If we don't return here, `llvm-objdump --triple=x86_64 --mcpu=help` will eventually reach `return 2;` later in the code, indicating an abnormal exit.
Would it be better to place the return statement right after the `T->printHelp()` and and include a check (if `mcpu=="help"`) within the existing long conditional block?
Here's what I mean:
```diff
@@ -3840,15 +3842,11 @@ int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) {
       !DisassembleSymbols.empty())
     Disassemble = true;
 
-  if (!Disassemble && MCPU == "help") {
-    return MCPUHelp();
-  }
-
   if (!ArchiveHeaders && !Disassemble && DwarfDumpType == DIDT_Null &&
       !DynamicRelocations && !FileHeaders && !PrivateHeaders && !RawClangAST &&
       !Relocations && !SectionHeaders && !SectionContents && !SymbolTable &&
       !DynamicSymbolTable && !UnwindInfo && !FaultMapSection && !Offloading &&
-      !(MachOOpt &&
+      !(MachOOpt && MCPU != "help" &&
         (Bind || DataInCode || ChainedFixups || DyldInfo || DylibId ||
          DylibsUsed || ExportsTrie || FirstPrivateHeader ||
          FunctionStartsType != FunctionStartsMode::None || IndirectSymbols ||
@@ -3858,6 +3856,9 @@ int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) {
     return 2;
   }
 
+  if (!Disassemble && MCPU == "help")
+    mcpuHelp();
+
   DisasmSymbolSet.insert_range(DisassembleSymbols);
 
   llvm::for_each(InputFilenames, dumpInput);
```

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


More information about the llvm-commits mailing list