On 06/11/14 09:02, Olivier Hainque wrote:
Hello,

For blocks requiring it, the gimplifier generates stack pointer
save/restore operations on entry/exit, per:

  gimplify_bind_expr (...)

   if (gimplify_ctxp->save_stack)
     {
       gimple stack_restore;

       /* Save stack on entry and restore it on exit.  Add a try_finally
         block to achieve this.  */
       build_stack_save_restore (&stack_save, &stack_restore);

       gimplify_seq_add_stmt (&cleanup, stack_restore);
     }

   /* Add clobbers for all variables that go out of scope.  */
   ...

There is no specific location assigned to these entry/exit statements
so they eventually inherits slocs coming from preceding statements.

This is problematic for tools relying on debug info to infer
which statements were executed out of execution traces (allowing
coverage analysis without code instrumentation).

An example of problematic scenario is provided below.

The attached patch is a proposal to improve this by propagating
start and end of block locations from the block structure to the
few gimple statements we generate. It adds an "end_locus" to the
block structure for this purpose, which the Ada front-end knows
how to fill already.

I verified that it does inserts proper .loc directives before the
entry/exit code on the example. The patch also bootstraps and regtests
fine for languages=all,ada on x86_64-pc-linux-gnu.

OK to commit ?

Thanks in advance for your feedback,

With Kind Regards,

Olivier

--

2014-06-11  Olivier Hainque  <hain...@adacore.com>

        * tree-core.h (tree_block): Add an "end_locus" field, allowing
        memorization of the end of block source location.
        * tree.h (BLOCK_SOURCE_END_LOCATION): New accessor.
        * gimplify.c (gimplify_bind_expr): Propagate the block start and
        end source location info we have on the block entry/exit code we
        generate.
OK. I assume y'all will add a suitable test to the Ada testsuite and propagate it into the GCC testsuite in due course?

jeff

Reply via email to