This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR 43835] Make IPA-SRA give up if certain function attributes are present
Hi,
On Fri, Apr 23, 2010 at 01:58:53PM +0200, Richard Guenther wrote:
> On Fri, 23 Apr 2010, Martin Jambor wrote:
>
> > 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?
>
> Wouldn't it be simpler and less error-prone to give up on any
> type attribute? The only one that would be falsely covered
> is warn_unused_result (does SRA remove return values?)
No, it doesn't.
>
> The patch is ok with that change (if (TYPE_ATTRIBUTES (TREE_TYPE
> (node->decl))) return false;).
OK, this is what I committed as revision 158667.
Thanks,
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 type 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
@@ -4162,6 +4162,9 @@ ipa_sra_preliminary_function_checks (str
return false;
}
+ if (TYPE_ATTRIBUTES (TREE_TYPE (node->decl)))
+ 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;
+}