Skip to content

Commit

Permalink
Add tests for out of bounds access
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-camp committed Apr 20, 2021
1 parent 54643bb commit 568a725
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions iree/vm/test/list_ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,6 @@ vm.module @list_ops {
vm.return
}

//===--------------------------------------------------------------------===//
// vm.list.* with variant types
//===--------------------------------------------------------------------===//

vm.export @test_variant
vm.func @test_variant() {
// TODO(benvanik): test vm.list with variant types.
vm.return
}

//===--------------------------------------------------------------------===//
// Failure tests
//===--------------------------------------------------------------------===//
Expand All @@ -102,4 +92,23 @@ vm.module @list_ops {
vm.list.set.i32 %list, %c0, %c1 : (!vm.list<i32>, i32, i32)
vm.return
}

vm.export @fail_out_of_bounds_read
vm.func @fail_out_of_bounds_read() {
%c1 = vm.const.i32 1 : i32
%list = vm.list.alloc %c1 : (i32) -> !vm.list<i32>
vm.list.resize %list, %c1 : (!vm.list<i32>, i32)
%v = vm.list.get.i32 %list, %c1 : (!vm.list<i32>, i32) -> i32
%v_dno = iree.do_not_optimize(%v) : i32
vm.return
}

vm.export @fail_out_of_bounds_write
vm.func @fail_out_of_bounds_write() {
%c1 = vm.const.i32 1 : i32
%list = vm.list.alloc %c1 : (i32) -> !vm.list<i32>
vm.list.resize %list, %c1 : (!vm.list<i32>, i32)
vm.list.set.i32 %list, %c1, %c1 : (!vm.list<i32>, i32, i32)
vm.return
}
}

0 comments on commit 568a725

Please sign in to comment.