This is an archive of the discontinued LLVM Phabricator instance.

[flang] Do not perform INTERNAL_CHECK for deallocation of unlimited polymorphic with intrinsic type spec
ClosedPublic

Authored by clementval on Jan 18 2023, 5:37 AM.

Details

Summary

When an unlimited polymorphic descriptor is establish for an intrinsic
type spec, the PointerNullifyIntrinsic or AllocatableInitIntrinsic runtime
function is called. These functions do not initialize an addendum with a derivedType.
When the deallocation on this descriptor is performed, the runtime should not
crash if the addendum is not present. This patch updates PointerDeallocatePolymorphic
and AllocatableDeallocatePolymorphic for this use case.

Depends on D141996

Diff Detail

Event Timeline

clementval created this revision.Jan 18 2023, 5:37 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 18 2023, 5:37 AM
Herald added a subscriber: sunshaoce. · View Herald Transcript
clementval requested review of this revision.Jan 18 2023, 5:37 AM

Remove extra comment

jeanPerier accepted this revision.Jan 18 2023, 6:06 AM
jeanPerier added inline comments.
flang/runtime/allocatable.cpp
147

Just to clarify, was AllocatableInitIntrinsic called when allocating the derived type to an intrinsic type or is it called in other contexts by lowering?

This revision is now accepted and ready to land.Jan 18 2023, 6:06 AM
PeteSteinfeld accepted this revision.Jan 18 2023, 6:09 AM

All builds and tests correctly and looks good.

Again, it would be better if there were a test for this in .../llvm-project/flang/unittests/Runtime.

All builds and tests correctly and looks good.

Again, it would be better if there were a test for this in .../llvm-project/flang/unittests/Runtime.

Should be doable for this one. I'll add it.

flang/runtime/allocatable.cpp
147

It is called when you allocate a unlimited polymorphic descriptor with an intrinsic type like:

class(*), allocatable :: p
allocate(integer::p)

Add unit test

Thanks, @clementval, you're the best.