// RUN: fir-opt %s --test-side-effects --verify-diagnostics func.func @concat(%arg0: !fir.ref>, %arg1: !fir.ref>) { // expected-remark@+1 {{operation has no memory effects}} %c30 = arith.constant 30 : index // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref>, !fir.ref>, index) -> (!hlfir.expr>) // expected-remark@+1 {{operation has no memory effects}} return } func.func @all_no_effects(%arg0: !hlfir.expr<2x!fir.logical<4>>) { // expected-remark@+1 {{operation has no memory effects}} %all = hlfir.all %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> !fir.logical<4> // expected-remark@+1 {{operation has no memory effects}} return } func.func @all_effects(%arg0: !fir.ref>>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %all = hlfir.all %arg0 dim %arg1 : (!fir.ref>>, i32) -> !hlfir.expr> // expected-remark@+1 {{operation has no memory effects}} return } func.func @any_no_effects(%arg0: !hlfir.expr<2x!fir.logical<4>>) { // expected-remark@+1 {{operation has no memory effects}} %all = hlfir.any %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> !fir.logical<4> // expected-remark@+1 {{operation has no memory effects}} return } func.func @any_effects(%arg0: !fir.ref>>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %all = hlfir.any %arg0 dim %arg1 : (!fir.ref>>, i32) -> !hlfir.expr> // expected-remark@+1 {{operation has no memory effects}} return } func.func @count_no_effects(%arg0: !hlfir.expr<2x!fir.logical<4>>) { // expected-remark@+1 {{operation has no memory effects}} %all = hlfir.count %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> i32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @count_effects(%arg0: !fir.ref>>, %arg1: i32) { // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %all = hlfir.count %arg0 dim %arg1 : (!fir.ref>>, i32) -> i32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @product_no_effects(%arg0: !hlfir.expr) { // expected-remark@+1 {{operation has no memory effects}} %product = hlfir.product %arg0 : (!hlfir.expr) -> f32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @product_effects(%arg0: !fir.ref>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %product = hlfir.product %arg0 dim %arg1 : (!fir.ref>, i32) -> !hlfir.expr<2xf32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @set_length_read(%arg0: !fir.ref>, %arg1: index) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.set_length %arg0 len %arg1 : (!fir.ref>, index) -> !hlfir.expr> // expected-remark@+1 {{operation has no memory effects}} return } func.func @sum_no_effects(%arg0: !hlfir.expr) { // expected-remark@+1 {{operation has no memory effects}} %sum = hlfir.sum %arg0 : (!hlfir.expr) -> f32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @sum_effects(%arg0: !fir.ref>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %sum = hlfir.sum %arg0 dim %arg1 : (!fir.ref>, i32) -> !hlfir.expr<2xf32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @maxval_no_effects(%arg0: !hlfir.expr) { // expected-remark@+1 {{operation has no memory effects}} %maxval = hlfir.maxval %arg0 : (!hlfir.expr) -> f32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @maxval_effects(%arg0: !fir.ref>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %maxval = hlfir.maxval %arg0 dim %arg1 : (!fir.ref>, i32) -> !hlfir.expr<2xf32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @minval_no_effects(%arg0: !hlfir.expr) { // expected-remark@+1 {{operation has no memory effects}} %minval = hlfir.minval %arg0 : (!hlfir.expr) -> f32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @minval_effects(%arg0: !fir.ref>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %minval = hlfir.minval %arg0 dim %arg1 : (!fir.ref>, i32) -> !hlfir.expr<2xf32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @minloc_effects_simple(%arg0: !hlfir.expr) { // expected-remark@+1 {{found an instance of 'allocate' on a value, on resource ''}} %minloc = hlfir.minloc %arg0 : (!hlfir.expr) -> !hlfir.expr // expected-remark@+1 {{operation has no memory effects}} return } func.func @minloc_effects(%arg0: !fir.ref>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %minloc = hlfir.minloc %arg0 dim %arg1 : (!fir.ref>, i32) -> !hlfir.expr<2xi32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @maxloc_effects_simple(%arg0: !hlfir.expr) { // expected-remark@+1 {{found an instance of 'allocate' on a value, on resource ''}} %maxloc = hlfir.maxloc %arg0 : (!hlfir.expr) -> !hlfir.expr // expected-remark@+1 {{operation has no memory effects}} return } func.func @maxloc_effects(%arg0: !fir.ref>, %arg1: i32) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %maxloc = hlfir.maxloc %arg0 dim %arg1 : (!fir.ref>, i32) -> !hlfir.expr<2xi32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @dot_product_no_effects(%arg0: !hlfir.expr, %arg1: !hlfir.expr) { // expected-remark@+1 {{operation has no memory effects}} %0 = hlfir.dot_product %arg0 %arg1 : (!hlfir.expr, !hlfir.expr) -> f32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @dot_product_effects(%arg0: !fir.ref>, %arg1: !fir.ref>) { // there are read effects on both arguments - the diagnostic verification just doesn't register duplicate identical diagnostics // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.dot_product %arg0 %arg1 : (!fir.ref>, !fir.ref>) -> f32 // expected-remark@+1 {{operation has no memory effects}} return } func.func @matmul_no_reads(%arg0: !hlfir.expr, %arg1: !hlfir.expr) { // expected-remark@+1 {{found an instance of 'allocate' on a value, on resource ''}} %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr, !hlfir.expr) -> !hlfir.expr // expected-remark@+1 {{operation has no memory effects}} return } func.func @matmul_reads(%arg0: !fir.ref>, %arg1: !fir.ref>) { // expected-remark@+3 {{found an instance of 'allocate' on a value, on resource ''}} // there are read effects on both arguments - the diagnostic verification just doesn't register duplicate identical diagnostics // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.matmul %arg0 %arg1 : (!fir.ref>, !fir.ref>) -> !hlfir.expr<10x10xf32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @transpose_no_reads(%arg0: !hlfir.expr) { // expected-remark@+1 {{found an instance of 'allocate' on a value, on resource ''}} %0 = hlfir.transpose %arg0 : (!hlfir.expr) -> !hlfir.expr // expected-remark@+1 {{operation has no memory effects}} return } func.func @transpose_read(%arg0: !fir.ref>) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.transpose %arg0 : (!fir.ref>) -> !hlfir.expr<5x10xf32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @matmul_transpose_no_reads(%arg0: !hlfir.expr, %arg1: !hlfir.expr) { // expected-remark@+1 {{found an instance of 'allocate' on a value, on resource ''}} %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr, !hlfir.expr) -> !hlfir.expr // expected-remark@+1 {{operation has no memory effects}} return } func.func @matmul_transpose_reads(%arg0: !fir.ref>, %arg1: !fir.ref>) { // expected-remark@+3 {{found an instance of 'allocate' on a value, on resource ''}} // there are read effects on both arguments - the diagnostic verification just doesn't register duplicate identical diagnostics // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.matmul_transpose %arg0 %arg1 : (!fir.ref>, !fir.ref>) -> !hlfir.expr<10x10xf32> // expected-remark@+1 {{operation has no memory effects}} return } func.func @associate(%arg0: i32) { // expected-remark@+1 {{found an instance of 'allocate' on resource ''}} %0:3 = hlfir.associate %arg0 {uniq_name = "x"} : (i32) -> (!fir.ref, !fir.ref, i1) // expected-remark@+1 {{found an instance of 'free' on resource ''}} hlfir.end_associate %0#1, %0#2 : !fir.ref, i1 // expected-remark@+1 {{operation has no memory effects}} return } func.func @as_expr_read(%arg0: !fir.ref>) { // expected-remark@+2 {{found an instance of 'allocate' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.as_expr %arg0 : (!fir.ref>) -> !hlfir.expr // expected-remark@+1 {{found an instance of 'free' on resource ''}} hlfir.destroy %0 : !hlfir.expr // expected-remark@+1 {{operation has no memory effects}} return } func.func @char_extremum(%arg0: !fir.ref>, %arg1: !fir.ref>) { // expected-remark@+3 {{found an instance of 'allocate' on a value, on resource ''}} // there are read effects on both arguments - the diagnostic verification just doesn't register duplicate identical diagnostics // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0 = hlfir.char_extremum min, %arg0, %arg1 : (!fir.ref>, !fir.ref>) -> !hlfir.expr> // expected-remark@+1 {{operation has no memory effects}} return } func.func @copy_in(%box: !fir.box>, %is_present: i1) { // expected-remark@+2 {{found an instance of 'allocate' on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} %0:2 = hlfir.copy_in %box : (!fir.box>) -> (!fir.box>, i1) // expected-remark@+1 {{operation has no memory effects}} return } func.func @copy_out(%box: !fir.box>, %temp: !fir.box>, %was_copied: i1) { // expected-remark@+2 {{found an instance of 'free' on resource ''}} // expected-remark@+1 {{found an instance of 'read' on a value, on resource ''}} hlfir.copy_out %temp, %was_copied : (!fir.box>, i1) -> () // expected-remark@+3 {{found an instance of 'free' on resource ''}} // expected-remark@+2 {{found an instance of 'read' on a value, on resource ''}} // expected-remark@+1 {{found an instance of 'write' on a value, on resource ''}} hlfir.copy_out %temp, %was_copied to %box : (!fir.box>, i1, !fir.box>) -> () // expected-remark@+1 {{operation has no memory effects}} return }