Re: [PATCH] Add alloc_align and assume_aligned attributes (PR middle-end/60092)

2014-07-06 Thread Gerald Pfeifer
On Thu, 6 Feb 2014, Jakub Jelinek wrote:
 As discussed on IRC, this patch introduces two new attributes,
 so that the C library (and other headers) have a way to
 a) tell the compiler something about functions like aligned_alloc
or memalign
 b) tell the compiler the alignment of pointers returned say by malloc

Hmm, it looks these did not make it into gcc-4.9/changes.html?  Mind
adding something there, Jakub?

Gerald


Re: [PATCH] Add alloc_align and assume_aligned attributes (PR middle-end/60092)

2014-02-07 Thread Richard Biener
On Thu, 6 Feb 2014, Jakub Jelinek wrote:

 Hi!
 
 As discussed on IRC, this patch introduces two new attributes,
 so that the C library (and other headers) have a way to
 a) tell the compiler something about functions like aligned_alloc
or memalign
 b) tell the compiler the alignment of pointers returned say by malloc
 
 Ok for trunk if bootstrap/regtest passes?
 
 2014-02-06  Jakub Jelinek  ja...@redhat.com
 
   PR middle-end/60092
   * tree-ssa-ccp.c (surely_varying_stmt_p): Don't return true
   if TYPE_ATTRIBUTES (gimple_call_fntype ()) contain
   assume_aligned or alloc_align attributes.
   (bit_value_alloc_assume_aligned_attribute): New function.   
   (evaluate_stmt): Handle calls to functions with
   assume_aligned or alloc_align attributes.
   * doc/extend.texi: Document assume_aligned and alloc_align
   attributes.
 c-family/
   * c-common.c (handle_alloc_align_attribute,
   handle_assume_aligned_attribute): New functions.
   (c_common_attribute_table): Add alloc_align and assume_aligned
   attributes.
 testsuite/
   * gcc.dg/attr-alloc_align-1.c: New test.
   * gcc.dg/attr-alloc_align-2.c: New test.
   * gcc.dg/attr-alloc_align-3.c: New test.
   * gcc.dg/attr-assume_aligned-1.c: New test.
   * gcc.dg/attr-assume_aligned-2.c: New test.
   * gcc.dg/attr-assume_aligned-3.c: New test.
 
 --- gcc/c-family/c-common.c.jj2014-02-05 10:37:58.0 +0100
 +++ gcc/c-family/c-common.c   2014-02-06 15:35:15.707333771 +0100
 @@ -366,6 +366,8 @@ static tree handle_warn_unused_result_at
  static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
  static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
  static tree handle_alloc_size_attribute (tree *, tree, tree, int, bool *);
 +static tree handle_alloc_align_attribute (tree *, tree, tree, int, bool *);
 +static tree handle_assume_aligned_attribute (tree *, tree, tree, int, bool 
 *);
  static tree handle_target_attribute (tree *, tree, tree, int, bool *);
  static tree handle_optimize_attribute (tree *, tree, tree, int, bool *);
  static tree ignore_attribute (tree *, tree, tree, int, bool *);
 @@ -766,6 +768,10 @@ const struct attribute_spec c_common_att
 handle_omp_declare_simd_attribute, false },
{ omp declare target, 0, 0, true, false, false,
 handle_omp_declare_target_attribute, false },
 +  { alloc_align, 1, 1, false, true, true,
 +   handle_alloc_align_attribute, false },
 +  { assume_aligned,  1, 2, false, true, true,
 +   handle_assume_aligned_attribute, false },
{ NULL, 0, 0, false, false, false, NULL, false }
  };
  
 @@ -8046,13 +8052,64 @@ handle_alloc_size_attribute (tree *node,
if (TREE_CODE (position) != INTEGER_CST
 || TREE_INT_CST_HIGH (position)
 || TREE_INT_CST_LOW (position)  1
 -   || TREE_INT_CST_LOW (position)  arg_count )
 +   || TREE_INT_CST_LOW (position)  arg_count)
   {
 warning (OPT_Wattributes,
  alloc_size parameter outside range);
 *no_add_attrs = true;
 return NULL_TREE;
   }
 +}
 +  return NULL_TREE;
 +}
 +
 +/* Handle a alloc_align attribute; arguments as in
 +   struct attribute_spec.handler.  */
 +
 +static tree
 +handle_alloc_align_attribute (tree *node, tree ARG_UNUSED (name), tree args,
 +   int, bool *no_add_attrs)
 +{
 +  unsigned arg_count = type_num_arguments (*node);
 +  tree position = TREE_VALUE (args);
 +  if (position  TREE_CODE (position) != IDENTIFIER_NODE
 +   TREE_CODE (position) != FUNCTION_DECL)
 +position = default_conversion (position);
 +
 +  if (TREE_CODE (position) != INTEGER_CST
 +  || TREE_INT_CST_HIGH (position)
 +  || TREE_INT_CST_LOW (position)  1
 +  || TREE_INT_CST_LOW (position)  arg_count)

You make it easier for wide-int folks if you use tree_fits_uhwi_p
and tree_to_uhwi ...

 +{
 +  warning (OPT_Wattributes,
 +alloc_align parameter outside range);
 +  *no_add_attrs = true;
 +  return NULL_TREE;
 +}
 +  return NULL_TREE;
 +}
 +
 +/* Handle a assume_aligned attribute; arguments as in
 +   struct attribute_spec.handler.  */
 +
 +static tree
 +handle_assume_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree 
 args,
 +  int, bool *no_add_attrs)
 +{
 +  for (; args; args = TREE_CHAIN (args))
 +{
 +  tree position = TREE_VALUE (args);
 +  if (position  TREE_CODE (position) != IDENTIFIER_NODE
 +TREE_CODE (position) != FUNCTION_DECL)
 + position = default_conversion (position);
 +
 +  if (TREE_CODE (position) != INTEGER_CST)
 + {
 +   warning (OPT_Wattributes,
 +assume_aligned parameter not integer constant);
 +   *no_add_attrs = true;
 +   return NULL_TREE;
 +   

Re: [PATCH] Add alloc_align and assume_aligned attributes (PR middle-end/60092)

2014-02-07 Thread Jakub Jelinek
On Fri, Feb 07, 2014 at 10:02:29AM +0100, Richard Biener wrote:
  +  if (TREE_CODE (position) != INTEGER_CST
  +  || TREE_INT_CST_HIGH (position)
  +  || TREE_INT_CST_LOW (position)  1
  +  || TREE_INT_CST_LOW (position)  arg_count)
 
 You make it easier for wide-int folks if you use tree_fits_uhwi_p
 and tree_to_uhwi ...

That was just a copy of the code from alloc_size, changed that too.

  +static prop_value_t
  +bit_value_alloc_assume_aligned_attribute (gimple stmt, tree attr,
  + prop_value_t ptrval,
  + bool alloc_aligned)
  +{
 
 This function is very similar to the existing bit_value_assume_aligned
 which asks for some factoring?  Like share the tails once you've
 figured out align and misalign values?

I've added support for the two attributes and original
__builtin_assume_aligned in just one function, will test it momentarily.

 I wonder if we want to backport support for these attributes
 to 4.8 (and 4.7?).

I think it doesn't help much.  At least glibc will need to conditionalize
the attributes on gcc version anyway, so they will be used only for GCC =
4.9 anyway (unless we'd do it for = 4.8.4 or something, can't be 4.8.3,
because, while it hasn't been released, current 4.8 branch snapshot mark
themselves as 4.8.3 in the patchlevel).

 Will you be working on a glibc patch?

I'll tell our glibc folks.

2014-02-07  Jakub Jelinek  ja...@redhat.com

PR middle-end/60092
* tree-ssa-ccp.c (surely_varying_stmt_p): Don't return true
if TYPE_ATTRIBUTES (gimple_call_fntype ()) contain
assume_aligned or alloc_align attributes.
(bit_value_assume_aligned): Add ATTR, PTRVAL and ALLOC_ALIGN
arguments.  Handle also assume_aligned and alloc_align attributes.
(evaluate_stmt): Adjust bit_value_assume_aligned caller.
Handle calls to functions with assume_aligned or alloc_align
attributes.
* doc/extend.texi: Document assume_aligned and alloc_align
attributes.
c-family/
* c-common.c (handle_alloc_size_attribute): Use tree_fits_uhwi_p
and tree_to_uhwi.
(handle_alloc_align_attribute, handle_assume_aligned_attribute): New
functions.
(c_common_attribute_table): Add alloc_align and assume_aligned
attributes.
testsuite/
* gcc.dg/attr-alloc_align-1.c: New test.
* gcc.dg/attr-alloc_align-2.c: New test.
* gcc.dg/attr-alloc_align-3.c: New test.
* gcc.dg/attr-assume_aligned-1.c: New test.
* gcc.dg/attr-assume_aligned-2.c: New test.
* gcc.dg/attr-assume_aligned-3.c: New test.

--- gcc/c-family/c-common.c.jj  2014-02-07 11:44:07.114924852 +0100
+++ gcc/c-family/c-common.c 2014-02-07 11:58:23.996841044 +0100
@@ -366,6 +366,8 @@ static tree handle_warn_unused_result_at
 static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
 static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
 static tree handle_alloc_size_attribute (tree *, tree, tree, int, bool *);
+static tree handle_alloc_align_attribute (tree *, tree, tree, int, bool *);
+static tree handle_assume_aligned_attribute (tree *, tree, tree, int, bool *);
 static tree handle_target_attribute (tree *, tree, tree, int, bool *);
 static tree handle_optimize_attribute (tree *, tree, tree, int, bool *);
 static tree ignore_attribute (tree *, tree, tree, int, bool *);
@@ -766,6 +768,10 @@ const struct attribute_spec c_common_att
  handle_omp_declare_simd_attribute, false },
   { omp declare target, 0, 0, true, false, false,
  handle_omp_declare_target_attribute, false },
+  { alloc_align,   1, 1, false, true, true,
+ handle_alloc_align_attribute, false },
+  { assume_aligned,1, 2, false, true, true,
+ handle_assume_aligned_attribute, false },
   { NULL, 0, 0, false, false, false, NULL, false }
 };
 
@@ -8043,16 +8049,62 @@ handle_alloc_size_attribute (tree *node,
   TREE_CODE (position) != FUNCTION_DECL)
position = default_conversion (position);
 
-  if (TREE_CODE (position) != INTEGER_CST
- || TREE_INT_CST_HIGH (position)
- || TREE_INT_CST_LOW (position)  1
- || TREE_INT_CST_LOW (position)  arg_count )
+  if (tree_fits_uhwi_p (position)
+ || !IN_RANGE (tree_to_uhwi (position), 1, arg_count))
{
  warning (OPT_Wattributes,
   alloc_size parameter outside range);
  *no_add_attrs = true;
  return NULL_TREE;
}
+}
+  return NULL_TREE;
+}
+
+/* Handle a alloc_align attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_alloc_align_attribute (tree *node, tree, tree args, int,
+ bool *no_add_attrs)
+{
+  unsigned arg_count = type_num_arguments (*node);
+  tree 

Re: [PATCH] Add alloc_align and assume_aligned attributes (PR middle-end/60092)

2014-02-07 Thread Richard Biener
On Fri, 7 Feb 2014, Jakub Jelinek wrote:

 On Fri, Feb 07, 2014 at 10:02:29AM +0100, Richard Biener wrote:
   +  if (TREE_CODE (position) != INTEGER_CST
   +  || TREE_INT_CST_HIGH (position)
   +  || TREE_INT_CST_LOW (position)  1
   +  || TREE_INT_CST_LOW (position)  arg_count)
  
  You make it easier for wide-int folks if you use tree_fits_uhwi_p
  and tree_to_uhwi ...
 
 That was just a copy of the code from alloc_size, changed that too.
 
   +static prop_value_t
   +bit_value_alloc_assume_aligned_attribute (gimple stmt, tree attr,
   +   prop_value_t ptrval,
   +   bool alloc_aligned)
   +{
  
  This function is very similar to the existing bit_value_assume_aligned
  which asks for some factoring?  Like share the tails once you've
  figured out align and misalign values?
 
 I've added support for the two attributes and original
 __builtin_assume_aligned in just one function, will test it momentarily.
 
  I wonder if we want to backport support for these attributes
  to 4.8 (and 4.7?).
 
 I think it doesn't help much.  At least glibc will need to conditionalize
 the attributes on gcc version anyway, so they will be used only for GCC =
 4.9 anyway (unless we'd do it for = 4.8.4 or something, can't be 4.8.3,
 because, while it hasn't been released, current 4.8 branch snapshot mark
 themselves as 4.8.3 in the patchlevel).

Ah, indeed.  Didn't think about the snapshots...

  Will you be working on a glibc patch?
 
 I'll tell our glibc folks.

Thanks.  Updated patch looks ok.

Richard.

 2014-02-07  Jakub Jelinek  ja...@redhat.com
 
   PR middle-end/60092
   * tree-ssa-ccp.c (surely_varying_stmt_p): Don't return true
   if TYPE_ATTRIBUTES (gimple_call_fntype ()) contain
   assume_aligned or alloc_align attributes.
   (bit_value_assume_aligned): Add ATTR, PTRVAL and ALLOC_ALIGN
   arguments.  Handle also assume_aligned and alloc_align attributes.
   (evaluate_stmt): Adjust bit_value_assume_aligned caller.
   Handle calls to functions with assume_aligned or alloc_align
   attributes.
   * doc/extend.texi: Document assume_aligned and alloc_align
   attributes.
 c-family/
   * c-common.c (handle_alloc_size_attribute): Use tree_fits_uhwi_p
   and tree_to_uhwi.
   (handle_alloc_align_attribute, handle_assume_aligned_attribute): New
   functions.
   (c_common_attribute_table): Add alloc_align and assume_aligned
   attributes.
 testsuite/
   * gcc.dg/attr-alloc_align-1.c: New test.
   * gcc.dg/attr-alloc_align-2.c: New test.
   * gcc.dg/attr-alloc_align-3.c: New test.
   * gcc.dg/attr-assume_aligned-1.c: New test.
   * gcc.dg/attr-assume_aligned-2.c: New test.
   * gcc.dg/attr-assume_aligned-3.c: New test.
 
 --- gcc/c-family/c-common.c.jj2014-02-07 11:44:07.114924852 +0100
 +++ gcc/c-family/c-common.c   2014-02-07 11:58:23.996841044 +0100
 @@ -366,6 +366,8 @@ static tree handle_warn_unused_result_at
  static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
  static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
  static tree handle_alloc_size_attribute (tree *, tree, tree, int, bool *);
 +static tree handle_alloc_align_attribute (tree *, tree, tree, int, bool *);
 +static tree handle_assume_aligned_attribute (tree *, tree, tree, int, bool 
 *);
  static tree handle_target_attribute (tree *, tree, tree, int, bool *);
  static tree handle_optimize_attribute (tree *, tree, tree, int, bool *);
  static tree ignore_attribute (tree *, tree, tree, int, bool *);
 @@ -766,6 +768,10 @@ const struct attribute_spec c_common_att
 handle_omp_declare_simd_attribute, false },
{ omp declare target, 0, 0, true, false, false,
 handle_omp_declare_target_attribute, false },
 +  { alloc_align, 1, 1, false, true, true,
 +   handle_alloc_align_attribute, false },
 +  { assume_aligned,  1, 2, false, true, true,
 +   handle_assume_aligned_attribute, false },
{ NULL, 0, 0, false, false, false, NULL, false }
  };
  
 @@ -8043,16 +8049,62 @@ handle_alloc_size_attribute (tree *node,
  TREE_CODE (position) != FUNCTION_DECL)
   position = default_conversion (position);
  
 -  if (TREE_CODE (position) != INTEGER_CST
 -   || TREE_INT_CST_HIGH (position)
 -   || TREE_INT_CST_LOW (position)  1
 -   || TREE_INT_CST_LOW (position)  arg_count )
 +  if (tree_fits_uhwi_p (position)
 +   || !IN_RANGE (tree_to_uhwi (position), 1, arg_count))
   {
 warning (OPT_Wattributes,
  alloc_size parameter outside range);
 *no_add_attrs = true;
 return NULL_TREE;
   }
 +}
 +  return NULL_TREE;
 +}
 +
 +/* Handle a alloc_align attribute; arguments as in
 +   struct attribute_spec.handler.  */
 +
 +static tree
 

Re: [PATCH] Add alloc_align and assume_aligned attributes (PR middle-end/60092)

2014-02-07 Thread Bernhard Reutner-Fischer

On 6 February 2014 16:42:05 Jakub Jelinek ja...@redhat.com wrote:


Hi!

As discussed on IRC, this patch introduces two new attributes,
so that the C library (and other headers) have a way to
a) tell the compiler something about functions like aligned_alloc
   or memalign
b) tell the compiler the alignment of pointers returned say by malloc

Ok for trunk if bootstrap/regtest passes?



+/* Return the propagation value for functions with assume_aligned
+   or alloc_aligned attribute.  */
+
+static prop_value_t
+bit_value_alloc_assume_aligned_attribute (gimple stmt, tree attr,
+ prop_value_t ptrval,
+ bool alloc_aligned)
+{
+  tree lhs = gimple_call_lhs (stmt), align, misalign = NULL_TREE;
+  tree type = TREE_TYPE (lhs);
+  unsigned HOST_WIDE_INT aligni, misaligni = 0;
+  prop_value_t alignval;
+  double_int value, mask;
+  prop_value_t val;


Do we have an optimization that moves most of the above down..


+  if (ptrval.lattice_val == UNDEFINED)
+return ptrval;
+  gcc_assert ((ptrval.lattice_val == CONSTANT
+   TREE_CODE (ptrval.value) == INTEGER_CST)
+ || ptrval.mask.is_minus_one ());
+  if (TREE_VALUE (attr) == NULL_TREE)
+return ptrval;
+  attr = TREE_VALUE (attr);
+  align = TREE_VALUE (attr);
+  if (!tree_fits_uhwi_p (align))
+return ptrval;
+  aligni = tree_to_uhwi (align);
+  if (alloc_aligned)
+{
+  if (aligni == 0 || aligni  gimple_call_num_args (stmt))
+   return ptrval;
+  align = gimple_call_arg (stmt, aligni - 1);
+  if (!tree_fits_uhwi_p (align))
+   return ptrval;
+  aligni = tree_to_uhwi (align);
+}
+  if (aligni = 1
+  || (aligni  (aligni - 1)) != 0)
+return ptrval;
+  if (!alloc_aligned  TREE_CHAIN (attr)  TREE_VALUE (TREE_CHAIN (attr)))
+{
+  misalign = TREE_VALUE (TREE_CHAIN (attr));
+  if (!tree_fits_uhwi_p (misalign))
+   return ptrval;
+  misaligni = tree_to_uhwi (misalign);
+  if (misaligni = aligni)
+   return ptrval;
+}


.. here, btw? Or would one have to do that manually?
Just curious.
Thanks,


+  align = build_int_cst_type (type, -aligni);
+  alignval = get_value_for_expr (align, true);
+  bit_value_binop_1 (BIT_AND_EXPR, type, value, mask,
+type, value_to_double_int (ptrval), ptrval.mask,
+type, value_to_double_int (alignval), alignval.mask);
+  if (!mask.is_minus_one ())
+{
+  val.lattice_val = CONSTANT;
+  val.mask = mask;
+  gcc_assert ((mask.low  (aligni - 1)) == 0);
+  gcc_assert ((value.low  (aligni - 1)) == 0);
+  value.low |= misaligni;
+  /* ???  Delay building trees here.  */
+  val.value = double_int_to_tree (type, value);
+}
+  else
+{
+  val.lattice_val = VARYING;
+  val.value = NULL_TREE;
+  val.mask = double_int_minus_one;
+}
+  return val;
+}
+
 /* Evaluate statement STMT.
Valid only for assignments, calls, conditionals, and switches. */




Sent with AquaMail for Android
http://www.aqua-mail.com




[PATCH] Add alloc_align and assume_aligned attributes (PR middle-end/60092)

2014-02-06 Thread Jakub Jelinek
Hi!

As discussed on IRC, this patch introduces two new attributes,
so that the C library (and other headers) have a way to
a) tell the compiler something about functions like aligned_alloc
   or memalign
b) tell the compiler the alignment of pointers returned say by malloc

Ok for trunk if bootstrap/regtest passes?

2014-02-06  Jakub Jelinek  ja...@redhat.com

PR middle-end/60092
* tree-ssa-ccp.c (surely_varying_stmt_p): Don't return true
if TYPE_ATTRIBUTES (gimple_call_fntype ()) contain
assume_aligned or alloc_align attributes.
(bit_value_alloc_assume_aligned_attribute): New function.   
(evaluate_stmt): Handle calls to functions with
assume_aligned or alloc_align attributes.
* doc/extend.texi: Document assume_aligned and alloc_align
attributes.
c-family/
* c-common.c (handle_alloc_align_attribute,
handle_assume_aligned_attribute): New functions.
(c_common_attribute_table): Add alloc_align and assume_aligned
attributes.
testsuite/
* gcc.dg/attr-alloc_align-1.c: New test.
* gcc.dg/attr-alloc_align-2.c: New test.
* gcc.dg/attr-alloc_align-3.c: New test.
* gcc.dg/attr-assume_aligned-1.c: New test.
* gcc.dg/attr-assume_aligned-2.c: New test.
* gcc.dg/attr-assume_aligned-3.c: New test.

--- gcc/c-family/c-common.c.jj  2014-02-05 10:37:58.0 +0100
+++ gcc/c-family/c-common.c 2014-02-06 15:35:15.707333771 +0100
@@ -366,6 +366,8 @@ static tree handle_warn_unused_result_at
 static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
 static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
 static tree handle_alloc_size_attribute (tree *, tree, tree, int, bool *);
+static tree handle_alloc_align_attribute (tree *, tree, tree, int, bool *);
+static tree handle_assume_aligned_attribute (tree *, tree, tree, int, bool *);
 static tree handle_target_attribute (tree *, tree, tree, int, bool *);
 static tree handle_optimize_attribute (tree *, tree, tree, int, bool *);
 static tree ignore_attribute (tree *, tree, tree, int, bool *);
@@ -766,6 +768,10 @@ const struct attribute_spec c_common_att
  handle_omp_declare_simd_attribute, false },
   { omp declare target, 0, 0, true, false, false,
  handle_omp_declare_target_attribute, false },
+  { alloc_align,   1, 1, false, true, true,
+ handle_alloc_align_attribute, false },
+  { assume_aligned,1, 2, false, true, true,
+ handle_assume_aligned_attribute, false },
   { NULL, 0, 0, false, false, false, NULL, false }
 };
 
@@ -8046,13 +8052,64 @@ handle_alloc_size_attribute (tree *node,
   if (TREE_CODE (position) != INTEGER_CST
  || TREE_INT_CST_HIGH (position)
  || TREE_INT_CST_LOW (position)  1
- || TREE_INT_CST_LOW (position)  arg_count )
+ || TREE_INT_CST_LOW (position)  arg_count)
{
  warning (OPT_Wattributes,
   alloc_size parameter outside range);
  *no_add_attrs = true;
  return NULL_TREE;
}
+}
+  return NULL_TREE;
+}
+
+/* Handle a alloc_align attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_alloc_align_attribute (tree *node, tree ARG_UNUSED (name), tree args,
+ int, bool *no_add_attrs)
+{
+  unsigned arg_count = type_num_arguments (*node);
+  tree position = TREE_VALUE (args);
+  if (position  TREE_CODE (position) != IDENTIFIER_NODE
+   TREE_CODE (position) != FUNCTION_DECL)
+position = default_conversion (position);
+
+  if (TREE_CODE (position) != INTEGER_CST
+  || TREE_INT_CST_HIGH (position)
+  || TREE_INT_CST_LOW (position)  1
+  || TREE_INT_CST_LOW (position)  arg_count)
+{
+  warning (OPT_Wattributes,
+  alloc_align parameter outside range);
+  *no_add_attrs = true;
+  return NULL_TREE;
+}
+  return NULL_TREE;
+}
+
+/* Handle a assume_aligned attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_assume_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
+int, bool *no_add_attrs)
+{
+  for (; args; args = TREE_CHAIN (args))
+{
+  tree position = TREE_VALUE (args);
+  if (position  TREE_CODE (position) != IDENTIFIER_NODE
+  TREE_CODE (position) != FUNCTION_DECL)
+   position = default_conversion (position);
+
+  if (TREE_CODE (position) != INTEGER_CST)
+   {
+ warning (OPT_Wattributes,
+  assume_aligned parameter not integer constant);
+ *no_add_attrs = true;
+ return NULL_TREE;
+   }
 }
   return NULL_TREE;
 }
--- gcc/tree-ssa-ccp.c.jj   2014-01-03 11:40:46.0 +0100
+++ gcc/tree-ssa-ccp.c  2014-02-06 16:16:27.260996887 +0100
@@ -738,13 

Re: [PATCH] Add alloc_align and assume_aligned attributes (PR middle-end/60092)

2014-02-06 Thread Marc Glisse

On Thu, 6 Feb 2014, Jakub Jelinek wrote:


+/* Handle a alloc_align attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_alloc_align_attribute (tree *node, tree ARG_UNUSED (name), tree args,
+ int, bool *no_add_attrs)
+{
+  unsigned arg_count = type_num_arguments (*node);
+  tree position = TREE_VALUE (args);
+  if (position  TREE_CODE (position) != IDENTIFIER_NODE
+   TREE_CODE (position) != FUNCTION_DECL)
+position = default_conversion (position);


The FUNCTION_DECL test is only useful when there are 2+ arguments to the
builtin (but it doesn't hurt).

--
Marc Glisse