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]

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


Hi,

the patch below makes IPA-SRA not to process functions with nonnull,
format or format_arg attributes so that it does not have to deal with
the indices they have as parameters.  This is the easiest fix for PR
43835 and I'd like to commit it before I manage to re-work the
parameter manipulation system (to create proper ABSTRACT_ORIGINS, not
to mess up PARAM_DECL chains and so on).

Bootstrapped and tested on x86-64-linux with no problems. OK for trunk
and the 4.5 branch?

Thanks,

Martin


2010-04-22  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 or format_arg 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,14 @@ 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)))
+      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]