From 3f19fccc0e22be67940d9a023de99b6faa6197d7 Mon Sep 17 00:00:00 2001 From: VadimCurca Date: Mon, 17 Nov 2025 10:57:44 +0100 Subject: [PATCH] [MLIR] Fix empty optional access in DialectConversion When both `MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS` and MLIR multithreading are enabled, `topLevelFingerPrint` is empty but its value is accessed. This adds a `has_value()` check before dereferencing the optional. --- mlir/lib/Transforms/Utils/DialectConversion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index 365bfddeaab73..27e3ec6f64c8f 100644 --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -2766,7 +2766,7 @@ LogicalResult OperationLegalizer::legalizeWithPattern(Operation *op) { rewriterImpl.patternMaterializations.clear(); #if MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS // Expensive pattern check that can detect API violations. - if (checkOp) { + if (checkOp && topLevelFingerPrint) { OperationFingerPrint fingerPrintAfterPattern(checkOp); if (fingerPrintAfterPattern != *topLevelFingerPrint) llvm::report_fatal_error("pattern '" + pattern.getDebugName() +