[PR debug/41343] introduce debug expr temps

Alexandre Oliva aoliva@redhat.com
Tue Sep 22 19:51:00 GMT 2009


This patch enables VTA to assign debug-only names to expressions
formerly computed at a certain point in the code stream, and then use
these names to replace the removed/modified identifiers, instead of
substituting the identifiers for the assigned expression.

IOW, if we start from:

foo_3 = a_1 + b_2;
...
# DEBUG x => foo_3 + bar_4

if we remove the DEF of foo_3, we should get:

# DEBUG D#1 => a_1 + b_2
...
# DEBUG x => D#1 + bar_4

D# are names for debug temps, represented as another kind of
declaration, that never appears in expressions other than debug stmts,
and with counters that don't interfere with the regular declaration
counters (messing with the would cause codegen differences).

This idea came out of Andrew Macleod's debug locus specification.  The
exponential growth of expressions in debug stmts, reported in PR 41343,
made it obvious that we needed something along these lines sooner rather
than later.


I'm not entirely happy with this patch, but it might serve as a stopgap
for the time being.  Some of the points that could be improved are:

- use something smaller than a DECL structure for DEBUG_EXPR_DECLs.  We
don't need all the stuff in a DECL, just a uid, a TYPE, a MODE (could be
inferred from the TYPE), and an RTL expansion

- avoid emitting multiple redundant copies of the same debug bind stmt
when removing an SSA DEF (*)

- maybe linking VALUEs of DEBUG_EXPR_DECL and the corresponding
expression by VALUE equivalence, rather than handling DECL_EXPR_DECLs as
another kind of variable in var-tracking

- use the explicit presence of DEBUG_EXPR_DECLs to decide whether to use
DW_OP_calls for complex sub-expressions, or inline the subexpressions in
location encoding

- use tuple assign-like forms for debug bind stmts, now possible because
the expression forms are simpler

(*)

ATM we decide to propagate the DEF into debug stmts, we no longer know
even in which block it used to be.  If it has already been unlinked, we
can't even emit the debug bind stmt right before or right after it.

I ended up implementing code to emit multiple copies of the debug bind
stmt, right before each USE.

We could do much better, emitting always a single copy of the debug bind
stmt, say at the block that dominates all USEs, right before the
earliest USE in that block, if there is any, or at the end of the block
otherwise.

But it would be much simpler to just emit the DEBUG use when unlinking
the DEF, so that it remains in the right place.  Failing that, we might
have to be concerned about expressions that vary between the DEF point
and the USE point, say references to global variables or memory
locations.  Code that was in place before simply disregarded that, but
introducing debug temps always at the def point would be a simple and
clean way to fix this, for var-tracking already takes care of noticing
changes and dropping equivalences.


In spite of all these shortcomings, I'd like to propose that we put this
patch in now, while I (we?) work on other urgent issues, and then on
making the improvements mentioned above.

This was regstrapped on x86_64-linux-gnu.  Ok to install?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vta-temp-values-pr41343.patch
Type: text/x-diff
Size: 15823 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090922/6ededa57/attachment.bin>
-------------- next part --------------

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer


More information about the Gcc-patches mailing list