public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma
@ 2011-02-02 16:06 hariharans at picochip dot com
  2011-02-02 16:08 ` [Bug debug/47590] " hariharans at picochip dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: hariharans at picochip dot com @ 2011-02-02 16:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

           Summary: var tracking produces wrong debug in code where
                    optimization is turned off using pragma
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hariharans@picochip.com


Created attachment 23216
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23216
The source code

In the attached testcase #pragma has been used to turn optimization off (The
file is otherwise compiled at -Os). By turning off optimization, we expected to
be able to get better debug experience. We noticed that the variable n in the
function "fn" takes the following values, if you step through the function.

4 3 0 2 1 5 0 10 -1

which is obviously wrong.

I reckon the problem lies in var-tracking. Our dwarf reader tells me that the
value of "n" could be found in the following places.

        Name: n
        Location:
        [29, 48) : DW_OP_reg1
        [48, 66) : DW_OP_reg4
        [66, 102) : DW_OP_fbreg[-6]
        [102, 112) : DW_OP_reg4

I will attach the address encoded assembly so you can see that var-tracking
gets it wrong. If i compile the whole file at -O0, the dwarf information the
dwarf gets it right.

        Name: n
        Location: DW_OP_fbreg[-6]

In this particular case, adding -fno-var-tracking has the same effect in
correcting the debug information.

I guess there are 2 things that could be done.

1. Find out the problem in var-tracking in this case and fix it.

2. Turn off var-tracking for functions where optimization is turned off using
attributes/pragmas.

Please let me know if you need any other information on this. I tried all my
experiments with master (as of 2-feb-2011). The experiments were conducted on
picochip (picochip-unknown-none target triplet).

Thanks
Hari


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
@ 2011-02-02 16:08 ` hariharans at picochip dot com
  2011-02-02 16:09 ` hariharans at picochip dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hariharans at picochip dot com @ 2011-02-02 16:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

--- Comment #1 from hariharans at picochip dot com 2011-02-02 16:07:27 UTC ---
Created attachment 23218
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23218
The assembly output from -Os compilation


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
  2011-02-02 16:08 ` [Bug debug/47590] " hariharans at picochip dot com
@ 2011-02-02 16:09 ` hariharans at picochip dot com
  2011-03-27 14:31 ` aoliva at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: hariharans at picochip dot com @ 2011-02-02 16:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

--- Comment #2 from hariharans at picochip dot com 2011-02-02 16:08:20 UTC ---
Created attachment 23219
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23219
The assembly with instruction addresses


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
  2011-02-02 16:08 ` [Bug debug/47590] " hariharans at picochip dot com
  2011-02-02 16:09 ` hariharans at picochip dot com
@ 2011-03-27 14:31 ` aoliva at gcc dot gnu.org
  2011-03-27 14:36 ` aoliva at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2011-03-27 14:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

--- Comment #3 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2011-03-27 13:01:26 UTC ---
Created attachment 23780
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23780
Patch that fixes the bug on all affected targets

The introduction of option saving and restoring broke the special handling of
flag_var_tracking on the targets that delayed it.  This patch fixes it.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
                   ` (2 preceding siblings ...)
  2011-03-27 14:31 ` aoliva at gcc dot gnu.org
@ 2011-03-27 14:36 ` aoliva at gcc dot gnu.org
  2011-06-03  1:42 ` aoliva at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2011-03-27 14:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.03.27 13:01:59
         AssignedTo|unassigned at gcc dot       |aoliva at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #4 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2011-03-27 13:01:59 UTC ---
Mine


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
                   ` (3 preceding siblings ...)
  2011-03-27 14:36 ` aoliva at gcc dot gnu.org
@ 2011-06-03  1:42 ` aoliva at gcc dot gnu.org
  2011-06-04 10:16 ` aoliva at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2011-06-03  1:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2011-06-03 01:41:57 UTC ---
Author: aoliva
Date: Fri Jun  3 01:41:54 2011
New Revision: 174595

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174595
Log:
PR debug/47590
* target.def (delay_sched2, delay_vartrack): New.
* doc/tm.texi.in: Update.
* doc/tm.texi: Rebuild.
* sched-rgn.c (gate_handle_sched2): Fail if delay_sched2.
* var-tracking.c (gate_handle_var_tracking): Likewise.
* config/bfin/bfin.c (bfin_flag_schedule_insns2): Drop.
(bfin_flag_var_tracking): Drop.
(output_file_start): Don't save and override flag_var_tracking.
(bfin_option_override): Ditto flag_schedule_insns_after_reload.
(bfin_reorg): Test original variables.
(TARGET_DELAY_SCHED2, TARGET_DELAY_VARTRACK): Define.
* config/ia64/ia64.c (ia64_flag_schedule_insns2): Drop.
(ia64_flag_var_tracking): Drop.
(TARGET_DELAY_SCHED2, TARGET_DELAY_VARTRACK): Define.
(ia64_file_start): Don't save and override flag_var_tracking.
(ia64_override_options_after_change): Ditto
flag_schedule_insns_after_reload.
(ia64_reorg): Test original variables.
* config/picochip/picochip.c (picochip_flag_schedule_insns2): Drop.
(picochip_flag_var_tracking): Drop.
(TARGET_DELAY_SCHED2, TARGET_DELAY_VARTRACK): Define.
(picochip_option_override): Don't save and override
flag_schedule_insns_after_reload.
(picochip_asm_file_start): Ditto flag_var_tracking.
(picochip_reorg): Test original variables.
* config/spu/spu.c (spu_flag_var_tracking): Drop.
(TARGET_DELAY_VARTRACK): Define.
(spu_var_tracking): New.
(spu_machine_dependent_reorg): Call it.
(asm_file_start): Don't save and override flag_var_tracking.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/bfin/bfin.c
    trunk/gcc/config/ia64/ia64.c
    trunk/gcc/config/picochip/picochip.c
    trunk/gcc/config/spu/spu.c
    trunk/gcc/doc/tm.texi
    trunk/gcc/doc/tm.texi.in
    trunk/gcc/sched-rgn.c
    trunk/gcc/target.def
    trunk/gcc/var-tracking.c


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
                   ` (4 preceding siblings ...)
  2011-06-03  1:42 ` aoliva at gcc dot gnu.org
@ 2011-06-04 10:16 ` aoliva at gcc dot gnu.org
  2011-06-04 10:22 ` aoliva at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2011-06-04 10:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

--- Comment #6 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2011-06-04 10:15:51 UTC ---
Author: aoliva
Date: Sat Jun  4 10:15:48 2011
New Revision: 174637

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174637
Log:
PR debug/47590
* target.def (delay_sched2, delay_vartrack): New.
* doc/tm.texi.in: Update.
* doc/tm.texi: Rebuild.
* sched-rgn.c (gate_handle_sched2): Fail if delay_sched2.
* var-tracking.c (gate_handle_var_tracking): Likewise.
* config/bfin/bfin.c (bfin_flag_schedule_insns2): Drop.
(bfin_flag_var_tracking): Drop.
(output_file_start): Don't save and override flag_var_tracking.
(bfin_option_override): Ditto flag_schedule_insns_after_reload.
(bfin_reorg): Test original variables.
(TARGET_DELAY_SCHED2, TARGET_DELAY_VARTRACK): Define.
* config/ia64/ia64.c (ia64_flag_schedule_insns2): Drop.
(ia64_flag_var_tracking): Drop.
(TARGET_DELAY_SCHED2, TARGET_DELAY_VARTRACK): Define.
(ia64_file_start): Don't save and override flag_var_tracking.
(ia64_override_options_after_change): Ditto
flag_schedule_insns_after_reload.
(ia64_reorg): Test original variables.
* config/picochip/picochip.c (picochip_flag_schedule_insns2): Drop.
(picochip_flag_var_tracking): Drop.
(TARGET_DELAY_SCHED2, TARGET_DELAY_VARTRACK): Define.
(picochip_option_override): Don't save and override
flag_schedule_insns_after_reload.
(picochip_asm_file_start): Ditto flag_var_tracking.
(picochip_reorg): Test original variables.
* config/spu/spu.c (spu_flag_var_tracking): Drop.
(TARGET_DELAY_VARTRACK): Define.
(spu_var_tracking): New.
(spu_machine_dependent_reorg): Call it.
(asm_file_start): Don't save and override flag_var_tracking.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/bfin/bfin.c
    branches/gcc-4_6-branch/gcc/config/ia64/ia64.c
    branches/gcc-4_6-branch/gcc/config/picochip/picochip.c
    branches/gcc-4_6-branch/gcc/config/spu/spu.c
    branches/gcc-4_6-branch/gcc/doc/tm.texi
    branches/gcc-4_6-branch/gcc/doc/tm.texi.in
    branches/gcc-4_6-branch/gcc/sched-rgn.c
    branches/gcc-4_6-branch/gcc/target.def
    branches/gcc-4_6-branch/gcc/var-tracking.c


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
                   ` (5 preceding siblings ...)
  2011-06-04 10:16 ` aoliva at gcc dot gnu.org
@ 2011-06-04 10:22 ` aoliva at gcc dot gnu.org
  2011-11-10 16:40 ` hariharans at picochip dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2011-06-04 10:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2011-06-04 10:21:35 UTC ---
Fixed


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] var tracking produces wrong debug in code where optimization is turned off using pragma
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
                   ` (6 preceding siblings ...)
  2011-06-04 10:22 ` aoliva at gcc dot gnu.org
@ 2011-11-10 16:40 ` hariharans at picochip dot com
  2012-03-25 11:56 ` [Bug debug/47590] pragma optimize doesn't recompute derived options (was: var tracking produces wrong debug in code where optimization is turned off using pragma) aoliva at gcc dot gnu.org
  2022-01-01  7:44 ` [Bug middle-end/47590] " pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: hariharans at picochip dot com @ 2011-11-10 16:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

hariharans at picochip dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
         Resolution|FIXED                       |

--- Comment #8 from hariharans at picochip dot com 2011-11-10 16:20:27 UTC ---
Hi Alexandre,
I just tried the same test on 4.6.2 compiler and 4.7.0 mainline. It fails in
exactly the same way as before. Can you test if the problem mentioned in this
has been fixed?

Thanks
Hari


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/47590] pragma optimize doesn't recompute derived options (was: var tracking produces wrong debug in code where optimization is turned off using pragma)
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
                   ` (7 preceding siblings ...)
  2011-11-10 16:40 ` hariharans at picochip dot com
@ 2012-03-25 11:56 ` aoliva at gcc dot gnu.org
  2022-01-01  7:44 ` [Bug middle-end/47590] " pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2012-03-25 11:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|aoliva at gcc dot gnu.org   |unassigned at gcc dot
                   |                            |gnu.org
            Summary|var tracking produces wrong |pragma optimize doesn't
                   |debug in code where         |recompute derived options
                   |optimization is turned off  |(was: var tracking produces
                   |using pragma                |wrong debug in code where
                   |                            |optimization is turned off
                   |                            |using pragma)

--- Comment #9 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2012-03-25 11:22:19 UTC ---
Sorry, closing e bug was a mistake. The only thing I fixed was the ability to
override -fvar-tracking with #pragma optimize, so that the change is taken into
acount on all targets.  We don't seem to have infrastructure to recompute flags
whose defaults are implied from others after #pragma optimize, and I haven't
even tried to implement that.  I just made sure that, if that is ever
implemented, the recomputed values will be used on all targets.  Meanwhile, add
“, "-fno-var-tracking", "-fno-var-tracking-assignments"” to the #pragma line,
and you'll get the intended behavior.

Incidentally, the inability to recompute implied flags, check inconsistencies,
etc, requires both options to be provided, and if any function compiled with
VTA enabled is inlined into one with these overriders, gcc will crash because
the VTA note will survive all the way to final.  There is code that forces
flag_var_tracking into a special clean-up mode when VTA is enabled when
var-tracking isn't, but that code doesn't get a chance to run after #pragma
optimize.

I'm unassigning this bug, in the hope that someone can take over from here.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug middle-end/47590] pragma optimize doesn't recompute derived options (was: var tracking produces wrong debug in code where optimization is turned off using pragma)
  2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
                   ` (8 preceding siblings ...)
  2012-03-25 11:56 ` [Bug debug/47590] pragma optimize doesn't recompute derived options (was: var tracking produces wrong debug in code where optimization is turned off using pragma) aoliva at gcc dot gnu.org
@ 2022-01-01  7:44 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-01  7:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47590

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-debug
          Component|debug                       |middle-end

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I wonder if this has been fixed since there has been so many fixes for #prama
optimize even in GCC 4.8.0.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-01-01  7:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-02 16:06 [Bug debug/47590] New: var tracking produces wrong debug in code where optimization is turned off using pragma hariharans at picochip dot com
2011-02-02 16:08 ` [Bug debug/47590] " hariharans at picochip dot com
2011-02-02 16:09 ` hariharans at picochip dot com
2011-03-27 14:31 ` aoliva at gcc dot gnu.org
2011-03-27 14:36 ` aoliva at gcc dot gnu.org
2011-06-03  1:42 ` aoliva at gcc dot gnu.org
2011-06-04 10:16 ` aoliva at gcc dot gnu.org
2011-06-04 10:22 ` aoliva at gcc dot gnu.org
2011-11-10 16:40 ` hariharans at picochip dot com
2012-03-25 11:56 ` [Bug debug/47590] pragma optimize doesn't recompute derived options (was: var tracking produces wrong debug in code where optimization is turned off using pragma) aoliva at gcc dot gnu.org
2022-01-01  7:44 ` [Bug middle-end/47590] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).