On 28/10/15 12:10, Richard Biener wrote:
On Wed, 28 Oct 2015, Tom de Vries wrote:

Richard,

when compiling this testcase:
...
static int __attribute__((noinline, noclone))
foo (int *a, int *b)
{
   *b = 1;
   *a = 2;
   return *b;
}

int __attribute__((noinline, noclone))
bar (int *a, int *b)
{
   return foo (a, b);
}
...

with -O2 -fipa-pta we find in the pta dumpfile:
...
Generating constraints for bar (bar)

bar.arg0 = &NONLOCAL
bar.arg1 = &NONLOCAL
bar.arg1 = &NONLOCAL
...

The reason for the duplicate last two constraints is that with fipa-pta, in
create_function_info_for we link the function arguments in a next chain.

And in intra_create_variable_infos there are two iteration mechanism used:
- the loop over the function arguments
- the loop over the vi_next (p) for each function argument p

So when processing argument a, we generate constraints for both a and it's
next b.
And when processing argument b, we generate constraints for b again.

Is this a known issue? Should we fix this?

Didn't see that yet.  Yes, we should fix it.

Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c  (revision 229481)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -5913,6 +6009,8 @@ intra_create_variable_infos (struct func
                 make_constraint_from_global_restrict (p, "PARM_RESTRICT");
               else if (p->may_have_pointers)
                 make_constraint_from (p, nonlocal_id);
+             if (p->is_full_var)
+               break;
             }
         }
      }

does for me.  Pre-approved if it passes testing.

Tested and committed. Posting with ChangeLog entry.

Thanks,
- Tom
Generate constraints only once in intra_create_variable_infos

2015-10-28  Tom de Vries  <t...@codesourcery.com>

	* tree-ssa-structalias.c (intra_create_variable_infos): Don't iterate
	into vi_next of a full_var.
---
 gcc/tree-ssa-structalias.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 07ec4a5..06415a2 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -5924,6 +5924,8 @@ intra_create_variable_infos (struct function *fn)
 		make_constraint_from_global_restrict (p, "PARM_RESTRICT", true);
 	      else if (p->may_have_pointers)
 		make_constraint_from (p, nonlocal_id);
+	      if (p->is_full_var)
+		break;
 	    }
 	}
     }
-- 
1.9.1

Reply via email to