[llvm] a57c583 - llvm-ml: Error on MCSubtargetInfo construction failure (#159221)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 20:10:18 PDT 2025


Author: Matt Arsenault
Date: 2025-09-17T12:10:14+09:00
New Revision: a57c583861d209f440ffa937a29979e116b4716e

URL: https://github.com/llvm/llvm-project/commit/a57c583861d209f440ffa937a29979e116b4716e
DIFF: https://github.com/llvm/llvm-project/commit/a57c583861d209f440ffa937a29979e116b4716e.diff

LOG: llvm-ml: Error on MCSubtargetInfo construction failure (#159221)

Replace assert with an error.

Added: 
    

Modified: 
    llvm/tools/llvm-ml/llvm-ml.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp
index ae58b0da6d69b..cda86e77f3eb4 100644
--- a/llvm/tools/llvm-ml/llvm-ml.cpp
+++ b/llvm/tools/llvm-ml/llvm-ml.cpp
@@ -325,7 +325,10 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) {
 
   std::unique_ptr<MCSubtargetInfo> STI(
       TheTarget->createMCSubtargetInfo(TheTriple, /*CPU=*/"", /*Features=*/""));
-  assert(STI && "Unable to create subtarget info!");
+  if (!STI) {
+    WithColor::error(errs(), ProgName) << "unable to create subtarget info\n";
+    exit(1);
+  }
 
   // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.


        


More information about the llvm-commits mailing list