[patch] Disable if_conversion2 for Og

Richard Earnshaw rearnsha@arm.com
Wed Apr 16 09:45:00 GMT 2014


On 15/04/14 02:59, Joey Ye wrote:
> If-converstion is harmful to optimized debugging as it generates conditional
> execution instructions with line number information, which resulted in a
> dillusion to developers that both then-else branches are executed.
> 
> For example:
> test.c:
> 1: unsigned oldest_sequence;
> 2:
> 3: unsigned foo(unsigned seq_number)
> 4: {
> 5:  if ((seq_number + 5) < 10)
> 6:    seq_number += 100;
> 7:   else
> 8:     seq_number = oldest_sequence;
> 
>   if (seq_number < oldest_sequence)
>     seq_number = oldest_sequence;
> 
>  return seq_number;
> }

Arguably, this is a bug in gdb.  The debugger should understand when a
breakpointed conditional instruction is not going to execute and
silently continue.  That preserves the illusion of not executing the
code without requiring the compiler to de-optimize things.

R.

> 
> $ arm-none-eabi-gcc -mthumb -mcpu=cortex-m3 -Og -g3
> gets:
>         .loc 1 5 0
>         adds    r3, r0, #5
>         cmp     r3, #9
>         .loc 1 6 0       <----- line 6, then branch
>         itee    ls
>         addls   r0, r0, #100
> .LVL1:
>         .loc 1 8 0       <----- line 8, else branch. Both branches seems to
> be executed in GDB
>         ldrhi   r3, .L5
>         ldrhi   r0, [r3]
> 
> The reason is that if_conversion2 is still enabled in Og. The patch simply
> disables it for Og.
> 
> Tests:
> * -Og bootstrap passed.
> * Make check default (no additional option): No regression.
> * Make check with -Og: expected regressions. Cases relying on if-conversion2
> failed.
>> FAIL: gcc.target/arm/its.c scan-assembler-times \\tit 2
>> FAIL: gcc.target/arm/pr40956.c scan-assembler-times mov[\\\\t ]*r., #0 1
>> FAIL: gcc.target/arm/thumb-ifcvt-2.c scan-assembler asreq
>> FAIL: gcc.target/arm/thumb-ifcvt-2.c scan-assembler lslne
>> FAIL: gcc.target/arm/thumb-ifcvt.c scan-assembler asrne
>> FAIL: gcc.target/arm/thumb-ifcvt.c scan-assembler lslne
> 
> OK to trunk and 4.8/4.9 branch?
> 
> ChangeLog:
>     * opts.c (OPT_fif_conversion2): Disable for Og.
> 
> diff --git a/gcc/opts.c b/gcc/opts.c
> index fdc903f..e076253 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -432,7 +432,7 @@ static const struct default_options
> default_options_table[] =
>      { OPT_LEVELS_1_PLUS, OPT_fcprop_registers, NULL, 1 },
>      { OPT_LEVELS_1_PLUS, OPT_fforward_propagate, NULL, 1 },
>      { OPT_LEVELS_1_PLUS, OPT_fif_conversion, NULL, 1 },
> -    { OPT_LEVELS_1_PLUS, OPT_fif_conversion2, NULL, 1 },
> +    { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 },
>      { OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 },
>      { OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 },
>      { OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 },
> 
> 
> 




More information about the Gcc-patches mailing list