[Mlir-commits] [mlir] 6f2943f - [MLIR][Standard] Fix use of `dyn_cast_or_null`

Frederik Gossen llvmlistbot at llvm.org
Tue Jun 16 14:06:42 PDT 2020


Author: Frederik Gossen
Date: 2020-06-16T21:06:15Z
New Revision: 6f2943fb1960a698b8fb876fdcc10f4508fd45f6

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

LOG: [MLIR][Standard] Fix use of `dyn_cast_or_null`

The value may be a function argument in which case `getDefiningOp` will return a
`nullptr`.

Differential Revision: https://reviews.llvm.org/D81965

Added: 
    

Modified: 
    mlir/lib/Dialect/StandardOps/IR/Ops.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index dd67f2de86f0..ca4fe836495b 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -1703,8 +1703,8 @@ struct ExtractElementFromTensorFromElements
     if (extract.indices().size() != 1)
       return failure();
 
-    auto tensor_from_elements =
-        dyn_cast<TensorFromElementsOp>(extract.aggregate().getDefiningOp());
+    auto tensor_from_elements = dyn_cast_or_null<TensorFromElementsOp>(
+        extract.aggregate().getDefiningOp());
     if (tensor_from_elements == nullptr)
       return failure();
 


        


More information about the Mlir-commits mailing list