Hi,

After spending some time looking at ealias/pta dumps, I realized that they're hard to understand because we use varinfo names to identify varinfos, while those names are not necessarily unique.

F.i., for a function f:
...
void
f (int *__restrict__ a, int *__restrict__ b)
{
  *a = 1;
  *b = 2;
}
...

we have at ealias the constraints:
...
a = &PARM_NOALIAS
PARM_NOALIAS = NONLOCAL
b = &PARM_NOALIAS
PARM_NOALIAS = NONLOCAL
derefaddrtmp = &NONLOCAL
*a = derefaddrtmp
derefaddrtmp = &NONLOCAL
*b = derefaddrtmp
...
F.i. PARM_NOALIAS occurs several times, and it's not clear if there are one or two varinfos with that name.

Using attached patch, it's clearer what varinfos the constraints relate to:
...
a(8) = &PARM_NOALIAS(9)
PARM_NOALIAS(9) = NONLOCAL(5)
b(10) = &PARM_NOALIAS(11)
PARM_NOALIAS(11) = NONLOCAL(5)
derefaddrtmp(12) = &NONLOCAL(5)
*a(8) = derefaddrtmp(12)
derefaddrtmp(13) = &NONLOCAL(5)
*b(10) = derefaddrtmp(13)
...

It this a good idea, f.i. guarded by (dump_flags & TDF_DETAILS) not to disturb scans of current tests?

Or, do we f.i. want to fix the names themselves to be unique?

Thanks,
- Tom
Improve alias dump accuracy

diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 3510683..4ea1f43 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -660,7 +660,7 @@ dump_constraint (FILE *file, constraint_t c)
     fprintf (file, "&");
   else if (c->lhs.type == DEREF)
     fprintf (file, "*");
-  fprintf (file, "%s", get_varinfo (c->lhs.var)->name);
+  fprintf (file, "%s(%u)", get_varinfo (c->lhs.var)->name, c->lhs.var);
   if (c->lhs.offset == UNKNOWN_OFFSET)
     fprintf (file, " + UNKNOWN");
   else if (c->lhs.offset != 0)
@@ -670,7 +670,7 @@ dump_constraint (FILE *file, constraint_t c)
     fprintf (file, "&");
   else if (c->rhs.type == DEREF)
     fprintf (file, "*");
-  fprintf (file, "%s", get_varinfo (c->rhs.var)->name);
+  fprintf (file, "%s(%u)", get_varinfo (c->rhs.var)->name, c->rhs.var);
   if (c->rhs.offset == UNKNOWN_OFFSET)
     fprintf (file, " + UNKNOWN");
   else if (c->rhs.offset != 0)
@@ -5823,10 +5823,10 @@ dump_solution_for_var (FILE *file, unsigned int var)
 
   /* Dump the solution for unified vars anyway, this avoids difficulties
      in scanning dumps in the testsuite.  */
-  fprintf (file, "%s = { ", vi->name);
+  fprintf (file, "%s(%u) = { ", vi->name, vi->id);
   vi = get_varinfo (find (var));
   EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, i, bi)
-    fprintf (file, "%s ", get_varinfo (i)->name);
+    fprintf (file, "%s(%u) ", get_varinfo (i)->name, i);
   fprintf (file, "}");
 
   /* But note when the variable was unified.  */

Reply via email to