[Mlir-commits] [mlir] 6a62179 - Reland "[MLIR] Add an assert in Operation::getOpResultImpl for out of range result"

Shivam Gupta llvmlistbot at llvm.org
Tue Apr 11 00:37:42 PDT 2023


Author: Shivam Gupta
Date: 2023-04-11T13:04:26+05:30
New Revision: 6a621795e03760e26acec7d3b612ba0c0a0f2e7e

URL: https://github.com/llvm/llvm-project/commit/6a621795e03760e26acec7d3b612ba0c0a0f2e7e
DIFF: https://github.com/llvm/llvm-project/commit/6a621795e03760e26acec7d3b612ba0c0a0f2e7e.diff

LOG: Reland "[MLIR] Add an assert in Operation::getOpResultImpl for out of range result"

This reverts commit e08af170736271f022b2cab44d58326356ce1db8.

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