[Mlir-commits] [mlir] [MLIR] Robustify Tosa_IfOp against null dereference and wrong assertion (PR #159756)
Jasmine Tang
llvmlistbot at llvm.org
Fri Sep 19 06:44:04 PDT 2025
================
@@ -438,6 +438,31 @@ func.func @test_pad_invalid_padding_value(%arg0: tensor<10xi8>, %arg1: tensor<1x
return %1 : tensor<10xi8>
}
+// -----
+func.func @test_cond_if_wrong_terminator_op(%arg0: tensor<i1>) -> tensor<i32> {
+ %0 = "tosa.cond_if"(%arg0) ({
+ %1 = "tosa.const"() <{values = dense<1> : tensor<i32>}> : () -> tensor<i32>
+ "tosa.yield"(%1) : (tensor<i32>) -> ()
+ }, {
+ // expected-error at +2 {{'func.return' op expects parent op 'func.func'}}
+ %2 = "tosa.const"() <{values = dense<2> : tensor<i32>}> : () -> tensor<i32>
+ "func.return"(%2) : (tensor<i32>) -> ()
+ }) : (tensor<i1>) -> tensor<i32>
+ return %0 : tensor<i32>
+}
+
+// -----
+func.func @test_cond_if_missing_terminator(%arg0: tensor<i1>) -> tensor<i32> {
+ %0 = "tosa.cond_if"(%arg0) ({
+ %1 = "tosa.const"() <{values = dense<1> : tensor<i32>}> : () -> tensor<i32>
+ "tosa.yield"(%1) : (tensor<i32>) -> ()
+ }, {
+ // expected-error at +1 {{block with no terminator}}
+ %2 = "tosa.const"() <{values = dense<2> : tensor<i32>}> : () -> tensor<i32>
+ }) : (tensor<i1>) -> tensor<i32>
+ return %0 : tensor<i32>
+}
+
----------------
badumbatish wrote:
hmm i dont think so, if it's the case i think it'd ICE out on the test and the XFAIL grep would show some relevant file names, I can add it if you'd like?
https://github.com/llvm/llvm-project/pull/159756
More information about the Mlir-commits
mailing list