-
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] Centralize automatic deallocation code in lowering (#67003)
There are currently several places that automatically deallocate allocatble if they are allocated: - INTENT(OUT) allocatable are deallocated on entry in the callee - INTENT(OUT) allocatable are also deallocated on the caller side of BIND(C) function in case the implementation is in C. - Results of function returning allocatable are deallocated after usage. - OPENMP privatized allocatable are deallocated at the end of OPENMP region. Introduce genDeallocateIfAllocated that centralize all this code, except for the function return that use genFreememIfAllocated since finalization is done separately currently. `fir::factory::genFinalization` and `fir::factory::genInlinedDeallocation` are removed and replaced by genFreemem since their name were misleading: finalization was not called. There is a fallout in the tests because previous generated code did not check the allocated status when doing inline deallocation. This was OK since free(null) is guaranteed to be a no-op, but this makes compiler code more complex, is a bit surprising in the generated IR IMHO, and it relied on knowing when genDeallocateBox inserts runtime calls or uses inlined code.
- Loading branch information
1 parent
f5f7e2a
commit 2cb31fe
Showing
11 changed files
with
170 additions
and
144 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
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
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
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
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
Oops, something went wrong.