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]: Fix PR/14638


This PR is a regression in our debug info generation, due to out-of-ssa splitting variables and us not being able to track that.

This is also a "cover PR" for the more general problem that we need to be able to track a *tree* that has been split into multiple variables in a sane way (we can already track the RTL).

The attached patch is a deceptively simple fix for this problem, made possible because we already have support for tracking this at the RTL level.
We just needed a way to say that "we've split this original user variable into these variables over here".


To do this was a four step process
1. i've simply taken what the docs say is unused field on var_decls (decl.vindex), and used it to store the user variable we were split from, for debug info purposes.


2. I told out-of-ssa to record what variable it's splitting from in that field.

3. Then, i've told the var-tracking code to track the value of the variable if the ultimate variable it is an alias of is not ignored for debug purposes.

4. I told dwarf2out's note_var_location to add the location of the split variable to the location list for the decl we are an alias of.

I think this is roughly the best we can do for now.

For the testcase in the PR:
foo (int b)
{
  int a = b;

loop:
  if (b > 0)
    {
      b--;
      goto loop;
    }

  return a + b;
}

main()
{
  printf ("%d\n", foo (93));
}

compiled with -O1 -fno-ivopts -g
(ivopt causes the whole function to just calculate a return value)

we will now properly associate the locations of the b.0 var that out-of-ssa creates with the user's b variable.
This can be seen simply by looking at the assembly/readelf output and noting that the locations noted as b.0 are also in b's location list.
Half the gdb's i have around don't seem to use the right values out of the location list anyway, but that's a gdb problem, since we clearly are saying b.0's values are that of b's, which is what we want.


We can also use this support for whenever we create new temporaries from existing ones, if we so choose (IE use it in more than just out-of-ssa).

This is currently bootstrapping and regtesting on my i686.
Okay for mainline if it passes?



Attachment: aliasof.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]