[all-commits] [llvm/llvm-project] a3bbe6: [flang][runtime] Validate pointer DEALLOCATE (#78612)
Peter Klausler via All-commits
all-commits at lists.llvm.org
Thu Jan 25 14:44:20 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a3bbe627d2d8d3a64c60dbec57c885d5303f4398
https://github.com/llvm/llvm-project/commit/a3bbe627d2d8d3a64c60dbec57c885d5303f4398
Author: Peter Klausler <35819229+klausler at users.noreply.github.com>
Date: 2024-01-25 (Thu, 25 Jan 2024)
Changed paths:
M flang/include/flang/Runtime/descriptor.h
M flang/include/flang/Runtime/magic-numbers.h
M flang/lib/Lower/Allocatable.cpp
M flang/runtime/descriptor.cpp
M flang/runtime/pointer.cpp
M flang/runtime/stat.cpp
M flang/runtime/stat.h
M flang/test/Lower/Intrinsics/c_loc.f90
Log Message:
-----------
[flang][runtime] Validate pointer DEALLOCATE (#78612)
The standard requires a compiler to diagnose an incorrect use of a
pointer in a DEALLOCATE statement. The pointer must be associated with
an entire object that was allocated as a pointer (not allocatable) by an
ALLOCATE statement.
Implement by appending a validation footer to pointer allocations. This
is an extra allocated word that encodes the base address of the
allocation. If it is not found after the data payload when the pointer
is deallocated, signal an error. There is a chance of a false positive
result, but that should be vanishingly unlikely.
This change requires all pointer allocations (not allocatables) to take
place in the runtime in PointerAllocate(), which might be slower in
cases that could otherwise be handled with a native memory allocation
operation. I believe that memory allocation of pointers is less common
than with allocatables, which are not affected. If this turns out to
become a performance problem, we can inline the creation and
initialization of the footer word.
Fixes https://github.com/llvm/llvm-project/issues/78391.
More information about the All-commits
mailing list