33 lines · plain
1// Test side effects of hlfir.assign op.2// RUN: fir-opt %s --test-side-effects --verify-diagnostics3 4func.func @test1(%x: !fir.ref<i32>, %i: i32) {5 // expected-remark @below {{found an instance of 'write' on op operand 1, on resource '<Default>'}}6 hlfir.assign %i to %x : i32, !fir.ref<i32>7 return8}9 10func.func @test2(%x: !fir.ref<i32>, %y: !fir.ref<i32>) {11 // expected-remark @below {{found an instance of 'write' on op operand 1, on resource '<Default>'}}12 // expected-remark @below {{found an instance of 'read' on op operand 0, on resource '<Default>'}}13 hlfir.assign %y to %x : !fir.ref<i32>, !fir.ref<i32>14 return15}16 17func.func @test3(%x: !fir.ref<!fir.type<t>>, %y: !fir.ref<!fir.type<t>>) {18 // expected-remark @below {{found an instance of 'write' on resource '<Default>'}}19 // expected-remark @below {{found an instance of 'read' on resource '<Default>'}}20 hlfir.assign %y to %x : !fir.ref<!fir.type<t>>, !fir.ref<!fir.type<t>>21 return22}23 24func.func @test4(%x: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, %y: !fir.box<!fir.array<?xi32>>) {25 // expected-remark @below {{found an instance of 'read' on op operand 0, on resource '<Default>'}}26 // expected-remark @below {{found an instance of 'read' on op operand 1, on resource '<Default>'}}27 // expected-remark @below {{found an instance of 'write' on resource '<Default>'}}28 // expected-remark @below {{found an instance of 'free' on resource '<Default>'}}29 // expected-remark @below {{found an instance of 'allocate' on resource '<Default>'}}30 hlfir.assign %y to %x realloc : !fir.box<!fir.array<?xi32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>31 return32}33