diff mbox

[Ada] Improve alignment computation for allocators

Message ID 2433006.z01zuzAadJ@polaris
State New
Headers show

Commit Message

Eric Botcazou June 13, 2016, 7:41 a.m. UTC
Allocators return pointer to void internally so the derived alignment is the 
minimal one for known_alignment, although we know that it's always larger.

Tested on x86_64-suse-linux, applied on the mainline.


2016-06-13  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/utils2.c (known_alignment) <CALL_EXPR>: Deal specially
	with calls to malloc.
diff mbox

Patch

Index: gcc-interface/utils2.c
===================================================================
--- gcc-interface/utils2.c	(revision 237323)
+++ gcc-interface/utils2.c	(working copy)
@@ -171,6 +171,10 @@  known_alignment (tree exp)
 
     case CALL_EXPR:
       {
+	tree func = get_callee_fndecl (exp);
+	if (func && DECL_IS_MALLOC (func))
+	  return get_target_system_allocator_alignment () * BITS_PER_UNIT;
+
 	tree t = maybe_inline_call_in_expr (exp);
 	if (t)
 	  return known_alignment (t);