Discussion:
[Bug debug/63623] New: Lots of functions get -fvar-tracking silently turned off unnecessarily
jakub at gcc dot gnu.org
2014-10-23 06:58:33 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63623

Bug ID: 63623
Summary: Lots of functions get -fvar-tracking silently turned
off unnecessarily
Product: gcc
Version: 4.8.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org

I have got a report that when glibc is compiled with gcc 4.8.x, the debug info
for the bytes parameter to __libc_malloc is wrong in the prologue (and
epilogue).

Here is a reduced testcase for x86_64-linux:
-std=gnu99 -fgnu89-inline -O2 -fmerge-all-constants -frounding-math -g -dA
-fPIC:

void *a;
extern void *(*d) (__SIZE_TYPE__, const void *);
void *foo (void *, __SIZE_TYPE__);
void *bar (void *, __SIZE_TYPE__);

void *
__libc_malloc (__SIZE_TYPE__ bytes)
{
void *b, *c;
if (__builtin_expect (d != 0, 0))
return d (bytes, 0);
b = a;
if (!b)
return 0;
c = foo (b, bytes);
if (!c)
b = bar (b, bytes);
return b;
}

r203167 on the trunk "fixed" this by slightly changing the CFG (because of the
__builtin_expect), so the bug went latent on this testcase.

I've investigated this and found that this is because the function doesn't have
frame pointer and vt_stack_adjustments failed on the function, which precludes
not just -fvar-tracking-assignments, but also -fvar-tracking altogether.
And the reason for that is that it doesn't handle i?86/x86_64 pop instructions,
like:
(insn/f:TI 76 81 77 8 (set (reg:DI 3 bx)
(mem:DI (post_inc:DI (reg/f:DI 7 sp)) [0 S8 A8])) rh1151226.i:19 75
{*popdi1}
(expr_list:REG_CFA_ADJUST_CFA (set (reg/f:DI 7 sp)
(plus:DI (reg/f:DI 7 sp)
(const_int 8 [0x8])))
(nil)))
where it doesn't account for any stack adjustment in such functions. Thus,
stack_adjust values may be either wrong in the VTA info, leading to wrong
debug, or, if because of that there is some disagreement on the edges between
what the stack_adjust value should be, it gives up on -fvar-tracking
altogether.
jakub at gcc dot gnu.org
2014-10-23 07:00:59 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63623

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-10-23
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Ever confirmed|0 |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 33789
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33789&action=edit
gcc5-pr63623.patch

Patch (successfully tested).
jakub at gcc dot gnu.org
2014-10-23 07:11:57 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63623

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
dwlocstat --tabulate=0.0:10,99
results on cc1plus bootstrapped --enable-checking=yes,rtl binaries before/after
the patch (in the tree without the patch I've applied the patch afterwards and
did make cc1plus in the gcc directory, so var-tracking.o in stage3 got rebuilt
again and thus the compared binaries contain exactly the same code, just
different debug info):

x86_64-linux cc1plus built without the patch:
cov% samples cumul
0.0 506230/38% 506230/38%
0..10 10327/0% 516557/39%
11..20 12390/0% 528947/39%
21..30 31265/2% 560212/42%
31..40 18775/1% 578987/43%
41..50 20631/1% 599618/45%
51..60 24921/1% 624539/47%
61..70 40959/3% 665498/50%
71..80 23771/1% 689269/52%
81..90 41771/3% 731040/55%
91..99 81667/6% 812707/61%
100 510564/38% 1323271/100%

x86_64-linux cc1plus built with the patch:
cov% samples cumul
0.0 382214/28% 382214/28%
0..10 13100/0% 395314/29%
11..20 14568/1% 409882/30%
21..30 33708/2% 443590/33%
31..40 21927/1% 465517/35%
41..50 23924/1% 489441/36%
51..60 28736/2% 518177/39%
61..70 45847/3% 564024/42%
71..80 29284/2% 593308/44%
81..90 52085/3% 645393/48%
91..99 99971/7% 745364/56%
100 577907/43% 1323271/100%

i686-linux cc1plus built without the patch:
cov% samples cumul
0.0 631348/48% 631348/48%
0..10 7764/0% 639112/48%
11..20 9690/0% 648802/49%
21..30 25036/1% 673838/51%
31..40 16113/1% 689951/52%
41..50 19753/1% 709704/54%
51..60 14563/1% 724267/55%
61..70 34093/2% 758360/58%
71..80 17450/1% 775810/59%
81..90 31339/2% 807149/61%
91..99 60368/4% 867517/66%
100 437548/33% 1305065/100%

i686-linux cc1plus built with the patch:
cov% samples cumul
0.0 377352/28% 377352/28%
0..10 16077/1% 393429/30%
11..20 15390/1% 408819/31%
21..30 31790/2% 440609/33%
31..40 23889/1% 464498/35%
41..50 29267/2% 493765/37%
51..60 22902/1% 516667/39%
61..70 45629/3% 562296/43%
71..80 29511/2% 591807/45%
81..90 50536/3% 642343/49%
91..99 93584/7% 735927/56%
100 569138/43% 1305065/100%

.debug_info/.debug_loc sizes in bytes:
x86_64-linux cc1plus without patch .debug_info 75411710, .debug_loc 75421077
x86_64-linux cc1plus with patch .debug_info 78498790, .debug_loc 90530117
i686-linux cc1plus without patch .debug_info 59921183, .debug_loc 37823166
i686-linux cc1plus with patch .debug_info 63009554, .debug_loc 59535100
jakub at gcc dot gnu.org
2014-10-23 21:59:13 UTC
Permalink
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63623

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Thu Oct 23 21:58:41 2014
New Revision: 216600

URL: https://gcc.gnu.org/viewcvs?rev=216600&root=gcc&view=rev
Log:
PR debug/63623
* var-tracking.c (stack_adjust_offset_pre_post_cb): New function.
(stack_adjust_offset_pre_post): Use it through for_each_inc_dec,
instead of only handling autoinc in dest if it is a MEM.
(vt_stack_adjustments): Fix up formatting.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/var-tracking.c

Loading...