PATCH: Improve debuggability at -O0 and fix PR 29609

Richard Guenther
Mon Sep 3 09:39:00 GMT 2007

On 9/3/07, Tristan Gingold <> wrote:
> Hi,
> this patch improve debuggability at -O0 and fixes PR 29609.
> For break/continue/goto statements directly inside an if statement the
> code generated is too optimized since tree-ssa.  On x86:
>      if (!f3())
>          goto failure; /* Line 23 */
> is translated to:
>          call    f3
>          testl   %eax, %eax
>          je      .L6
> and therefore there is no possible breakpoint at line 23 which is a mess
> at -O0.
> This patch first add a new flag to GOTO_EXPR: GOTO_EXPLICIT_P
> (field static_flag) so that gotos coming explicitely from user code
> can be
> tracked.  During gimple lower pass and only at -O0 the explicit gotos
> are
> not merged with the conditionnal jump created by an if statement.
> This is just enough to generate correct code but not yet enough to
> have to
> correct debug line opcode generated.  The jump insn may be removed by
> the
> into_cfglayout pass.  To avoid this issue a new flag is added to edge
> flags:
> EDGE_EXPLICIT (only at -O0).  When this flag is set cfgrtl doesn't
> remove
> the jump and cfgcleanup does not try to remove this forwarding edge.
> Now the code generated at -O0 -g is:
>          .loc 1 22 0
>          call    f3
>          testl   %eax, %eax
>          jne     .L6
>          .loc 1 23 0
>          jmp     .L7

I don't like this approach.  From a quick check I see that gimple
lowering retains
location information for both the if and the then branch correctly in
and the CFG created has the correct locus set on the edge already.  So where
is this information lost?  I suppose it may be during expand where we call
do_jump via jumpif but the complete jump sequence has one location.  So the
proper fix would probably to teach do_jump to take an alternate location for the


More information about the Gcc-patches mailing list