public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0
@ 2012-08-10 8:37 senthil_kumar.selvaraj at atmel dot com
2012-08-10 8:54 ` [Bug middle-end/54218] " rguenth at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: senthil_kumar.selvaraj at atmel dot com @ 2012-08-10 8:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54218
Bug #: 54218
Summary: Debug info for function parameters is incorrect when
compiled with -O0
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: senthil_kumar.selvaraj@atmel.com
Created attachment 27980
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27980
Failing dejagnu test case
When compiling a function, like below, with no optimizations (-O0), on a x86_64
target (also occurs for atleast one other target (avr))
void func(int p)
{
p = 0;
p = 32;
}
wrong debug information is emitted for the function parameter (p), that cause
the debugger to keep showing the value of the actual argument, even after p is
overwritten. A failing dejagnu test is attached.
Based on a preliminary analysis, the actual problem seems to be that stack
space for a function parameter (that is not used??) is allocated twice when
gimple_expand_cfg runs - once when expand_used_vars runs, and later when
assign_parm_setup_stack runs. expand_used_vars allocates stack space despite
the check for a default definition being present in the partition, because the
function parameter node (which I guess should be the default definition) is not
present when iterating over num_ssa_names.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/54218] Debug info for function parameters is incorrect when compiled with -O0
2012-08-10 8:37 [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0 senthil_kumar.selvaraj at atmel dot com
@ 2012-08-10 8:54 ` rguenth at gcc dot gnu.org
2012-08-10 10:24 ` senthil_kumar.selvaraj at atmel dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-08-10 8:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54218
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-debug
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-08-10
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-08-10 08:53:46 UTC ---
That's because the actual parameter value is not used:
func (int p)
{
;; basic block 2, loop depth 0
;; pred: ENTRY
p_1 = 0;
p_2 = 32;
return;
Partition 0 (p_1 - 1 2 )
Does -fvar-tracking "fix" it?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/54218] Debug info for function parameters is incorrect when compiled with -O0
2012-08-10 8:37 [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0 senthil_kumar.selvaraj at atmel dot com
2012-08-10 8:54 ` [Bug middle-end/54218] " rguenth at gcc dot gnu.org
@ 2012-08-10 10:24 ` senthil_kumar.selvaraj at atmel dot com
2012-08-10 10:25 ` senthil_kumar.selvaraj at atmel dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: senthil_kumar.selvaraj at atmel dot com @ 2012-08-10 10:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54218
--- Comment #2 from Senthil Kumar Selvaraj <senthil_kumar.selvaraj at atmel dot com> 2012-08-10 10:23:55 UTC ---
Comment on attachment 27980
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27980
Failing dejagnu test case
>/* { dg-do run } */
>/* { dg-options "-g" } */
>/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
>
>void func(int p)
>{
> p = 0; /* { dg-final { gdb-test 8 "p" "0" } } */
> p = 32;/* { dg-final { gdb-test 8 "p" "42" } } */
>}
>
>int
>main (void)
>{
> int local = 42;
> func(local);
>}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/54218] Debug info for function parameters is incorrect when compiled with -O0
2012-08-10 8:37 [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0 senthil_kumar.selvaraj at atmel dot com
2012-08-10 8:54 ` [Bug middle-end/54218] " rguenth at gcc dot gnu.org
2012-08-10 10:24 ` senthil_kumar.selvaraj at atmel dot com
@ 2012-08-10 10:25 ` senthil_kumar.selvaraj at atmel dot com
2012-08-10 10:39 ` senthil_kumar.selvaraj at atmel dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: senthil_kumar.selvaraj at atmel dot com @ 2012-08-10 10:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54218
Senthil Kumar Selvaraj <senthil_kumar.selvaraj at atmel dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #27980|0 |1
is obsolete| |
--- Comment #3 from Senthil Kumar Selvaraj <senthil_kumar.selvaraj at atmel dot com> 2012-08-10 10:25:03 UTC ---
Created attachment 27981
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27981
Failing dejagnu test case (right line number)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/54218] Debug info for function parameters is incorrect when compiled with -O0
2012-08-10 8:37 [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0 senthil_kumar.selvaraj at atmel dot com
` (2 preceding siblings ...)
2012-08-10 10:25 ` senthil_kumar.selvaraj at atmel dot com
@ 2012-08-10 10:39 ` senthil_kumar.selvaraj at atmel dot com
2013-01-07 12:04 ` george.thomas at atmel dot com
2013-01-07 12:06 ` george.thomas at atmel dot com
5 siblings, 0 replies; 7+ messages in thread
From: senthil_kumar.selvaraj at atmel dot com @ 2012-08-10 10:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54218
--- Comment #4 from Senthil Kumar Selvaraj <senthil_kumar.selvaraj at atmel dot com> 2012-08-10 10:39:32 UTC ---
(In reply to comment #1)
> That's because the actual parameter value is not used:
>
> func (int p)
> {
> ;; basic block 2, loop depth 0
> ;; pred: ENTRY
> p_1 = 0;
> p_2 = 32;
> return;
>
> Partition 0 (p_1 - 1 2 )
>
>
> Does -fvar-tracking "fix" it?
Yes, it does. Doesn't change the code generated though - the initial copy is
still at a different frame offset.
(In reply to comment #1)
> That's because the actual parameter value is not used:
>
> func (int p)
> {
> ;; basic block 2, loop depth 0
> ;; pred: ENTRY
> p_1 = 0;
> p_2 = 32;
> return;
>
> Partition 0 (p_1 - 1 2 )
>
>
> Does -fvar-tracking "fix" it?
(In reply to comment #1)
> That's because the actual parameter value is not used:
>
> func (int p)
> {
> ;; basic block 2, loop depth 0
> ;; pred: ENTRY
> p_1 = 0;
> p_2 = 32;
> return;
>
> Partition 0 (p_1 - 1 2 )
>
>
> Does -fvar-tracking "fix" it?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/54218] Debug info for function parameters is incorrect when compiled with -O0
2012-08-10 8:37 [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0 senthil_kumar.selvaraj at atmel dot com
` (3 preceding siblings ...)
2012-08-10 10:39 ` senthil_kumar.selvaraj at atmel dot com
@ 2013-01-07 12:04 ` george.thomas at atmel dot com
2013-01-07 12:06 ` george.thomas at atmel dot com
5 siblings, 0 replies; 7+ messages in thread
From: george.thomas at atmel dot com @ 2013-01-07 12:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54218
--- Comment #5 from George Thomas <george.thomas at atmel dot com> 2013-01-07 12:04:22 UTC ---
Created attachment 29095
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29095
Draft Patch for the fix of 54218
The issue is happening because stack space is allocated twice
1. assign_params_setup_stack and
2. expand_used_vars
The proposed fix is to allocate the space only once in assign_params_stack
by explicitly checking in expand_used_vars if the tree node is of type
PARM_DECL.
if its PARM_DECL, it would mean that it would already have been expanded and
hence do not require further expansion.
This fixes the issue and allows debugging to work properly.
I would like to know if it would be an acceptable change.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/54218] Debug info for function parameters is incorrect when compiled with -O0
2012-08-10 8:37 [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0 senthil_kumar.selvaraj at atmel dot com
` (4 preceding siblings ...)
2013-01-07 12:04 ` george.thomas at atmel dot com
@ 2013-01-07 12:06 ` george.thomas at atmel dot com
5 siblings, 0 replies; 7+ messages in thread
From: george.thomas at atmel dot com @ 2013-01-07 12:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54218
George Thomas <george.thomas at atmel dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |george.thomas at atmel dot
| |com
--- Comment #6 from George Thomas <george.thomas at atmel dot com> 2013-01-07 12:06:01 UTC ---
Another alternative thought of for the fix was to,
Make the Parameters to be the default def of the next use. In this case,
the condition mentioned above will not expand the variable.
if (!bitmap_bit_p (SA.partition_has_default_def, i))
{
expand_one_var (var, true, true);
gcc_assert (SA.partition_to_pseudo[i]);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-01-07 12:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-10 8:37 [Bug middle-end/54218] New: Debug info for function parameters is incorrect when compiled with -O0 senthil_kumar.selvaraj at atmel dot com
2012-08-10 8:54 ` [Bug middle-end/54218] " rguenth at gcc dot gnu.org
2012-08-10 10:24 ` senthil_kumar.selvaraj at atmel dot com
2012-08-10 10:25 ` senthil_kumar.selvaraj at atmel dot com
2012-08-10 10:39 ` senthil_kumar.selvaraj at atmel dot com
2013-01-07 12:04 ` george.thomas at atmel dot com
2013-01-07 12:06 ` george.thomas at atmel dot com
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).