]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bypass gcc code generation bug triggered by -finline-functions
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 16 Nov 2017 21:53:46 +0000 (22:53 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 16 Nov 2017 21:53:46 +0000 (22:53 +0100)
commit 7dd9a7f8b3118c25014b0a77aff899e517c46bcd has added the flag -finline-functions.

This triggers a code generation bug in gcc 6.3.0
(at least with gcc version 6.3.0 20170516 (Debian 6.3.0-18)).
(this bug can be reproduced e.g. on gcc67, which is a debian 9.2 system)

The bad code causes the debug trace to be indented by more than 500 characters,
giving e.g. for the first debug line produced by stage 2:
--12305:1:launcher launching /home/philippe/valgrind/git/smallthing/./.in_place/memcheck-amd64-linux
--12305:1:debuglog                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  DebugLog system started by Stage 2 (main), level 1 logging requested

This commit bypasses the code generation bug, by moving the indent calculation
just before its usage.

Note: on amd64/x86, the code size of memcheck tool increases by about 12%
with -finline-functions.
In terms of perf impact (using perf/vg_perf) this gives mixed results :
   memcheck is usually slightly faster, but some tests are slower (e.g. heap_pdb4)
   callgrind is usually slower, but some tests are faster
   helgrind : some tests are slowed down, some tests are faster (some significantly faster such as sarp and ffbench).

See below 2 runs of comparing trunk (with -finline-functions) with fixes
(which does not have -finline-functions).

-- Running  tests in perf ----------------------------------------------
-- bigcode1 --
bigcode1 trunk_untouched:0.07s  me: 2.2s (32.0x, -----)  he: 1.7s (23.9x, -----)  ca: 9.0s (129.0x, -----)
bigcode1 fixes     :0.07s  me: 2.3s (32.3x, -0.9%)  he: 1.7s (23.9x,  0.0%)  ca: 8.8s (125.4x,  2.8%)
-- bigcode2 --
bigcode2 trunk_untouched:0.07s  me: 5.0s (72.1x, -----)  he: 3.2s (46.0x, -----)  ca:18.6s (266.4x, -----)
bigcode2 fixes     :0.07s  me: 5.1s (73.0x, -1.2%)  he: 3.2s (46.1x, -0.3%)  ca:18.4s (262.9x,  1.3%)
-- bz2 --
bz2      trunk_untouched:0.43s  me: 4.5s (10.4x, -----)  he: 6.7s (15.5x, -----)  ca:10.4s (24.2x, -----)
bz2      fixes     :0.43s  me: 4.5s (10.5x, -0.4%)  he: 6.7s (15.5x,  0.0%)  ca:10.1s (23.4x,  3.4%)
-- fbench --
fbench   trunk_untouched:0.14s  me: 2.7s (19.6x, -----)  he: 1.9s (13.4x, -----)  ca: 4.0s (28.3x, -----)
fbench   fixes     :0.14s  me: 2.8s (19.9x, -1.8%)  he: 2.0s (14.6x, -8.5%)  ca: 3.9s (28.1x,  0.8%)
-- ffbench --
ffbench  trunk_untouched:0.15s  me: 2.6s (17.1x, -----)  he: 3.4s (22.4x, -----)  ca: 1.5s (10.1x, -----)
ffbench  fixes     :0.15s  me: 2.6s (17.3x, -0.8%)  he: 3.1s (20.9x,  6.8%)  ca: 1.5s (10.0x,  1.3%)
-- heap --
heap     trunk_untouched:0.05s  me: 3.6s (72.8x, -----)  he: 5.0s (100.0x, -----)  ca: 4.9s (98.2x, -----)
heap     fixes     :0.05s  me: 3.7s (73.6x, -1.1%)  he: 5.1s (102.4x, -2.4%)  ca: 4.8s (95.6x,  2.6%)
-- heap_pdb4 --
heap_pdb4 trunk_untouched:0.06s  me: 5.9s (97.7x, -----)  he: 5.6s (93.7x, -----)  ca: 5.2s (86.8x, -----)
heap_pdb4 fixes     :0.06s  me: 5.8s (96.0x,  1.7%)  he: 5.7s (95.3x, -1.8%)  ca: 5.3s (87.7x, -1.0%)
-- many-loss-records --
many-loss-records trunk_untouched:0.01s  me: 1.0s (101.0x, -----)  he: 0.8s (85.0x, -----)  ca: 0.8s (78.0x, -----)
many-loss-records fixes     :0.01s  me: 1.0s (100.0x,  1.0%)  he: 0.9s (86.0x, -1.2%)  ca: 0.8s (78.0x,  0.0%)
-- many-xpts --
many-xpts trunk_untouched:0.03s  me: 1.1s (38.3x, -----)  he: 1.4s (46.0x, -----)  ca: 1.9s (62.7x, -----)
many-xpts fixes     :0.03s  me: 1.1s (37.0x,  3.5%)  he: 1.4s (47.0x, -2.2%)  ca: 1.8s (61.3x,  2.1%)
-- memrw --
memrw    trunk_untouched:0.04s  me: 0.9s (21.5x, -----)  he: 2.3s (58.0x, -----)  ca: 1.9s (46.8x, -----)
memrw    fixes     :0.04s  me: 0.9s (22.0x, -2.3%)  he: 2.3s (58.0x,  0.0%)  ca: 1.9s (47.2x, -1.1%)
-- sarp --
sarp     trunk_untouched:0.02s  me: 1.5s (77.0x, -----)  he: 3.4s (168.5x, -----)  ca: 1.3s (63.0x, -----)
sarp     fixes     :0.02s  me: 1.6s (80.0x, -3.9%)  he: 4.0s (200.5x,-19.0%)  ca: 1.3s (65.5x, -4.0%)
-- tinycc --
tinycc   trunk_untouched:0.10s  me: 6.7s (66.7x, -----)  he: 6.6s (65.9x, -----)  ca: 7.2s (72.4x, -----)
tinycc   fixes     :0.10s  me: 6.6s (66.0x,  1.0%)  he: 6.8s (68.0x, -3.2%)  ca: 7.2s (72.1x,  0.4%)
-- Finished tests in perf ----------------------------------------------

== 12 programs, 72 timings =================

-- Running  tests in perf ----------------------------------------------
-- bigcode1 --
bigcode1 trunk_untouched:0.07s  me: 2.2s (32.0x, -----)  he: 1.7s (23.7x, -----)  ca: 9.0s (129.1x, -----)
bigcode1 fixes     :0.07s  me: 2.3s (32.3x, -0.9%)  he: 1.7s (23.9x, -0.6%)  ca: 8.8s (125.3x,  3.0%)
-- bigcode2 --
bigcode2 trunk_untouched:0.07s  me: 5.0s (72.1x, -----)  he: 3.2s (46.0x, -----)  ca:18.7s (266.6x, -----)
bigcode2 fixes     :0.07s  me: 5.1s (72.9x, -1.0%)  he: 3.2s (46.0x,  0.0%)  ca:18.5s (263.7x,  1.1%)
-- bz2 --
bz2      trunk_untouched:0.43s  me: 4.5s (10.5x, -----)  he: 6.7s (15.5x, -----)  ca:10.4s (24.2x, -----)
bz2      fixes     :0.43s  me: 4.5s (10.5x, -0.2%)  he: 6.7s (15.5x, -0.2%)  ca:10.1s (23.4x,  3.3%)
-- fbench --
fbench   trunk_untouched:0.14s  me: 2.8s (19.6x, -----)  he: 1.9s (13.4x, -----)  ca: 4.0s (28.2x, -----)
fbench   fixes     :0.14s  me: 2.8s (19.9x, -1.1%)  he: 2.0s (14.6x, -8.5%)  ca: 3.9s (28.1x,  0.3%)
-- ffbench --
ffbench  trunk_untouched:0.15s  me: 2.6s (17.1x, -----)  he: 3.4s (22.5x, -----)  ca: 1.5s (10.1x, -----)
ffbench  fixes     :0.15s  me: 2.6s (17.3x, -0.8%)  he: 3.1s (20.8x,  7.4%)  ca: 1.5s ( 9.9x,  2.0%)
-- heap --
heap     trunk_untouched:0.05s  me: 3.6s (72.6x, -----)  he: 5.0s (99.4x, -----)  ca: 4.9s (98.4x, -----)
heap     fixes     :0.05s  me: 3.7s (73.6x, -1.4%)  he: 5.1s (102.4x, -3.0%)  ca: 4.8s (95.2x,  3.3%)
-- heap_pdb4 --
heap_pdb4 trunk_untouched:0.06s  me: 5.9s (98.0x, -----)  he: 5.6s (94.0x, -----)  ca: 5.2s (86.8x, -----)
heap_pdb4 fixes     :0.06s  me: 5.8s (96.0x,  2.0%)  he: 5.7s (94.8x, -0.9%)  ca: 5.2s (87.3x, -0.6%)
-- many-loss-records --
many-loss-records trunk_untouched:0.01s  me: 1.0s (101.0x, -----)  he: 0.8s (85.0x, -----)  ca: 0.8s (76.0x, -----)
many-loss-records fixes     :0.01s  me: 1.0s (100.0x,  1.0%)  he: 0.9s (87.0x, -2.4%)  ca: 0.8s (77.0x, -1.3%)
-- many-xpts --
many-xpts trunk_untouched:0.03s  me: 1.2s (38.7x, -----)  he: 1.4s (45.3x, -----)  ca: 1.9s (62.7x, -----)
many-xpts fixes     :0.03s  me: 1.1s (37.0x,  4.3%)  he: 1.4s (47.0x, -3.7%)  ca: 1.8s (61.3x,  2.1%)
-- memrw --
memrw    trunk_untouched:0.04s  me: 0.9s (22.0x, -----)  he: 2.3s (58.2x, -----)  ca: 1.9s (46.5x, -----)
memrw    fixes     :0.04s  me: 0.9s (21.8x,  1.1%)  he: 2.3s (58.2x,  0.0%)  ca: 1.9s (47.2x, -1.6%)
-- sarp --
sarp     trunk_untouched:0.02s  me: 1.5s (76.5x, -----)  he: 3.4s (167.5x, -----)  ca: 1.3s (63.0x, -----)
sarp     fixes     :0.02s  me: 1.6s (79.5x, -3.9%)  he: 4.0s (200.5x,-19.7%)  ca: 1.3s (65.5x, -4.0%)
-- tinycc --
tinycc   trunk_untouched:0.10s  me: 6.6s (66.3x, -----)  he: 6.6s (66.2x, -----)  ca: 7.2s (72.4x, -----)
tinycc   fixes     :0.10s  me: 6.6s (66.1x,  0.3%)  he: 6.8s (68.1x, -2.9%)  ca: 7.2s (72.2x,  0.3%)
-- Finished tests in perf ----------------------------------------------

== 12 programs, 72 timings =================

coregrind/m_debuglog.c

index bb9aa1b3025f2a09ba9dab0eb0348d5db51ebeaf..7e8b59f623a6374a643ccfbe5bb888611b5f28ce 100644 (file)
@@ -1203,9 +1203,6 @@ void VG_(debugLog) ( Int level, const HChar* modulename,
    if (level > loglevel)
       return;
 
-   indent = 2*level - 1;
-   if (indent < 1) indent = 1;
-
    buf.n = 0;
    buf.buf[0] = 0;
    pid = local_sys_getpid();
@@ -1223,6 +1220,8 @@ void VG_(debugLog) ( Int level, const HChar* modulename,
    (void)myvprintf_int64 ( add_to_buf, &buf, 0, 10, 1, False, (ULong)level );
    (void)myvprintf_str ( add_to_buf, &buf, 0, 1, ":", False );
    (void)myvprintf_str ( add_to_buf, &buf, 0, 8, modulename, False );
+   indent = 2*level - 1;
+   if (indent < 1) indent = 1;
    (void)myvprintf_str ( add_to_buf, &buf, 0, indent, "", False );
 
    va_start(vargs,format);