-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][hlfir] use fir.type_info to skip runtime call if nofinal is s…
…et (#68397) HLFIR was always calling Destroy runtime when doing derived type scalar assignments because the IR did not contain the info of whether finalization was needed or not. This info is now available in fir.type_info which allow skipping the runtime call when not needed. Also, when finalization is needed, simply use Assign runtime. This makes no difference from a semantic point of view with the current code that generated a call to Destroy and did the assignment inline, but if some piece of runtime must be called anyway, it is simpler to just call Assign that deals with everything.
- Loading branch information
1 parent
f47914a
commit 87b2682
Showing
4 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Test hlfir.assign code generation to FIR of derived type requiring | ||
// or not finalization. | ||
|
||
// RUN: fir-opt %s -convert-hlfir-to-fir | FileCheck %s | ||
|
||
!t_simple = !fir.type<simple{i:i32}> | ||
fir.type_info @simple noinit nodestroy nofinal : !t_simple | ||
|
||
func.func @test_simple(%a: !fir.ref<!t_simple>, %b: !fir.ref<!t_simple>) { | ||
hlfir.assign %b to %a : !fir.ref<!t_simple>, !fir.ref<!t_simple> | ||
return | ||
} | ||
// CHECK-LABEL: func.func @test_simple( | ||
// CHECK-NOT: Destroy | ||
// CHECK: %[[VAL_1:.*]] = fir.coordinate_of %{{.*}}, %{{.*}} : (!fir.ref<!fir.type<simple{i:i32}>>, !fir.field) -> !fir.ref<i32> | ||
// CHECK: %[[VAL_3:.*]] = fir.coordinate_of %{{.*}}, %{{.*}} : (!fir.ref<!fir.type<simple{i:i32}>>, !fir.field) -> !fir.ref<i32> | ||
// CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32> | ||
// CHECK: fir.store %[[VAL_4]] to %[[VAL_3]] : !fir.ref<i32> | ||
|
||
|
||
!t_with_final = !fir.type<with_final{i:i32}> | ||
fir.type_info @with_final noinit : !t_with_final | ||
|
||
func.func @test_with_final(%a: !fir.ref<!t_with_final>, %b: !fir.ref<!t_with_final>) { | ||
hlfir.assign %b to %a : !fir.ref<!t_with_final>, !fir.ref<!t_with_final> | ||
return | ||
} | ||
// CHECK-LABEL: func.func @test_with_final( | ||
// CHECK: fir.call @_FortranAAssign |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters