[Mlir-commits] [mlir] 13b2197 - [MLIR] Add an assert in Operation::getOpResultImpl for out of range result
Shivam Gupta
llvmlistbot at llvm.org
Sun Apr 9 13:20:35 PDT 2023
Author: Shivam Gupta
Date: 2023-04-10T01:49:42+05:30
New Revision: 13b21971fbf5cd47dc3acb0c593aae8ae980c8d8
URL: https://github.com/llvm/llvm-project/commit/13b21971fbf5cd47dc3acb0c593aae8ae980c8d8
DIFF: https://github.com/llvm/llvm-project/commit/13b21971fbf5cd47dc3acb0c593aae8ae980c8d8.diff
LOG: [MLIR] Add an assert in Operation::getOpResultImpl for out of range result
This fix https://github.com/llvm/llvm-project/issues/61962.
Calling op->getResult(0) on a function like operation with no results
returned a garbage pointer.
This patch add assert to check number is in range.
Differential Revision: https://reviews.llvm.org/D147883
Added:
Modified:
mlir/include/mlir/IR/Operation.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 250ae959204a3..632e0677483e5 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -804,6 +804,8 @@ class alignas(8) Operation final
/// Returns a pointer to the use list for the given result, which may be
/// either inline or out-of-line.
detail::OpResultImpl *getOpResultImpl(unsigned resultNumber) {
+ assert(resultNumber < getNumResults() &&
+ "Result number is out of range for operation");
unsigned maxInlineResults = detail::OpResultImpl::getMaxInlineResults();
if (resultNumber < maxInlineResults)
return getInlineOpResult(resultNumber);
More information about the Mlir-commits
mailing list