@@ -23,7 +23,7 @@ func.func private @bar(%arg0: !fir.ref<!fir.array<12x23xi32>>)
2323
2424// DECL-LABEL: func.func @test(
2525// DECL-SAME: %[[arg0:.*]]: !fir.ref<!fir.array<12x23xi32>>) {
26- // DECL: fircg.ext_declare
26+ // DECL: fircg.ext_declare{{.*}}{uniq_name = "_QFarray_numeric_lboundsEx"}
2727
2828
2929func.func @useless_shape_with_duplicate_extent_operand(%arg0: !fir.ref<!fir.array<3x3xf32>>) {
@@ -37,7 +37,7 @@ func.func @useless_shape_with_duplicate_extent_operand(%arg0: !fir.ref<!fir.arra
3737// NODECL-NEXT: return
3838
3939// DECL-LABEL: func.func @useless_shape_with_duplicate_extent_operand(
40- // DECL: fircg.ext_declare
40+ // DECL: fircg.ext_declare{{.*}}{uniq_name = "u"}
4141
4242// Test DCE does not crash because of unreachable code.
4343func.func @unreachable_code(%arg0: !fir.ref<!fir.char<1,10>>) {
@@ -51,4 +51,20 @@ func.func @unreachable_code(%arg0: !fir.ref<!fir.char<1,10>>) {
5151// NODECL-LABEL: func.func @unreachable_code(
5252// NODECL-NOT: uniq_name = "live_code"
5353// DECL-LABEL: func.func @unreachable_code(
54- // DECL: uniq_name = "live_code"
54+ // DECL: fircg.ext_declare{{.*}}{uniq_name = "live_code"}
55+ // DECL: fir.declare{{.*}}{uniq_name = "dead_code"}
56+
57+
58+ // Test that attributes get attached to the memref operation when fir.declare is not preserved
59+ func.func @test_local_memref() {
60+ %0 = fir.alloca !fir.array<10xi32> {uniq_name = "local_array"}
61+ %1 = fir.declare %0 {uniq_name = "local_array_declare", acc.declare = #acc.declare<dataClause = acc_create>} : (!fir.ref<!fir.array<10xi32>>) -> !fir.ref<!fir.array<10xi32>>
62+ return
63+ }
64+ // NODECL-LABEL: func.func @test_local_memref() {
65+
66+ // Note: the uniq_name is not attached of fir.declare is not preserved because it conflicts with the uniq_name of the memref
67+ // NODECL: fir.alloca{{.*}}{acc.declare = #acc.declare<dataClause = acc_create>, uniq_name = "local_array"}
68+
69+ // DECL-LABEL: func.func @test_local_memref() {
70+ // DECL: fircg.ext_declare{{.*}}{acc.declare = #acc.declare<dataClause = acc_create>, uniq_name = "local_array_declare"}
0 commit comments