]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Handle secondary stack memory allocations alignment
authorMarc Poulhiès <poulhies@adacore.com>
Thu, 2 Jun 2022 07:52:21 +0000 (09:52 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 6 Jul 2022 13:29:48 +0000 (13:29 +0000)
commit3202e9f88fd286a8fc4814abeaa2238d70f4d585
treebd5a0f263e62a5019093bc0d0911062ab4b66cc5
parentb65a875a7c1a728ddb5d58fb97777394a6f773e2
[Ada] Handle secondary stack memory allocations alignment

To accomodate cases where objects allocated on the secondary stack
needed a more constrained alignement than Standard'Maximum_Alignement,
the alignment for all allocations in the full runtime were forced on to
be aligned on Standard'Maximum_Alignement*2. This changes removes this
workaround and correctly handles the over-alignment in all runtimes.

This change modifies the SS_Allocate procedure to accept a new Alignment
parameter and to dynamically realign the pointer returned by the memory
allocation (Allocate_* functions or dedicated stack allocations for
zfp/cert).

It also simplifies the 0-sized allocations by not allocating any memory
if pointer is already correctly aligned (already the case in cert and
zfp runtimes).

gcc/ada/

* libgnat/s-secsta.ads (SS_Allocate): Add new Alignment
parameter.
(Memory_Alignment): Remove.
* libgnat/s-secsta.adb (Align_Addr): New.
(SS_Allocate): Add new Alignment parameter. Realign pointer if
needed. Don't allocate anything for 0-sized allocations.
* gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Add
allocated object's alignment as last parameter to allocation
invocation.
gcc/ada/gcc-interface/utils2.cc
gcc/ada/libgnat/s-secsta.adb
gcc/ada/libgnat/s-secsta.ads