This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 5/5] Make ipa-sra observe the used parameter.
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Richard Guenther <rguenther at suse dot de>
- Date: Thu, 09 Jul 2009 19:43:34 +0200
- Subject: [PATCH 5/5] Make ipa-sra observe the used parameter.
- References: <20090709174329.696498141@virgil.suse.cz>
This is to a big extent an RFC patch which makes IPA-SRA ignore
parameters decorated with the attribute "used." Unlike the other
ones, it also needs an approval from a C front-end maintainer.
2009-07-09 Martin Jambor <mjambor@suse.cz>
* c-common.c (handle_used_attribute): Also accept the attribute on
PARM_DECLs.
* tree-sra.c (find_param_candidates): Do not consider parameters
decorated with the used attribute.
* testsuite/gcc.dg/ipa/ipa-sra-5.c: New testsuite.
Index: mine/gcc/c-common.c
===================================================================
--- mine.orig/gcc/c-common.c
+++ mine/gcc/c-common.c
@@ -6030,6 +6030,7 @@ handle_used_attribute (tree *pnode, tree
tree node = *pnode;
if (TREE_CODE (node) == FUNCTION_DECL
+ || TREE_CODE (node) == PARM_DECL
|| (TREE_CODE (node) == VAR_DECL && TREE_STATIC (node)))
{
TREE_USED (node) = 1;
Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -2691,7 +2691,8 @@ find_param_candidates (void)
count++;
if (TREE_THIS_VOLATILE (parm)
- || TREE_ADDRESSABLE (parm))
+ || TREE_ADDRESSABLE (parm)
+ || DECL_PRESERVE_P (parm))
continue;
if (is_unused_scalar_param (parm))
Index: mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-5.c
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/gcc.dg/ipa/ipa-sra-5.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-eipa_sra-details" } */
+
+static int *
+__attribute__((noinline))
+ ox (int *i, __attribute__((used)) int *j)
+{
+ return i;
+}
+
+int a;
+
+int *caller (void)
+{
+ int b = 10;
+
+ return ox (&a, &b);
+}
+/* { dg-final { scan-tree-dump-times "base: j, remove_param" 0 "eipa_sra" } } */
+/* { dg-final { cleanup-tree-dump "eipa_sra" } } */