diff mbox series

[AArch64] Define MALLOC_ABI_ALIGNMENT

Message ID DB6PR0801MB2053457858AEF015746EC80B835E0@DB6PR0801MB2053.eurprd08.prod.outlook.com
State New
Headers show
Series [AArch64] Define MALLOC_ABI_ALIGNMENT | expand

Commit Message

Wilco Dijkstra Oct. 31, 2017, 5:07 p.m. UTC
The AArch64 backend currently doesn't set MALLOC_ABI_ALIGNMENT, so
add this to enable alignment optimizations on malloc pointers.

OK for commit?

2017-10-31  Wilco Dijkstra  <wdijkstr@arm.com>

	* config/aarch64/aarch64.h (MALLOC_ABI_ALIGNMENT): New define.
--

Comments

James Greenhalgh Nov. 1, 2017, 5:40 p.m. UTC | #1
On Tue, Oct 31, 2017 at 05:07:54PM +0000, Wilco Dijkstra wrote:
> The AArch64 backend currently doesn't set MALLOC_ABI_ALIGNMENT, so
> add this to enable alignment optimizations on malloc pointers.
> 
> OK for commit?

As far as I understand it, because we have 128-bit types, a malloc of
anything greater than 16 bytes would require 16-byte alignment. So, assuming
this macro isn't required to desribe possibly unaligned smaller allocations
(for example 1 byte allocations), this is OK.

Reviewed-By: James Greenhalgh <james.greenhalgh@arm.com>

Thanks,
James

> 
> 2017-10-31  Wilco Dijkstra  <wdijkstr@arm.com>
> 
> 	* config/aarch64/aarch64.h (MALLOC_ABI_ALIGNMENT): New define.
> --
> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
> index 8e7093f0476fa7fed3ba6d6cb008743106d1ff58..159dde7c7134d4d0e5378951d1d8a1d6dab48ba2 100644
> --- a/gcc/config/aarch64/aarch64.h
> +++ b/gcc/config/aarch64/aarch64.h
> @@ -111,6 +111,9 @@
>  
>  #define STRUCTURE_SIZE_BOUNDARY		8
>  
> +/* Heap alignment.  */
> +#define MALLOC_ABI_ALIGNMENT  BIGGEST_ALIGNMENT
> +
>  /* Defined by the ABI */
>  #define WCHAR_TYPE "unsigned int"
>  #define WCHAR_TYPE_SIZE			32
Richard Earnshaw Nov. 2, 2017, 10:54 a.m. UTC | #2
On 01/11/17 17:40, James Greenhalgh wrote:
> On Tue, Oct 31, 2017 at 05:07:54PM +0000, Wilco Dijkstra wrote:
>> The AArch64 backend currently doesn't set MALLOC_ABI_ALIGNMENT, so
>> add this to enable alignment optimizations on malloc pointers.
>>
>> OK for commit?
> 
> As far as I understand it, because we have 128-bit types, a malloc of
> anything greater than 16 bytes would require 16-byte alignment. So, assuming
> this macro isn't required to desribe possibly unaligned smaller allocations
> (for example 1 byte allocations), this is OK.
> 
> Reviewed-By: James Greenhalgh <james.greenhalgh@arm.com>
> 
> Thanks,
> James
> 
>>
>> 2017-10-31  Wilco Dijkstra  <wdijkstr@arm.com>
>>
>> 	* config/aarch64/aarch64.h (MALLOC_ABI_ALIGNMENT): New define.
>> --
>> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
>> index 8e7093f0476fa7fed3ba6d6cb008743106d1ff58..159dde7c7134d4d0e5378951d1d8a1d6dab48ba2 100644
>> --- a/gcc/config/aarch64/aarch64.h
>> +++ b/gcc/config/aarch64/aarch64.h
>> @@ -111,6 +111,9 @@
>>  
>>  #define STRUCTURE_SIZE_BOUNDARY		8
>>  
>> +/* Heap alignment.  */
>> +#define MALLOC_ABI_ALIGNMENT  BIGGEST_ALIGNMENT
>> +
>>  /* Defined by the ABI */
>>  #define WCHAR_TYPE "unsigned int"
>>  #define WCHAR_TYPE_SIZE			32

I wonder if it would be safer to define this explicitly as the current
value of BIGGEST_ALIGNMENT; then if we ever have to change the latter we
won't get silent breakage.

R.
Wilco Dijkstra Nov. 2, 2017, 11:49 a.m. UTC | #3
Richard Earnshaw wrote:
> On 01/11/17 17:40, James Greenhalgh wrote:

>> As far as I understand it, because we have 128-bit types, a malloc of
>> anything greater than 16 bytes would require 16-byte alignment. So, assuming
>> this macro isn't required to desribe possibly unaligned smaller allocations
>> (for example 1 byte allocations), this is OK.

I'm sure one can create structures with 16-byte alignment that are smaller than
16 bytes. For example union of say a char and __int128 empty_array[0] should do it.

>> +#define MALLOC_ABI_ALIGNMENT  BIGGEST_ALIGNMENT

> I wonder if it would be safer to define this explicitly as the current
> value of BIGGEST_ALIGNMENT; then if we ever have to change the latter we
> won't get silent breakage.

I'll do that for the commit. I used BIGGEST_ALIGNMENT since that is what the
Arm port does...

Wilco
diff mbox series

Patch

diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 8e7093f0476fa7fed3ba6d6cb008743106d1ff58..159dde7c7134d4d0e5378951d1d8a1d6dab48ba2 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -111,6 +111,9 @@ 
 
 #define STRUCTURE_SIZE_BOUNDARY		8
 
+/* Heap alignment.  */
+#define MALLOC_ABI_ALIGNMENT  BIGGEST_ALIGNMENT
+
 /* Defined by the ABI */
 #define WCHAR_TYPE "unsigned int"
 #define WCHAR_TYPE_SIZE			32