public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/95047] New: Wrong debug information for ternary operator at O0
@ 2020-05-11 7:20 massarelli at diag dot uniroma1.it
2020-05-11 7:31 ` [Bug debug/95047] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: massarelli at diag dot uniroma1.it @ 2020-05-11 7:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95047
Bug ID: 95047
Summary: Wrong debug information for ternary operator at O0
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: massarelli at diag dot uniroma1.it
Target Milestone: ---
Debug information for ternary operator seems wrong at O0.
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/tmp/gcc_build --disable-multilib
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200508 (experimental) (GCC)
$ lldb -v
lldb version 11.0.0
clang revision 23cbea9a04e023d5b79dfee5964fae769340c993
llvm revision 23cbea9a04e023d5b79dfee5964fae769340c993
$ cat a.c
short a;
short
b( left, right )
{
return
((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left >
((32767) >> ((int)right)))) ?
0 :
left
;
}
int main ()
{
a = b(4294967286 , 5);
}
$ gcc -O0 -g a.c
$ lldb a.out
* thread #1, name = 'a.out', stop reason = breakpoint 2.1
frame #0: 0x00000000004004c1 unopt`main at a.c:13:9
10 }
11 int main ()
12 {
-> 13 a = b(4294967286 , 5);
14 }
(lldb) s
Process 78 stopped
* thread #1, name = 'a.out', stop reason = step in
frame #0: 0x000000000040048c unopt`b(left=-10, right=5) at a.c:7:7
4 {
5 return
6 ((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left
> ((32767) >> ((int)right)))) ?
-> 7 0 :
8 left
9 ;
10 }
(lldb) s
Process 78 stopped
* thread #1, name = 'a.out', stop reason = step in
frame #0: 0x00000000004004bb unopt`b(left=-10, right=5) at a.c:10:1
7 0 :
8 left
9 ;
-> 10 }
11 int main ()
12 {
13 a = b(4294967286 , 5);
(lldb) s
Process 78 stopped
* thread #1, name = 'a.out', stop reason = step in
frame #0: 0x00000000004004d5 unopt`main at a.c:13:7
10 }
11 int main ()
12 {
-> 13 a = b(4294967286 , 5);
14 }
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug debug/95047] Wrong debug information for ternary operator at O0
2020-05-11 7:20 [Bug debug/95047] New: Wrong debug information for ternary operator at O0 massarelli at diag dot uniroma1.it
@ 2020-05-11 7:31 ` pinskia at gcc dot gnu.org
2020-05-11 7:42 ` massarelli at diag dot uniroma1.it
2020-05-11 8:26 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-05-11 7:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95047
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC puts the line information as the line/collumn as the ':' part of the
ternary
opertator.
<bb 2> :
[t666.c:7:7] if (left_3(D) >= 0)
goto <bb 3>; [INV]
else
goto <bb 7>; [INV]
<bb 3> :
[t666.c:6:17] if (right_4(D) >= 0)
goto <bb 4>; [INV]
else
goto <bb 7>; [INV]
<bb 4> :
[t666.c:6:39] if (right_4(D) <= 31)
goto <bb 5>; [INV]
else
goto <bb 7>; [INV]
<bb 5> :
[t666.c:6:83] _1 = 32767 >> right_4(D);
[t666.c:6:63] if (left_3(D) <= _1)
goto <bb 6>; [INV]
else
goto <bb 7>; [INV]
<bb 6> :
[t666.c:7:7] iftmp.0_5 = (short int) left_3(D);
[t666.c:7:7] goto <bb 8>; [INV]
<bb 7> :
[t666.c:7:7] iftmp.0_6 = 0;
<bb 8> :
# iftmp.0_2 = PHI <[t666.c:7:7] iftmp.0_5(6), [t666.c:7:7] iftmp.0_6(7)>
[t666.c:7:7] _7 = iftmp.0_2;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug debug/95047] Wrong debug information for ternary operator at O0
2020-05-11 7:20 [Bug debug/95047] New: Wrong debug information for ternary operator at O0 massarelli at diag dot uniroma1.it
2020-05-11 7:31 ` [Bug debug/95047] " pinskia at gcc dot gnu.org
@ 2020-05-11 7:42 ` massarelli at diag dot uniroma1.it
2020-05-11 8:26 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: massarelli at diag dot uniroma1.it @ 2020-05-11 7:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95047
--- Comment #2 from Luca Massarelli <massarelli at diag dot uniroma1.it> ---
Ok, so it seems that there is an inconsistency with -Og:
$ gcc -Og -g -o opt a.c
$ lldb opt
* thread #1, name = 'opt', stop reason = breakpoint 1.1
frame #0: 0x00000000004004bb opt`main at a.c:13:9
10 }
11 int main ()
12 {
-> 13 a = b(4294967286 , 5);
14 }
(lldb) s
Process 101 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400482 opt`b(left=-10, right=5) at a.c:6:12
3 b( left, right )
4 {
5 return
-> 6 ((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left
> ((32767) >> ((int)right)))) ?
7 0 :
8 left
9 ;
(lldb) s
Process 101 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x0000000000400490 opt`b(left=-10, right=5) at a.c:7:7
4 {
5 return
6 ((left < 0) || (((int)right) < 0) || (((int)right) >= 32) || (left
> ((32767) >> ((int)right)))) ?
-> 7 0 :
8 left
9 ;
10 }
(lldb) s
Process 101 stopped
* thread #1, name = 'opt', stop reason = step in
frame #0: 0x00000000004004cf opt`main at a.c:13:7
10 }
11 int main ()
12 {
-> 13 a = b(4294967286 , 5);
14 }
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug debug/95047] Wrong debug information for ternary operator at O0
2020-05-11 7:20 [Bug debug/95047] New: Wrong debug information for ternary operator at O0 massarelli at diag dot uniroma1.it
2020-05-11 7:31 ` [Bug debug/95047] " pinskia at gcc dot gnu.org
2020-05-11 7:42 ` massarelli at diag dot uniroma1.it
@ 2020-05-11 8:26 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-05-11 8:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95047
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
That is because when GCC does for -Og:
[t666.c:6:12] _1 = left_6(D) >= 0;
[t666.c:6:34] _2 = right_7(D) >= 0;
[t666.c:6:17] _3 = _1 & _2;
[t666.c:7:7] if (_3 != 0)
This "optimization" happens at early on. I have not looked into why the line
numbers are different.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-11 8:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 7:20 [Bug debug/95047] New: Wrong debug information for ternary operator at O0 massarelli at diag dot uniroma1.it
2020-05-11 7:31 ` [Bug debug/95047] " pinskia at gcc dot gnu.org
2020-05-11 7:42 ` massarelli at diag dot uniroma1.it
2020-05-11 8:26 ` 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).