lfortran icon indicating copy to clipboard operation
lfortran copied to clipboard

Finalization TODO

Open assem2002 opened this issue 1 month ago • 1 comments

After merging this #8871, We'll be able to say that we have a good finalization process that's working properly (for fortran types). Here's a full todo to perfect it.

  • [ ] Use Functions to finalize types -- (e.g. finalize_alloatable_scalar, finalize_derivedType_tt , finalize_descriptorArray). This will make us have smaller binaries + will resolves the issue of recursive derived types declaration ( reference integration_tests/derived_types_78.f90).
  • [ ] Handle the case of block symbol having a return statement. We need to finalize any sub-constructs in a super-construct if we use return in them (reference integration_tests/finalization_01.f90).
  • [x] Remove unnecessary labels #8844.
  • [ ] Add a utility to print out the amount of allocated VS Freed heap memory and what is the purpose of allocating that memory -- To find leaks and investigate memory usages.
  • [ ] Add Finalization functions in the VTable of the types -- To handle the case of unlimited polymorphic type in Fortran class(*) -- remember that it could be an array.

assem2002 avatar Nov 19 '25 18:11 assem2002

I think we also need to use the same utilities of finalization with deallocate statement, as it for sure leaks now.

As we'll end up having LLVM-finalization function per type, things should get easier.

assem2002 avatar Nov 19 '25 18:11 assem2002