[llvm] [llvm-objdump] Support --mcpu=help/--mattr=help without -d (PR #165661)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 01:55:44 PST 2025
================
@@ -3826,20 +3853,33 @@ int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) {
!DisassembleSymbols.empty())
Disassemble = true;
- if (!ArchiveHeaders && !Disassemble && DwarfDumpType == DIDT_Null &&
- !DynamicRelocations && !FileHeaders && !PrivateHeaders && !RawClangAST &&
- !Relocations && !SectionHeaders && !SectionContents && !SymbolTable &&
- !DynamicSymbolTable && !UnwindInfo && !FaultMapSection && !Offloading &&
- !(MachOOpt &&
- (Bind || DataInCode || ChainedFixups || DyldInfo || DylibId ||
- DylibsUsed || ExportsTrie || FirstPrivateHeader ||
- FunctionStartsType != FunctionStartsMode::None || IndirectSymbols ||
- InfoPlist || LazyBind || LinkOptHints || ObjcMetaData || Rebase ||
- Rpaths || UniversalHeaders || WeakBind || !FilterSections.empty()))) {
+ const bool PrintCpuHelp = (MCPU == "help" || is_contained(MAttrs, "help"));
+
+ const bool ShouldDump =
+ ArchiveHeaders || Disassemble || DwarfDumpType != DIDT_Null ||
+ DynamicRelocations || FileHeaders || PrivateHeaders || RawClangAST ||
+ Relocations || SectionHeaders || SectionContents || SymbolTable ||
+ DynamicSymbolTable || UnwindInfo || FaultMapSection || Offloading ||
+ (MachOOpt &&
+ (Bind || DataInCode || ChainedFixups || DyldInfo || DylibId ||
+ DylibsUsed || ExportsTrie || FirstPrivateHeader ||
+ FunctionStartsType != FunctionStartsMode::None || IndirectSymbols ||
+ InfoPlist || LazyBind || LinkOptHints || ObjcMetaData || Rebase ||
+ Rpaths || UniversalHeaders || WeakBind || !FilterSections.empty()));
+
+ if (!ShouldDump && !PrintCpuHelp) {
T->printHelp(ToolName);
return 2;
}
+ // If the target triple is derived from the files, we display help message
+ // when disassembling them.
+ if (!Disassemble && PrintCpuHelp) {
----------------
jh7370 wrote:
So by removing `!Disassemble`, we'd no longer defer to printing at the later point and would just print within the new code (and therefore still once only) and the output would ultimately be identical. Is that correct? If so, it's simpler to not have the disassembly special case, so we can remove it, I think.
https://github.com/llvm/llvm-project/pull/165661
More information about the llvm-commits
mailing list