[llvm] Revert "[llc] Add -M for InstPrinter options" (PR #135070)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 12:08:56 PDT 2025


https://github.com/thurstond created https://github.com/llvm/llvm-project/pull/135070

Reverts llvm/llvm-project#121078

Reason: buildbot breakage (https://lab.llvm.org/buildbot/#/builders/55/builds/9607)
```
******************** TEST 'LLVM :: tools/llc/instprinter-options.ll' FAILED ********************
Exit Code: 1
Command Output (stderr):
--
not /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llc -mtriple=x86_64 < /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/tools/llc/instprinter-options.ll -M invalid 2>&1 | /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/tools/llc/instprinter-options.ll --implicit-check-not=error: # RUN: at line 2
+ not /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llc -mtriple=x86_64 -M invalid
+ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/FileCheck /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/tools/llc/instprinter-options.ll --implicit-check-not=error:
command line:1:22: error: IMPLICIT-CHECK-NOT: excluded string found in input
-implicit-check-not='error:'
                     ^
<stdin>:3:1: note: found here
error: Aborted
^~~~~~
Input file: <stdin>
Check file: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/tools/llc/instprinter-options.ll
-dump-input=help explains the following input dump.
Input was:
<<<<<<
          1: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llc: error: invalid InstPrinter option 'invalid' 
          2: libc++abi: Pure virtual function called! 
          3: error: Aborted 
not:imp1     !~~~~~          error: no match expected
>>>>>>
```

>From 69a55b8cab98a8f07a9d84e9704fe79ed9d2fbea Mon Sep 17 00:00:00 2001
From: Thurston Dang <thurston.dang at gmail.com>
Date: Wed, 9 Apr 2025 12:07:54 -0700
Subject: [PATCH] Revert "[llc] Add -M for InstPrinter options"

This reverts commit 02b377d8f7252b1acf6ea4fad55a101b6bc3fcf7.
---
 llvm/docs/CommandGuide/llc.rst                |  5 -----
 llvm/include/llvm/MC/MCTargetOptions.h        |  3 ---
 llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp |  8 +-------
 .../test/CodeGen/RISCV/compress-opt-select.ll |  4 ++--
 .../CodeGen/RISCV/hwasan-check-memaccess.ll   |  2 +-
 llvm/test/tools/llc/instprinter-options.ll    |  4 ----
 .../tools/llvm-mc/disassembler-options.test   |  2 +-
 llvm/tools/llc/llc.cpp                        | 20 ++-----------------
 llvm/tools/llvm-mc/llvm-mc.cpp                | 11 +++++-----
 9 files changed, 12 insertions(+), 47 deletions(-)
 delete mode 100644 llvm/test/tools/llc/instprinter-options.ll

diff --git a/llvm/docs/CommandGuide/llc.rst b/llvm/docs/CommandGuide/llc.rst
index 900649f59c401..7f28ab3a82f7c 100644
--- a/llvm/docs/CommandGuide/llc.rst
+++ b/llvm/docs/CommandGuide/llc.rst
@@ -43,11 +43,6 @@ End-user Options
 
  Print a summary of command line options.
 
-.. option:: -M
-
- Pass target-specific InstPrinter options.
- Refer to the ``-M`` option of :manpage:`llvm-objdump(1)`.
-
 .. option:: -o <filename>
 
  Use ``<filename>`` as the output filename. See the summary above for more
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h b/llvm/include/llvm/MC/MCTargetOptions.h
index fd554bc0ba7c6..7b0d81faf73d2 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -105,9 +105,6 @@ class MCTargetOptions {
   /// integrated assembler.
   std::vector<std::string> IASSearchPaths;
 
-  // InstPrinter options.
-  std::vector<std::string> InstPrinterOptions;
-
   // Whether to emit compact-unwind for non-canonical personality
   // functions on Darwins.
   bool EmitCompactUnwindNonCanonical : 1;
diff --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
index 37611479088be..5757ca1b3adf8 100644
--- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
+++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
@@ -21,7 +21,6 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCInstPrinter.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCObjectWriter.h"
 #include "llvm/MC/MCRegisterInfo.h"
@@ -133,10 +132,8 @@ bool CodeGenTargetMachineImpl::addAsmPrinter(PassManagerBase &PM,
                                              MCContext &Context) {
   Expected<std::unique_ptr<MCStreamer>> MCStreamerOrErr =
       createMCStreamer(Out, DwoOut, FileType, Context);
-  if (!MCStreamerOrErr) {
-    Context.reportError(SMLoc(), toString(MCStreamerOrErr.takeError()));
+  if (auto Err = MCStreamerOrErr.takeError())
     return true;
-  }
 
   // Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
   FunctionPass *Printer =
@@ -166,9 +163,6 @@ CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out,
         getTargetTriple(),
         Options.MCOptions.OutputAsmVariant.value_or(MAI.getAssemblerDialect()),
         MAI, MII, MRI);
-    for (StringRef Opt : Options.MCOptions.InstPrinterOptions)
-      if (!InstPrinter->applyTargetSpecificCLOption(Opt))
-        return createStringError("invalid InstPrinter option '" + Opt + "'");
 
     // Create a code emitter if asked to show the encoding.
     std::unique_ptr<MCCodeEmitter> MCE;
diff --git a/llvm/test/CodeGen/RISCV/compress-opt-select.ll b/llvm/test/CodeGen/RISCV/compress-opt-select.ll
index c0234f40cff56..733c84ac23613 100644
--- a/llvm/test/CodeGen/RISCV/compress-opt-select.ll
+++ b/llvm/test/CodeGen/RISCV/compress-opt-select.ll
@@ -1,9 +1,9 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
 ; RUN: llc -mtriple=riscv32 -target-abi ilp32d -mattr=+c,+f,+d \
-; RUN:     -M no-aliases < %s \
+; RUN:     -riscv-no-aliases < %s \
 ; RUN:   | FileCheck -check-prefix=RV32IFDC %s
 ; RUN: llc -mtriple=riscv32 -target-abi ilp32d -mattr=-c,+f,+d \
-; RUN:     -M no-aliases < %s \
+; RUN:     -riscv-no-aliases < %s \
 ; RUN:   | FileCheck -check-prefix=RV32IFD %s
 
 ; constant is small and fit in 6 bit (compress imm)
diff --git a/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll b/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll
index cf780f4f7f76c..c4e5dcedf5ede 100644
--- a/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll
+++ b/llvm/test/CodeGen/RISCV/hwasan-check-memaccess.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple=riscv64 < %s | FileCheck %s
 ; RUN: llc -mtriple=riscv64 --relocation-model=pic < %s | FileCheck %s
-; RUN: llc -mtriple=riscv64 -mattr=+c -M no-aliases < %s \
+; RUN: llc -mtriple=riscv64 -mattr=+c --riscv-no-aliases < %s \
 ; RUN:   | FileCheck %s --check-prefix=COMPRESS
 
 define ptr @f2(ptr %x0, ptr %x1) {
diff --git a/llvm/test/tools/llc/instprinter-options.ll b/llvm/test/tools/llc/instprinter-options.ll
deleted file mode 100644
index dd47bb46decce..0000000000000
--- a/llvm/test/tools/llc/instprinter-options.ll
+++ /dev/null
@@ -1,4 +0,0 @@
-; REQUIRES: x86-registered-target
-; RUN: not llc -mtriple=x86_64 < %s -M invalid 2>&1 | FileCheck %s --implicit-check-not=error:
-
-; CHECK: error: invalid InstPrinter option 'invalid'
diff --git a/llvm/test/tools/llvm-mc/disassembler-options.test b/llvm/test/tools/llvm-mc/disassembler-options.test
index e53bfce9f47ab..a7fd8b1b9f8d3 100644
--- a/llvm/test/tools/llvm-mc/disassembler-options.test
+++ b/llvm/test/tools/llvm-mc/disassembler-options.test
@@ -1,4 +1,4 @@
 # RUN: export LSAN_OPTIONS=detect_leaks=0
 # RUN: not llvm-mc -M invalid /dev/null 2>&1 | FileCheck %s
 
-# CHECK: error: invalid InstPrinter option 'invalid'
+# CHECK: error: invalid disassembler option 'invalid'
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 140459ba2de21..a97d07dec722b 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -69,9 +69,6 @@ static codegen::RegisterCodeGenFlags CGF;
 static cl::opt<std::string>
 InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
 
-static cl::list<std::string>
-    InstPrinterOptions("M", cl::desc("InstPrinter options"));
-
 static cl::opt<std::string>
 InputLanguage("x", cl::desc("Input language ('ir' or 'mir')"));
 
@@ -501,7 +498,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
     Options.MCOptions.AsmVerbose = AsmVerbose;
     Options.MCOptions.PreserveAsmComments = PreserveComments;
     Options.MCOptions.IASSearchPaths = IncludeDirs;
-    Options.MCOptions.InstPrinterOptions = InstPrinterOptions;
     Options.MCOptions.SplitDwarfFile = SplitDwarfFile;
     if (DwarfDirectory.getPosition()) {
       Options.MCOptions.MCUseDwarfDirectory =
@@ -678,17 +674,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
     MachineModuleInfoWrapperPass *MMIWP =
         new MachineModuleInfoWrapperPass(Target.get());
 
-    // Set a temporary diagnostic handler. This is used before
-    // MachineModuleInfoWrapperPass::doInitialization for features like -M.
-    bool HasMCErrors = false;
-    MCContext &MCCtx = MMIWP->getMMI().getContext();
-    MCCtx.setDiagnosticHandler([&](const SMDiagnostic &SMD, bool IsInlineAsm,
-                                   const SourceMgr &SrcMgr,
-                                   std::vector<const MDNode *> &LocInfos) {
-      WithColor::error(errs(), argv0) << SMD.getMessage() << '\n';
-      HasMCErrors = true;
-    });
-
     // Construct a custom pass pipeline that starts after instruction
     // selection.
     if (!getRunPassNames().empty()) {
@@ -723,8 +708,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
     } else if (Target->addPassesToEmitFile(
                    PM, *OS, DwoOut ? &DwoOut->os() : nullptr,
                    codegen::getFileType(), NoVerify, MMIWP)) {
-      if (!HasMCErrors)
-        reportError("target does not support generation of this file type");
+      reportError("target does not support generation of this file type");
     }
 
     const_cast<TargetLoweringObjectFile *>(Target->getObjFileLowering())
@@ -752,7 +736,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
 
     PM.run(*M);
 
-    if (Context.getDiagHandlerPtr()->HasErrors || HasMCErrors)
+    if (Context.getDiagHandlerPtr()->HasErrors)
       return 1;
 
     // Compare the two outputs and make sure they're the same
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index db2c6eeb22519..70f92d09aded7 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -49,9 +49,9 @@ static cl::opt<std::string> InputFilename(cl::Positional,
                                           cl::desc("<input file>"),
                                           cl::init("-"), cl::cat(MCCategory));
 
-static cl::list<std::string> InstPrinterOptions("M",
-                                                cl::desc("InstPrinter options"),
-                                                cl::cat(MCCategory));
+static cl::list<std::string>
+    DisassemblerOptions("M", cl::desc("Disassembler options"),
+                        cl::cat(MCCategory));
 
 static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
                                            cl::value_desc("filename"),
@@ -369,7 +369,6 @@ int main(int argc, char **argv) {
   MCOptions.ShowMCInst = ShowInst;
   MCOptions.AsmVerbose = true;
   MCOptions.MCUseDwarfDirectory = MCTargetOptions::EnableDwarfDirectory;
-  MCOptions.InstPrinterOptions = InstPrinterOptions;
 
   setDwarfDebugFlags(argc, argv);
   setDwarfDebugProducer();
@@ -532,9 +531,9 @@ int main(int argc, char **argv) {
       return 1;
     }
 
-    for (StringRef Opt : InstPrinterOptions)
+    for (StringRef Opt : DisassemblerOptions)
       if (!IP->applyTargetSpecificCLOption(Opt)) {
-        WithColor::error() << "invalid InstPrinter option '" << Opt << "'\n";
+        WithColor::error() << "invalid disassembler option '" << Opt << "'\n";
         return 1;
       }
 



More information about the llvm-commits mailing list