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

Ruoyu Qiu via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 05:02:56 PST 2025


================
@@ -3533,6 +3533,35 @@ commaSeparatedValues(const llvm::opt::InputArgList &InputArgs, int ID) {
   return Values;
 }
 
+static void mcpuHelp() {
+  std::string Error;
+  Triple DummyTriple;
+
+  if (!TripleName.empty())
+    DummyTriple.setTriple(TripleName);
+  else {
+    // If the target triple is derived from the files, we display help message
----------------
cabbaken wrote:

> If Disassemble is true, we should always defer to the existing printing point to print help. Otherwise, if I'm not mistaken, you'll print the help output twice, for this case.

If I understand correctly, the reason we defer to the existing printing point is to avoid printing the help output twice. However, the `Help()` function in MCSubtargetInfo.cpp already controls this using the following static flag:
```c++
static void Help(ArrayRef<StringRef> CPUNames,
                 ArrayRef<SubtargetFeatureKV> FeatTable) {
  static bool PrintOnce = false;
  if (PrintOnce) {
    return;
  }
...
  PrintOnce = true;
}
```
This design ensures the help message will only be printed once.

> Going back to my original comment in this thread: there's no need for the if (Disassemble) clause to be inside the else case. It should be the main route taken when disassembling and the rest of this function should only occur if we are not disassembling.

If we must defer to the existing printing point, we should skip mcpuHelp() here. However, to implement the following case:
> 3. --mcpu=help + --disassemble + no objects specified + other dump options, --triple
a. As 2. but target derived from --triple option value.

we would need to insert code into `disassembleObject()`, which would significantly increase its complexity.
Is this necessary for this specific case?

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


More information about the llvm-commits mailing list