This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, PR 43835] Make IPA-SRA give up if certain function attributes are present


Hi,

On Thu, Apr 22, 2010 at 10:03:45PM +0200, Jakub Jelinek wrote:
> On Thu, Apr 22, 2010 at 07:29:18PM +0200, Martin Jambor wrote:
> > +  for (type_attrs = TYPE_ATTRIBUTES (TREE_TYPE (node->decl));
> > +       type_attrs;
> > +       type_attrs = TREE_CHAIN (type_attrs))
> > +    if (is_attribute_p ("nonnull", TREE_PURPOSE (type_attrs))
> > +	|| is_attribute_p ("format", TREE_PURPOSE (type_attrs))
> > +	|| is_attribute_p ("format_arg", TREE_PURPOSE (type_attrs)))
> > +      return false;
> 
> I believe alloc_size attribute needs to be treated the same and
> sentinel attribute likewise.

Thanks for checking this, I didn't find these when searching through
the info page.  An updated patch is below (I'm currently bootstrapping
it but don't expect any problems).  OK fro trunk and the 4.5 branch?

Martin

2010-04-23  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/43835
	* tree-sra.c (ipa_sra_preliminary_function_checks): Check that the
	function does not have nonnull, format, format_arg, alloc_size or
	sentinel attributes.

	* testsuite/gcc.c-torture/execute/pr43835.c: New test.


Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -4125,6 +4125,8 @@ modify_function (struct cgraph_node *nod
 static bool
 ipa_sra_preliminary_function_checks (struct cgraph_node *node)
 {
+  tree type_attrs;
+
   if (!cgraph_node_can_be_local_p (node))
     {
       if (dump_file)
@@ -4162,6 +4164,16 @@ ipa_sra_preliminary_function_checks (str
       return false;
     }
 
+  for (type_attrs = TYPE_ATTRIBUTES (TREE_TYPE (node->decl));
+       type_attrs;
+       type_attrs = TREE_CHAIN (type_attrs))
+    if (is_attribute_p ("nonnull", TREE_PURPOSE (type_attrs))
+	|| is_attribute_p ("format", TREE_PURPOSE (type_attrs))
+	|| is_attribute_p ("format_arg", TREE_PURPOSE (type_attrs))
+	|| is_attribute_p ("alloc_size", TREE_PURPOSE (type_attrs))
+	|| is_attribute_p ("sentinel", TREE_PURPOSE (type_attrs)))
+      return false;
+
   return true;
 }
 
Index: mine/gcc/testsuite/gcc.c-torture/execute/pr43835.c
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/gcc.c-torture/execute/pr43835.c
@@ -0,0 +1,51 @@
+struct PMC { 
+    unsigned flags;
+};
+
+typedef struct Pcc_cell
+{
+    struct PMC *p;
+    long bla;
+    long type;
+} Pcc_cell;
+
+extern void abort ();
+extern void Parrot_gc_mark_PMC_alive_fun(int * interp, struct PMC *pmc)
+     __attribute__((noinline));
+
+void Parrot_gc_mark_PMC_alive_fun (int * interp, struct PMC *pmc)
+{
+  abort ();
+}
+
+static void mark_cell(int * interp, Pcc_cell *c)
+        __attribute__((__nonnull__(1)))
+        __attribute__((__nonnull__(2)))
+        __attribute__((noinline));
+
+static void
+mark_cell(int * interp, Pcc_cell *c)
+{
+            if (c->type == 4 && c->p
+		&& !(c->p->flags & (1<<18)))
+	      Parrot_gc_mark_PMC_alive_fun(interp, c->p);
+}
+
+void foo(int * interp, Pcc_cell *c);
+
+void
+foo(int * interp, Pcc_cell *c)
+{
+  mark_cell(interp, c);
+}
+
+int main()
+{
+  int i; 
+  Pcc_cell c;
+  c.p = 0;
+  c.bla = 42;
+  c.type = 4;
+  foo (&i, &c);
+  return 0;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]