[mlir][tosa] Fix segmentation fault in case of folding unranked tensor
authorKai Sasaki <lewuathe@gmail.com>
Mon, 13 Feb 2023 20:54:42 +0000 (12:54 -0800)
committerRob Suderman <suderman@google.com>
Mon, 13 Feb 2023 21:12:25 +0000 (13:12 -0800)
commit9d0b596aada6fb2166dd4f6f58e359fbac483154
treea3b2fc77df20eb75c701174df505abc6a537fb65
parentf36fe009c0fc1d655bfc6168730bedfa1b36e622
[mlir][tosa] Fix segmentation fault in case of folding unranked tensor

Trying to fold the unranked tensor for "tosa.equal" crashes due to null reference.
We need to check the dynamic cast result beforehand. This is reported in
https://github.com/llvm/llvm-project/issues/60192.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D143034
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
mlir/test/Dialect/Tosa/constant_folding.mlir