[Mlir-commits] [mlir] [mlir][linalg] fix segmentation fault in isContractionBody function (PR #108703)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Sep 14 08:08:36 PDT 2024
https://github.com/BRUCE11111 created https://github.com/llvm/llvm-project/pull/108703
Fix Segmentation Fault in function.
`getDefiningOp()` may return `nullptr` pointer.
>From 18e8c0fdb0f615bb5cf2227f34cbda141ac96dd0 Mon Sep 17 00:00:00 2001
From: "Xu, Xiaohui1" <xiaohui1.xu at intel.com>
Date: Sat, 14 Sep 2024 23:01:11 +0800
Subject: [PATCH] [mlir][linalg] fix segmentation fault in isContractionBody
function
---
mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
index 0c48a5aeb26a26..0b5191664a9e2f 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
@@ -222,7 +222,7 @@ bool mlir::linalg::detail::isContractionBody(
Value contributed = getSourceSkipUnary(
isa<BlockArgument>(reductionLHS) ? reductionRHS : reductionLHS);
Operation *elementwiseOp = contributed.getDefiningOp();
- if (elementwiseOp->getNumResults() != 1 ||
+ if (!elementwiseOp || elementwiseOp->getNumResults() != 1 ||
elementwiseOp->getNumOperands() != 2) {
errs << "expected elementwise op to be binary";
return false;
More information about the Mlir-commits
mailing list