public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][AArch64] Define MALLOC_ABI_ALIGNMENT
@ 2017-10-31 17:14 Wilco Dijkstra
  2017-11-01 17:41 ` James Greenhalgh
  0 siblings, 1 reply; 4+ messages in thread
From: Wilco Dijkstra @ 2017-10-31 17:14 UTC (permalink / raw)
  To: GCC Patches; +Cc: nd

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.
--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][AArch64] Define MALLOC_ABI_ALIGNMENT
  2017-10-31 17:14 [PATCH][AArch64] Define MALLOC_ABI_ALIGNMENT Wilco Dijkstra
@ 2017-11-01 17:41 ` James Greenhalgh
  2017-11-02 10:54   ` Richard Earnshaw
  0 siblings, 1 reply; 4+ messages in thread
From: James Greenhalgh @ 2017-11-01 17:41 UTC (permalink / raw)
  To: Wilco Dijkstra; +Cc: GCC Patches, nd

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][AArch64] Define MALLOC_ABI_ALIGNMENT
  2017-11-01 17:41 ` James Greenhalgh
@ 2017-11-02 10:54   ` Richard Earnshaw
  2017-11-02 11:49     ` Wilco Dijkstra
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Earnshaw @ 2017-11-02 10:54 UTC (permalink / raw)
  To: James Greenhalgh, Wilco Dijkstra; +Cc: GCC Patches, nd

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][AArch64] Define MALLOC_ABI_ALIGNMENT
  2017-11-02 10:54   ` Richard Earnshaw
@ 2017-11-02 11:49     ` Wilco Dijkstra
  0 siblings, 0 replies; 4+ messages in thread
From: Wilco Dijkstra @ 2017-11-02 11:49 UTC (permalink / raw)
  To: Richard Earnshaw, James Greenhalgh; +Cc: GCC Patches, nd

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-02 11:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 17:14 [PATCH][AArch64] Define MALLOC_ABI_ALIGNMENT Wilco Dijkstra
2017-11-01 17:41 ` James Greenhalgh
2017-11-02 10:54   ` Richard Earnshaw
2017-11-02 11:49     ` Wilco Dijkstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).