The new operation is just an abstract attribute that is attached to [hl]fir.declare operations of dummy arguments of a subroutine. Dummy arguments of the same subroutine refer to the same fir.dummy_scope, so they can be recognized as such during FIR AliasAnalysis. Note that the fir.dummy_scope must be specific to the runtime instantiation of a subroutine, so any MLIR inlining/cloning should duplicate and unique it vs using the same fir.dummy_scope for different runtime instantiations. This is why I made it an operation rather than an attribute. The new operation uses a write effect on DebuggingResource, same as [hl]fir.declare, to avoid optimizing it away.
35 lines
2.2 KiB
Plaintext
35 lines
2.2 KiB
Plaintext
// RUN: fir-opt %s | fir-opt | FileCheck %s
|
|
// RUN: fir-opt %s | fir-opt -cse | FileCheck %s
|
|
|
|
// CHECK-LABEL: func.func @dummy_scope(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32>) {
|
|
// CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
|
|
// CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "x"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
// CHECK: return
|
|
// CHECK: }
|
|
func.func @dummy_scope(%arg0: !fir.ref<f32>) {
|
|
%scope = fir.dummy_scope : !fir.dscope
|
|
%0:2 = hlfir.declare %arg0 dummy_scope %scope {uniq_name = "x"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @dummy_scopes(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32>) {
|
|
// CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
|
|
// CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "x"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
// CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
|
|
// CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_3]] {uniq_name = "innerEx"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
// CHECK: %[[VAL_5:.*]] = fir.dummy_scope : !fir.dscope
|
|
// CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_5]] {uniq_name = "innerEx"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
// CHECK: return
|
|
// CHECK: }
|
|
func.func @dummy_scopes(%arg0: !fir.ref<f32>) {
|
|
%scope_out = fir.dummy_scope : !fir.dscope
|
|
%0:2 = hlfir.declare %arg0 dummy_scope %scope_out {uniq_name = "x"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
%scope_in1 = fir.dummy_scope : !fir.dscope
|
|
%1:2 = hlfir.declare %arg0 dummy_scope %scope_in1 {uniq_name = "innerEx"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
%scope_in2 = fir.dummy_scope : !fir.dscope
|
|
%2:2 = hlfir.declare %arg0 dummy_scope %scope_in2 {uniq_name = "innerEx"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
|
|
return
|
|
}
|