Skip to content

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Sep 17, 2025

Replace assert with a handled error. The same should probably
be done for all of the MC constructors.

Replace assert with a handled error. The same should probably
be done for all of the MC constructors.
Copy link
Contributor Author

arsenm commented Sep 17, 2025

@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-tools-llvm-mca

Author: Matt Arsenault (arsenm)

Changes

Replace assert with a handled error. The same should probably
be done for all of the MC constructors.


Full diff: https://github.com/llvm/llvm-project/pull/159215.diff

1 Files Affected:

  • (modified) llvm/tools/llvm-mca/llvm-mca.cpp (+5-1)
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index c969340742c39..a04b6ee9d90cf 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -413,7 +413,11 @@ int main(int argc, char **argv) {
 
   std::unique_ptr<MCSubtargetInfo> STI(
       TheTarget->createMCSubtargetInfo(TheTriple, MCPU, FeaturesStr));
-  assert(STI && "Unable to create subtarget info!");
+  if (!STI) {
+    WithColor::error() << "unable to create subtarget info\n";
+    return 1;
+  }
+
   if (!STI->isCPUStringValid(MCPU))
     return 1;
 

@arsenm arsenm marked this pull request as ready for review September 17, 2025 00:38
Base automatically changed from users/arsenm/llvm-mca/fix-unnecessary-reconstruction-triple to main September 17, 2025 01:29
@arsenm arsenm merged commit 35d6ee6 into main Sep 17, 2025
13 checks passed
@arsenm arsenm deleted the users/arsenm/llvm-mca/error-mcsubtargetinfo-failure branch September 17, 2025 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants