[Mlir-commits] [mlir] [mlir][vector] Fix crash on untraceable masks in getCompressedMaskOp (PR #207299)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jul 8 04:25:00 PDT 2026


================
@@ -98,10 +98,16 @@ static FailureOr<Operation *> getCompressedMaskOp(OpBuilder &rewriter,
     if (auto extractOp = dyn_cast<vector::ExtractOp>(maskOp)) {
       maskOp = extractOp.getSource().getDefiningOp();
       extractOps.push_back(extractOp);
+    } else {
+      // Unsupported mask-defining op (e.g. a block argument, which has no
+      // defining op, or an op we cannot trace through). Bail out rather than
+      // looping forever or dereferencing a null op below.
+      break;
     }
   }
 
-  if (!isa<arith::ConstantOp, vector::CreateMaskOp, vector::ConstantMaskOp>(
+  if (!maskOp ||
+      !isa<arith::ConstantOp, vector::CreateMaskOp, vector::ConstantMaskOp>(
----------------
marquisburg wrote:

Still needed for the null case. A block-argument leaves `maskIOo` null and `isa<>` on null segfaults in a release build. I did go ahead and switch to `isa_and_present<...>` to stay null-safe without the explicit `!maskOp ||`

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


More information about the Mlir-commits mailing list