[Ada] Bump secondary stack alignment factor in full runtimes
authorOlivier Hainque <hainque@adacore.com>
Tue, 24 Mar 2020 08:49:29 +0000 (08:49 +0000)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 12 Jun 2020 08:29:30 +0000 (04:29 -0400)
2020-06-12  Olivier Hainque  <hainque@adacore.com>

gcc/ada/

* libgnat/s-secsta.ads (Memory_Alignment): New constant, memory
alignment for chunks and allocated blocks. Initialize to
Standard'Maximum_Alignment * 2.
(Chunk_Memory): Use it.
* libgnat/s-secsta.adb (Round_Up): Likewise.

gcc/ada/libgnat/s-secsta.adb
gcc/ada/libgnat/s-secsta.ads

index 0010449..7ec8462 100644 (file)
@@ -564,7 +564,7 @@ package body System.Secondary_Stack is
       --------------
 
       function Round_Up (Size : Storage_Count) return Memory_Size is
-         Algn_MS : constant Memory_Size := Standard'Maximum_Alignment;
+         Algn_MS : constant Memory_Size := Memory_Alignment;
          Size_MS : constant Memory_Size := Memory_Size (Size);
 
       begin
index 764ae2f..d06e97f 100644 (file)
@@ -261,10 +261,23 @@ private
    subtype Memory_Index is Memory_Size;
    --  Index into the memory storage of a single chunk
 
+   Memory_Alignment : constant := Standard'Maximum_Alignment * 2;
+   --  The memory alignment we will want to honor on every allocation.
+   --
+   --  At this stage, gigi assumes we can accomodate any alignment requirement
+   --  there might be on the data type for which the memory gets allocated (see
+   --  build_call_alloc_dealloc).
+   --
+   --  The multiplication factor is intended to account for requirements
+   --  by user code compiled with specific arch/cpu options such as -mavx
+   --  on X86[_64] targets, which Standard'Maximum_Alignment doesn't convey
+   --  without such compilation options. * 4 would actually be needed to
+   --  support -mavx512f on X86, but this would incur more annoying memory
+   --  consumption overheads.
+
    type Chunk_Memory is array (Memory_Size range <>) of SSE.Storage_Element;
-   for Chunk_Memory'Alignment use Standard'Maximum_Alignment;
-   --  The memory storage of a single chunk. It utilizes maximum alignment in
-   --  order to guarantee efficient operations.
+   for Chunk_Memory'Alignment use Memory_Alignment;
+   --  The memory storage of a single chunk
 
    --------------
    -- SS_Chunk --