]> git.ipfire.org Git - thirdparty/valgrind.git/log
thirdparty/valgrind.git
7 years agoRemove old Haskell and orig diff files.
Mark Wielaard [Tue, 12 Dec 2017 18:13:08 +0000 (19:13 +0100)] 
Remove old Haskell and orig diff files.

These files haven't been used for the last 20 years.

7 years agoBug 387664 - Memcheck: make expensive-definedness-checks be the default
Julian Seward [Tue, 12 Dec 2017 09:22:51 +0000 (10:22 +0100)] 
Bug 387664 - Memcheck: make expensive-definedness-checks be the default

Memcheck tries to accurately track definedness at the bit level, at least
for scalar integer operations.  For many operations it is good enough to use
approximations which may overstate the undefinedness of the result of an
operation, provided that fully defined inputs still produce a fully defined
output.  For example, the standard analysis for an integer add is

   Add#(x#, y#) = Left(UifU(x#, y#))

which (as explained in the USENIX 05 paper
http://valgrind.org/docs/memcheck2005.pdf) means: for an add, worst-case
carry propagation is assumed.  So all bits to the left of, and including,
the rightmost undefined bit in either operand, are assumed to be undefined.

As compilers have become increasingly aggressive, some of these
approximations are no longer good enough.  For example, LLVM for some years
has used Add operations with partially undefined inputs, when it knows that
the carry propagation will not pollute important parts of the result.
Similarly, both GCC and LLVM will generate integer equality comparisons with
partially undefined inputs in situations where it knows the result of the
comparison will be defined.  In both cases, Memcheck's default strategies
give rise to false uninitialised-value errors, and the problem is getting
worse as time goes by.

Memcheck already has expensive (non-default) instrumentation for integer
adds, subtracts, and equality comparisons.  Currently these are only used if
you specify --expensive-definedness-checks=yes, and in some rare cases to do
with inlined string operations, as determined by analysing the block to be
instrumented, and by default on MacOS.  The performance hit from them can be
quite high, up to 30% lossage.

This patch makes the following changes:

* During instrumentation, there is much finer control over which IROps get
  expensive instrumentation.  The following groups can now be selected
  independently for expensive or cheap instrumentation:

     Iop_Add32
     Iop_Add64
     Iop_Sub32
     Iop_Sub64
     Iop_CmpEQ32 and Iop_CmpNE32
     Iop_CmpEQ64 and Iop_CmpNE64

  This makes it possible to only enable, on a given platform, only the minimal
  necessary set of expensive cases.

* The default set of expensive cases can be set on a per-platform basis.
  This is set up in the first part of MC_(instrument).

* There is a new pre-instrumentation analysis pass.  It identifies Iop_Add32
  and Iop_Add64 uses for which the expensive handling will give the same
  results as the cheap handling.  This includes all adds that are used only
  to create memory addresses.  Given that the expensive handling of adds is,
  well, expensive, and that most adds merely create memory addresses, this
  more than halves the extra costs of expensive Add handling.

* The pre-existing "bogus literal" detection (0x80808080, etc) pass
  has been rolled into the new pre-instrumentation analysis.

* The --expensive-definedness-checks= flag has been changed.  Before, it
  had two settings, "no" and "yes", with "no" being the default.  Now, it
  has three settings:

   no -- always use the cheapest handling

   auto -- use the minimum set of expensive handling needed to get
           reasonable results on this platform, and perform
           pre-instrumentation analysis so as to minimise the costs thereof

   yes -- always use the most expensive handling

  The default setting is now "auto".  The user-visible effect of the new
  default is that there should (hopefully) be a drop in false positive rates
  but (unfortunately) also some drop in performance.

7 years agoFix this test to work properly with accurate CmpEQ/NE definedness tracking
Julian Seward [Thu, 7 Dec 2017 12:31:38 +0000 (13:31 +0100)] 
Fix this test to work properly with accurate CmpEQ/NE definedness tracking

Memcheck reports an error on "if (n == 42)" in this test.  Unless, that is,
accurate CmpEQ/NE definedness tracking is enabled.  If you stare at this
long enough it is possible to see that the test "n == 42" isn't actually
undefined, because |n| is only ever zero or one, and only its least
significant bit is undefined.  So the equality comparison against 42 is
defined because there are corresponding bits in the two operands that are
different and are both defined.

This commit fixes that by comparing with 1, which forces the result to
really depend on the only undefined bit in |n|.

I also added robustification:

* return arbitrary values from gcc_cant_inline_me(), so as to avoid gcc
  simply copying the input to the output or otherwise deleting the
  conditional branch.

* marking gcc_cant_inline_me() as un-inlineable

* Putting compiler barriers in the second conditional in main(), so gcc
  can't simply ignore the result of the call to gcc_cant_inline_me() and
  then delete the call entirely.

7 years agoamd64: add a spec rule for SHRL/SARL then CondS. gcc-8 has been seen to generate...
Julian Seward [Thu, 7 Dec 2017 11:24:57 +0000 (12:24 +0100)] 
amd64: add a spec rule for SHRL/SARL then CondS.  gcc-8 has been seen to generate such things.

7 years agoamd64: Add a new spec rule for SUBL then Cond{B,NB} in the case where the RHS is...
Julian Seward [Tue, 5 Dec 2017 11:35:09 +0000 (12:35 +0100)] 
amd64: Add a new spec rule for SUBL then Cond{B,NB} in the case where the RHS is a constant power of two.

LLVM 5.0 appears to have started generating such constructions in order to
find out whether the top N bits of a value are all zero.  This currently
generates Iop_CmpLE32U on partially uninitialised data, causing false
positives in Memcheck.  It seems simplest and most efficient to remove such
constructions at this point.

7 years agoRearrange sections in mc_translate.c. No functional change.
Julian Seward [Tue, 5 Dec 2017 11:04:17 +0000 (12:04 +0100)] 
Rearrange sections in mc_translate.c.  No functional change.

Rearrange big sections in mc_translate.c, so that the "main" instrumentation
function is at the end of the file rather than in the middle.  The previous
layout never made much sense.  The new layout is, roughly:

* stuff for baseline (level 2, non-origin tracking) instrumentation
* stuff for origin tracking (level 3) instrumentation
* the "final tidying" pass
* the main instrumentation function (and soon, a new pre-instrumentation
  analysis pass)

7 years agoWhen user asks enough verbosity, also give the full version in preamble
Philippe Waroquiers [Tue, 21 Nov 2017 21:17:47 +0000 (22:17 +0100)] 
When user asks enough verbosity, also give the full version in preamble

so that e.g.
   valgrind -v date
produces
   ==7639== Using Valgrind-3.14.0.GIT-c470e0c23c-20171120X and LibVEX; rerun with -h for copyright info
to give the verbose version.

7 years agoarm(32)-linux: add support for the TPIDRURW system register. Fixes #386425.
Julian Seward [Mon, 20 Nov 2017 10:43:55 +0000 (11:43 +0100)] 
arm(32)-linux: add support for the TPIDRURW system register.  Fixes #386425.

7 years agoBypass gcc code generation bug triggered by -finline-functions
Philippe Waroquiers [Thu, 16 Nov 2017 21:53:46 +0000 (22:53 +0100)] 
Bypass gcc code generation bug triggered by -finline-functions

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 =================

7 years agoAdd .stderr.exp file for memcheck/tests/linux/capget when running inside Docker conta...
Ivo Raisr [Wed, 15 Nov 2017 22:33:27 +0000 (23:33 +0100)] 
Add .stderr.exp file for memcheck/tests/linux/capget when running inside Docker container.

7 years agoUpdate .gitignore for Solaris.
Ivo Raisr [Tue, 14 Nov 2017 13:11:40 +0000 (13:11 +0000)] 
Update .gitignore for Solaris.

7 years agoUpdate NEWS after fixing BZ#208052.
Ivo Raisr [Tue, 14 Nov 2017 09:51:49 +0000 (10:51 +0100)] 
Update NEWS after fixing BZ#208052.

7 years agoAvoid underflow in strlcpy and strlcat wrappers when count is zero
Tom Hughes [Tue, 14 Nov 2017 09:16:26 +0000 (09:16 +0000)] 
Avoid underflow in strlcpy and strlcat wrappers when count is zero

We can't decrement n because it's unsigned and might be zero which
means it would wrap and we'd wind up reading far too much.

Fixes BZ#208052

7 years agosynchronize access to vgdb_interrupted_tid
Petar Jovanovic [Mon, 13 Nov 2017 12:12:25 +0000 (13:12 +0100)] 
synchronize access to vgdb_interrupted_tid

Delay writing to the global vgdb_interrupted_tid until all the threads are
in interruptible state. This ensures that valgrind_wait() will see correct
value.

This solves occasional failures of gdbserver_tests/hgtls test.

7 years agoImprove efficiency of SP tracking in helgrind (and incidentally in exp-sgheck)
Philippe Waroquiers [Sat, 4 Nov 2017 22:32:19 +0000 (23:32 +0100)] 
Improve efficiency of SP tracking in helgrind (and incidentally in exp-sgheck)

Helgrind (and incidentally exp-sgcheck) does not need both of
tracking new mem stack and die mem stack:
Helgrind only tracks new mem stack. exp-sgcheck only tracks die mem stack.

Currently, m_translate.c vg_SP_update_pass inserts helpers calls
for new and die mem stack, even if the tool only needs new mem stack (helgrind)
or die mem stack (exp-sgcheck).

The optimisation consists in not inserting helpers calls when the tool
does not need to see new (or die) mem stack.
Also, for helgrind, implement specialised new_mem_stack for known SP updates
with small values (like memcheck).

This reduces the size of the generated code for helgrind and exp-sgcheck.
(see below the diffs on perf/memrw). This does not impact the code generation
for tools that tracks both new and die mem stack (such as memcheck).

trunk:
exp-sgcheck: --28481--  transtab: new        2,256 (44,529 -> 581,402; ratio 13.1) [0 scs] avg tce size 257
helgrind:    --28496--  transtab: new        2,299 (46,667 -> 416,575; ratio 8.9) [0 scs] avg tce size 181
memcheck:    --28501--  transtab: new        2,220 (50,038 -> 777,139; ratio 15.5) [0 scs] avg tce size 350

with this patch:
exp-sgcheck: --28516--  transtab: new        2,254 (44,479 -> 567,196; ratio 12.8) [0 scs] avg tce size 251
helgrind:    --28512--  transtab: new        2,297 (46,620 -> 399,799; ratio 8.6) [0 scs] avg tce size 174
memcheck:    --28507--  transtab: new        2,219 (49,991 -> 776,028; ratio 15.5) [0 scs] avg tce size 349

More in details, the changes consist in:

pub_core_tooliface.h:
  * add 2 booleans any_new_mem_stack and any_die_mem_stack to the tdict struct
  * renamed VG_(sanity_check_needs) to VG_(finish_needs_init), as it
    does now more than sanity checks : it derives the 2 above booleans.
m_tooliface.c:
  * change VG_(sanity_check_needs) to VG_(finish_needs_init)
m_main.c:
  * update call to VG_(sanity_check_needs)
hg_main.c:
  * add a few inlines for functions just calling another function
  * define the functions evh__new_mem_stack_[4|8|12|16|32|112|128|144|160]
    (using the macro DCL_evh__new_mem_stack).
  * call the VG_(track_new_mem_stack_[4|8|12|16|32|112|128|144|160])
m_translate.c
  * n_SP_updates_* stats are now maintained separately for the new and die
    fast and known cases.
  * need_to_handle_SP_assignment can now check only the 2 booleans
    any_new_mem_stack and any_die_mem_stack
  * DO_NEW macro: does not insert anymore a helper call if the tool does
    not track 'new' mem_stack.
    In case there is no new tracking, it however still does update the
    SP aliases (and the n_SP_updates_new_fast).
  * similar changes for DO_DIE macro.
  * a bunch of white spaces changes
 Note: it is easier to look at the changes in this file using
   git diff -w
 to ignore the white spaces changes (e.g. due to DO_NEW/DO_DIE indentation
 changes).

regtested on debian/amd64 and on centos/ppc64

7 years agoMove or conditionalise on CHECK_CEM some expensive asserts
Philippe Waroquiers [Sat, 4 Nov 2017 22:31:19 +0000 (23:31 +0100)] 
Move or conditionalise on CHECK_CEM some expensive asserts

* Some RCEC related asserts checking there was no corruption are on hot paths
   => make these checks only when CHECK_CEM is set.
* Move an expensive assert where the event is inserted, as it is useless
  to check this when searching for an already existing event :
  it is enough to ensure that an invalid szB cannot be inserted,
  and so will not be found, and so assert will trigger in the insertion logic.

7 years agos390_irgen_EX_SS: add initialisations so as to remove (false positive) warnings from...
Julian Seward [Tue, 7 Nov 2017 14:01:51 +0000 (15:01 +0100)] 
s390_irgen_EX_SS: add initialisations so as to remove (false positive) warnings from gcc-7.x.

When compiling guest_s390_toIR.c for a 32-bit target (a configuration in which
it will never be used, but never mind), gcc-7.x notices that sizeof(ss.dec) is
larger than sizeof(ss.bytes), so the initialisation of ss.bytes leaves ss.dec.b2
and ss.dec.d2 uninitialised.  This patch causes both variants to be initialised.
When built for a 64 bit target, the existing initialisation of ss.bytes covers
ss.dec completely, so there is no error.

7 years agoAdd -finline-functions to standard build flags, so gcc will consider all functions...
Julian Seward [Tue, 7 Nov 2017 13:18:16 +0000 (14:18 +0100)] 
Add -finline-functions to standard build flags, so gcc will consider all functions as candidates for inlining.

7 years agoOptionally exit on the first error with --exit-on-first-error=<yes|no>.
Ivo Raisr [Sat, 4 Nov 2017 13:29:48 +0000 (14:29 +0100)] 
Optionally exit on the first error with --exit-on-first-error=<yes|no>.

Fixes BZ#385939.
Slightly modified patch by: Fauchet Gauthier <gauthier.fauchet@free.fr>

7 years agoSmall optimisation in helgrind address description
Philippe Waroquiers [Sat, 4 Nov 2017 07:32:03 +0000 (08:32 +0100)] 
Small optimisation in helgrind address description

Searching if an addr is in a malloc-ed client block is expensive (linear search)
So, before scanning the list of malloc block, check that the address is
in a client heap segment : this is a fast operation (it has a small
cache, and for cache miss, does a dichotomic search) and avoids
scanning a often big list (for big applications).

7 years agomips: finetune tests that print FCSR
Petar Jovanovic [Fri, 3 Nov 2017 18:10:04 +0000 (19:10 +0100)] 
mips: finetune tests that print FCSR

Bits 18 (NAN2008) and 19 (ABS2008) in FCSR are preset by hardware and can
differ between platforms. Hence, we should clear these bits before printing
FCSR value in order to have the same output on different platforms.

This fixes several failures (tests modified by this change) that occur on
MIPS P5600 board. The P5600 is a core that implements MIPS32 Release 5 arch.

7 years agoImprove the NEWS entry for --delta-stacktrace flag.
Philippe Waroquiers [Thu, 2 Nov 2017 20:50:48 +0000 (21:50 +0100)] 
Improve the NEWS entry for --delta-stacktrace flag.

7 years agoFix 376257 - helgrind history full speed up using a cached stack
Philippe Waroquiers [Thu, 2 Nov 2017 20:33:35 +0000 (21:33 +0100)] 
Fix 376257 - helgrind history full speed up using a cached stack

This patch implements the flag --delta-stacktrace=yes/no.
Yes indicates to calculate the full history stack traces by
changing just the last frame if no call/return instruction was
executed.
This can speed up helgrind by up to 25%.

This flags is currently set to yes only on linux x86 and amd64, as some
platform dependent validation of the used heuristics is needed before
setting the default to yes on a platform. See function check_cached_rcec_ok
in libhb_core.c for more details about how to validate/check the behaviour
on a new platform.

7 years agoFix access to time base register to return 64-bits.
Carl Love [Tue, 31 Oct 2017 18:45:28 +0000 (13:45 -0500)] 
Fix access to time base register to return 64-bits.

7 years agoandroid: compute possible size of a symbol of unknown size
Petar Jovanovic [Tue, 31 Oct 2017 16:30:14 +0000 (17:30 +0100)] 
android: compute possible size of a symbol of unknown size

Under specific circumstances, setting 2048 as a size of symbol of unknown
size causes that symbol crosses unmapped region. This further causes an
assertion in Valgrind.

Compute possible size by computing maximal size the symbol can have within
its section.

Patch by Tamara Vlahovic.

7 years agointroduce a test for n-i-bz fix bug in strspn replacement
Philippe Waroquiers [Sat, 28 Oct 2017 13:02:11 +0000 (15:02 +0200)] 
introduce a test for n-i-bz  fix bug in strspn replacement

c1eace647ca4f670ef9bec0d0fe72cdd25a96394 fixed a bug in strspn replacement.
Add a test to cover this fix.

7 years agomips: update NEWS about MIPS MSA support
Petar Jovanovic [Fri, 27 Oct 2017 22:39:16 +0000 (00:39 +0200)] 
mips: update NEWS about MIPS MSA support

Spread the word about MIPS MSA support.

Related BZ issue - #382563.

7 years agomips: MSA tests
Petar Jovanovic [Fri, 27 Oct 2017 14:26:24 +0000 (16:26 +0200)] 
mips: MSA tests

This set of tests covers the whole MSA instruction set:

  none/tests/mips32/msa_arithmetic
  none/tests/mips32/msa_comparison
  none/tests/mips32/msa_data_transfer
  none/tests/mips32/msa_fpu
  none/tests/mips32/msa_logical_and_shift
  none/tests/mips32/msa_shuffle

  none/tests/mips64/msa_arithmetic         (symlink to mips32)
  none/tests/mips64/msa_comparison         (symlink to mips32)
  none/tests/mips64/msa_data_transfer
  none/tests/mips64/msa_fpu                (symlink to mips32)
  none/tests/mips64/msa_logical_and_shift  (symlink to mips32)
  none/tests/mips64/msa_shuffle            (symlink to mips32)

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Related BZ issue - #382563.

7 years agomips: add support for MSA regs in Memcheck
Petar Jovanovic [Fri, 27 Oct 2017 13:10:37 +0000 (15:10 +0200)] 
mips: add support for MSA regs in Memcheck

Add support for MSA registers in Memcheck.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Related BZ issue - #382563.

7 years agomips: detect presence of MSA
Petar Jovanovic [Fri, 27 Oct 2017 13:05:22 +0000 (15:05 +0200)] 
mips: detect presence of MSA

Detect presence of MSA capabilities.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Minor code-style rewrites by myself.

Related BZ issue - #382563.

7 years agomips: MSA support for mips32/mips64.
Petar Jovanovic [Tue, 24 Oct 2017 16:00:28 +0000 (18:00 +0200)] 
mips: MSA support for mips32/mips64.

Full support of MIPS SIMD Architecture Module (MSA) instruction set.

Following IOPs have been implemented using generation of MSA instructions:

  Iop_GetElem8x16, Iop_GetElem16x8, Iop_GetElem32x4, Iop_GetElem64x2,
  Iop_V128to32, Iop_V128HIto64, Iop_V128to64, Iop_F32toF16x4, Iop_Abs64x2,
  Iop_Abs32x4, Iop_Abs16x8, Iop_Abs8x16, Iop_Cnt8x16, Iop_NotV128,
  Iop_Reverse8sIn16_x8, Iop_Reverse8sIn32_x4, Iop_Reverse8sIn64_x2,
  Iop_Cls8x16, Iop_Cls16x8, Iop_Cls32x4, Iop_Clz8x16, Iop_Clz16x8,
  Iop_Clz32x4, Iop_Clz64x2, Iop_Abs32Fx4, Iop_Abs64Fx2, Iop_RecipEst32Fx4,
  Iop_RecipEst64Fx2, Iop_RSqrtEst32Fx4, Iop_RSqrtEst64Fx2, Iop_F16toF32x4,
  Iop_I32UtoFx4, Iop_FtoI32Sx4_RZ, Iop_FtoI32Ux4_RZ, Iop_Add8x16,
  Iop_Add16x8, Iop_Add32x4, Iop_Add64x2, Iop_Sub8x16, Iop_Sub16x8,
  Iop_Sub32x4, Iop_Sub64x2, Iop_QAdd8Sx16, Iop_QAdd16Sx8, Iop_QAdd32Sx4,
  Iop_QAdd64Sx2, Iop_QAdd8Ux16, Iop_QAdd16Ux8, Iop_QAdd32Ux4,
  Iop_QAdd64Ux2, Iop_QSub8Sx16, Iop_QSub16Sx8, Iop_QSub32Sx4,
  Iop_QSub64Sx2, Iop_QSub8Ux16, Iop_QSub16Ux8, Iop_QSub32Ux4,
  Iop_QSub64Ux2, Iop_QDMulHi32Sx4, Iop_QDMulHi16Sx8, Iop_QRDMulHi32Sx4,
  Iop_QRDMulHi16Sx8, Iop_Max8Sx16, Iop_Max16Sx8, Iop_Max32Sx4, Iop_Max64Sx2,
  Iop_Max8Ux16, Iop_Max16Ux8, Iop_Max32Ux4, Iop_Max64Ux2, Iop_Min8Sx16,
  Iop_Min16Sx8, Iop_Min32Sx4, Iop_Min64Sx2, Iop_Min8Ux16, Iop_Min16Ux8,
  Iop_Min32Ux4, Iop_Min64Ux2, Iop_Shl8x16, Iop_Shl16x8, Iop_Shl32x4,
  Iop_Shl64x2, Iop_Shr8x16, Iop_Shr16x8, Iop_Shr32x4, Iop_Shr64x2,
  Iop_Sar8x16, Iop_Sar16x8, Iop_Sar32x4, Iop_Sar64x2, Iop_InterleaveHI8x16,
  Iop_InterleaveHI16x8, Iop_InterleaveHI32x4, Iop_InterleaveHI64x2,
  Iop_InterleaveLO8x16, Iop_InterleaveLO16x8, Iop_InterleaveLO32x4,
  Iop_InterleaveLO64x2, Iop_InterleaveEvenLanes8x16,
  Iop_InterleaveEvenLanes16x8, Iop_InterleaveEvenLanes32x4,
  Iop_InterleaveOddLanes8x16, Iop_InterleaveOddLanes16x8,
  Iop_InterleaveOddLanes32x4, Iop_CmpEQ8x16, Iop_CmpEQ16x8, Iop_CmpEQ32x4,
  Iop_CmpEQ64x2, Iop_CmpGT8Sx16, Iop_CmpGT16Sx8, Iop_CmpGT32Sx4,
  Iop_CmpGT64Sx2, Iop_CmpGT8Ux16, Iop_CmpGT16Ux8, Iop_CmpGT32Ux4,
  Iop_CmpGT64Ux2, Iop_Avg8Sx16, Iop_Avg16Sx8, Iop_Avg32Sx4, Iop_Avg8Ux16,
  Iop_Avg16Ux8, Iop_Avg32Ux4, Iop_Mul8x16, Iop_Mul16x8, Iop_Mul32x4,
  Iop_AndV128, Iop_OrV128, Iop_XorV128, Iop_ShrV128, Iop_ShlV128,
  Iop_ShlN8x16, Iop_ShlN16x8, Iop_ShlN32x4, Iop_ShlN64x2, Iop_SarN8x16,
  Iop_SarN16x8, Iop_SarN32x4, Iop_SarN64x2, Iop_ShrN8x16, Iop_ShrN16x8,
  Iop_ShrN32x4, Iop_ShrN64x2, Iop_QandQSarNnarrow64Sto32Sx2,
  Iop_QandQSarNnarrow32Sto16Sx4, Iop_QandQRSarNnarrow64Sto32Sx2,
  Iop_QandQRSarNnarrow32Sto16Sx4, Iop_CmpEQ32Fx4, Iop_CmpEQ64Fx2,
  Iop_CmpLT32Fx4, Iop_CmpLT64Fx2, Iop_CmpLE32Fx4, Iop_CmpLE64Fx2,
  Iop_CmpUN32Fx4, Iop_CmpUN64Fx2, Iop_64HLtoV128, Iop_Min32Fx4,
  Iop_Min64Fx2, Iop_Max32Fx4, Iop_Max64Fx2, Iop_Sqrt32Fx4,
  Iop_Sqrt64Fx2, Iop_Add32Fx4, Iop_Add64Fx2, Iop_Sub32Fx4,
  Iop_Sub64Fx2, Iop_Mul32Fx4, Iop_Mul64Fx2, Iop_Div32Fx4,
  Iop_Div64Fx2, Iop_F32x4_2toQ16x8, Iop_F64x2_2toQ32x4,
  Iop_ScaleF64, Scale2_64Fx2, Scale2_32Fx4, Iop_Log2_32Fx4, Iop_Log2_64Fx2,
  Iop_PackOddLanes8x16, Iop_PackEvenLanes8x16, Iop_PackOddLanes16x8,
  Iop_PackEvenLanes16x8, Iop_PackOddLanes32x4, Iop_PackEvenLanes32x4.

Folowing IOPs have been implemented without generating MSA instructions:

  Iop_CmpEQ8, Iop_MullU8, Iop_MullS8, Iop_MullU16, Iop_MullS16, Iop_DivS32,
  Iop_DivU32, Iop_DivS64, Iop_DivU64, Iop_F32toI32U, Iop_F64toI64U,
  Iop_I64UtoF64

Imlementation of the following IOPs has been changed in order to use MSA
when it is possible:

  Iop_MAddF64, Iop_MSubF32, Iop_MSubF64.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Related BZ issue - #382563.

7 years agomips: new Iops added to support MSA
Petar Jovanovic [Mon, 9 Oct 2017 15:48:48 +0000 (17:48 +0200)] 
mips: new Iops added to support MSA

New Iops are defined:
  Iop_Scale2_32Fx4, Iop_Scale2_64Fx2,
  Iop_Log2_32Fx4, Iop_Log2_64Fx2,
  Iop_F32x4_2toQ16x8, Iop_F64x2_2toQ32x4,
  Iop_PackOddLanes8x16, Iop_PackEvenLanes8x16,
  Iop_PackOddLanes16x8, Iop_PackEvenLanes16x8,
  Iop_PackOddLanes32x4, Iop_PackEvenLanes32x4.

Contributed by:
  Tamara Vlahovic, Aleksandar Rikalo and Aleksandra Karadzic.

Related BZ issue - #382563.

7 years agoFix n-i-bz fix bug in strspn replacement
Philippe Waroquiers [Thu, 26 Oct 2017 18:53:15 +0000 (20:53 +0200)] 
Fix n-i-bz  fix bug in strspn replacement

Mix-up between UChar and HChar in strspn.
Also grouped together the n-i-bz announded fixes in NEWS

7 years agoBug #385912. Remove explicit NULL check from none/tests/rlimit_nofile.
Mark Wielaard [Fri, 20 Oct 2017 12:55:06 +0000 (14:55 +0200)] 
Bug #385912. Remove explicit NULL check from none/tests/rlimit_nofile.

glibc doesn't guarantee anything about setrlimit with a NULL limit argument.
It could just crash (if it needs to adjust the limit) or might silently
succeed (as newer glibc do). Just remove the extra check.

See also the "setrlimit change to prlimit change in behavior" thread:
https://sourceware.org/ml/libc-alpha/2017-10/threads.html#00830

7 years agoSuppress _dl_runtime_resolve_avx_slow for memcheck conditional.
Mark Wielaard [Tue, 17 Oct 2017 15:49:26 +0000 (17:49 +0200)] 
Suppress _dl_runtime_resolve_avx_slow for memcheck conditional.

glibc ld.so has an optimization when resolving a symbol that checks
whether or not the upper 128 bits of the ymm registers are zero. If
so it uses "cheaper" instructions to save/restore them using the xmm
registers. If those upper 128 bits contain undefined values memcheck
will issue an Conditional jump or move depends on uninitialised value(s)
warning whenever trying to resolve a symbol.

This triggers in our sh-mem-vecxxx test cases. Suppress the warning
by default.

https://bugs.kde.org/show_bug.cgi?id=385868

7 years agomips: simplify handling of Iop_Max32U
Petar Jovanovic [Tue, 17 Oct 2017 13:40:47 +0000 (15:40 +0200)] 
mips: simplify handling of Iop_Max32U

Use MIPSRH_Reg to get MIPSRH for Iop_Max32U. Without it, under specific
circumstances, the code may explode and exceed Valgrind instruction buffer
due to multiple calls to iselWordExpr_R through iselWordExpr_RH.

Issue discovered while testing Valgrind on Android.

Patch by Tamara Vlahovic.

7 years agomips: fix handling of Iex_ITE
Petar Jovanovic [Tue, 17 Oct 2017 13:31:06 +0000 (15:31 +0200)] 
mips: fix handling of Iex_ITE

While handling Iex_ITE, do not use the same virtual register for the
input and output.

Issue discovered while testing Valgrind on Android.

Patch by Tamara Vlahovic.

7 years agoVEX register allocator: allocate caller-save registers for short lived vregs.
Ivo Raisr [Sat, 23 Sep 2017 07:46:40 +0000 (09:46 +0200)] 
VEX register allocator: allocate caller-save registers for short lived vregs.

Allocate caller-saved registers for short lived vregs and callee-save registers
for vregs which span accross helper calls.
Fixes BZ#384987.

7 years agoRefactor tracking of MOV coalescing.
Ivo Raisr [Fri, 22 Sep 2017 20:50:11 +0000 (22:50 +0200)] 
Refactor tracking of MOV coalescing.

Reg<->Reg MOV coalescing status is now a part of the HRegUsage.
This allows register allocation to query it two times without incurring
a performance penalty. This in turn allows to better keep track of
vreg<->vreg MOV coalescing so that all vregs in the coalesce chain
get the effective |dead_before| of the last vreg.

A small performance improvement has been observed because this allows
to coalesce even spilled vregs (previously only assigned ones).

7 years agomips: add support for bi-arch build on mips64
Petar Jovanovic [Tue, 10 Oct 2017 16:06:14 +0000 (18:06 +0200)] 
mips: add support for bi-arch build on mips64

If native compiler can build Valgrind for mips32 o32 on native mips64
system, it should do it.
This change adds a second architecture for MIPS in a similar way how it has
been previously done for amd64 and ppc64.

7 years agoPPC64, vpermr, xxperm, xxpermr fix Iop_Perm8x16 selector field
Carl Love [Thu, 5 Oct 2017 17:19:59 +0000 (12:19 -0500)] 
PPC64, vpermr, xxperm, xxpermr fix Iop_Perm8x16 selector field

The implementation of the vpermr, xxperm, xxpermr violate this by
using a mask of 0x1F.  Fix the code and the corresponding comments
to met the definition for Iop_Perm8x16.  Use Iop_Dup8x16 to generate
vector value for subtraction.

Bugzilla 385334.

7 years agoPPC64, revert the change to vperm instruction.
Carl Love [Wed, 4 Oct 2017 15:54:07 +0000 (10:54 -0500)] 
PPC64, revert the change to vperm instruction.

The patch was in my git tree with the patch I intended to apply.
I didn't realize the patch was in the tree.  Git applied both
patches.  Still investigating the vperm change to see if it is
really needed.

7 years agoPPC64, Add support for xscmpeqdp, xscmpgtdp, xscmpgedp, xsmincdp instructions.
Carl Love [Wed, 4 Oct 2017 15:24:36 +0000 (10:24 -0500)] 
PPC64, Add support for xscmpeqdp, xscmpgtdp, xscmpgedp, xsmincdp instructions.

These are Power 9 instructions.

Add test cases for the new instructions to test_isa_3_0.c

Bugzilla 385183.

7 years agoPPC64, Fix bug in vperm instruction.
Carl Love [Tue, 3 Oct 2017 15:49:48 +0000 (10:49 -0500)] 
PPC64, Fix bug in vperm instruction.

The ISA says:

Let the source vector be the concatenation of the
contents of VR[VRA] followed by the contents of
VR[VRB].

For each integer value i from 0 to 15, do the following.
  Let index be the value specified by bits 3:7 of byte
  element i of VR[VRC].

So, the index value is 5-bits wide ([3:7]), not 4-bits wide.

7 years agoPPC64, Re-implement the vpermr instruction using the Iop_Perm8x16.
Carl Love [Tue, 3 Oct 2017 20:18:09 +0000 (15:18 -0500)] 
PPC64, Re-implement the vpermr instruction using the Iop_Perm8x16.

The current implementation will generate a lot of Iops.  The number
of generated Iops can lead to Valgrind running out of temporary space.
See bugzilla https://bugs.kde.org/show_bug.cgi?id=385208 as an example
of the issue.  Using Iop_Perm8x16 reduces the number of Iops significantly.

bugzilla 385210

7 years agoPPC64, Use the vperm code to implement the xxperm inst.
Carl Love [Tue, 3 Oct 2017 20:09:22 +0000 (15:09 -0500)] 
PPC64, Use the vperm code to implement the xxperm inst.

The current xxperm instruction implementation generates a huge
number of Iops to explicitly do the permutation.  The code
was changed to use the Iop_Perm8x16 which is much more efficient
so temporary memory doesn't get exhausted.

Bugzilla 385208

7 years agoPPC64, Replace body of generate_store_FPRF with C helper function.
Carl Love [Tue, 3 Oct 2017 17:08:09 +0000 (12:08 -0500)] 
PPC64, Replace body of generate_store_FPRF with C helper function.

The function calculates the floating point condition code values
and stores them into the floating point condition code register.
The function is used by a number of instructions. The calculation
generates a lot of Iops as it much check the operatds for NaN, SNaN,
zero, dnorm, norm and infinity. The large number of Iops exhausts
temporary memory.

7 years agoPPC64, Add support for the Data Stream Control Register (DSCR)
Carl Love [Tue, 3 Oct 2017 17:03:22 +0000 (12:03 -0500)] 
PPC64, Add support for the Data Stream Control Register (DSCR)

7 years agomips32: add BE-exp files for several tests
Petar Jovanovic [Mon, 2 Oct 2017 12:54:20 +0000 (14:54 +0200)] 
mips32: add BE-exp files for several tests

This fixes several tests on mips32 BE platforms:

memcheck/tests/mips32/fadvise64
drd/tests/tc19_shadowmem
helgrind/tests/tc19_shadowmem

7 years agomips: make sure configure script checks for correct ABIs
Petar Jovanovic [Mon, 2 Oct 2017 11:28:50 +0000 (13:28 +0200)] 
mips: make sure configure script checks for correct ABIs

For mips64, we currently build for n64.
For mips32, we currently build for o32.

Pass these flags explicitly in configure checks.

7 years agogitignore: Fix up false directory-level .gitignore settings
Rhys Kidd [Mon, 2 Oct 2017 00:57:04 +0000 (20:57 -0400)] 
gitignore: Fix up false directory-level .gitignore settings

So we never intended to ignore all changes from the top-level down in /include
or /cachegrind. Instead allow the filetype-specific .gitignore patterns match
to the contents of these two folders.

Also, don't ignore changes to include/valgrind.h as it exists in the repository
and should be tracked for any changes developers might make.

Changes tested by running a git clean force and then full rebuild. No stray
build artifacts were being tracked erroneously by git after these changes.

7 years agoPreliminary support for Darwin 17.x (macOS 10.13)
Rhys Kidd [Sun, 10 Sep 2017 15:34:32 +0000 (11:34 -0400)] 
Preliminary support for Darwin 17.x (macOS 10.13)

7 years agoFix missing workq_ops operations (macOS)
Rhys Kidd [Sun, 1 Oct 2017 22:56:05 +0000 (18:56 -0400)] 
Fix missing workq_ops operations (macOS)

Related to discussion in bz#383723. Patch based upon one provided by
Andy Maloney.

7 years agomips64: set mips64r2 as default for 64-builds
Petar Jovanovic [Fri, 29 Sep 2017 17:14:42 +0000 (19:14 +0200)] 
mips64: set mips64r2 as default for 64-builds

Set mips64r2 as default. Major 64-bit platforms are Rev2.
This also fixes small issue when -march=octeon is in conflict with -mips64.

7 years agomips: optimize multiplication Iops
Petar Jovanovic [Thu, 28 Sep 2017 17:29:51 +0000 (19:29 +0200)] 
mips: optimize multiplication Iops

Optimize and refactor some of mul* Iop code in VEX/priv/host_mips_.

Patch from Aleksandar Rikalo.

7 years agoMinor refactoring for VEX register allocator v3. No functional change.
Ivo Raisr [Thu, 28 Sep 2017 05:39:12 +0000 (07:39 +0200)] 
Minor refactoring for VEX register allocator v3. No functional change.

7 years agoAdd a .exp file for the dash version in Debian 9
Philippe Waroquiers [Wed, 27 Sep 2017 16:29:58 +0000 (18:29 +0200)] 
Add a .exp file for the dash version in Debian 9

Add shell.stderr.exp-dash3, which differs from shell.stderr.exp-dash2 with:

6c6
< ./shell_binaryfile: 4: ./shell_binaryfile: Syntax error: ")" unexpected
---
> ./shell: 19: ./shell: ./shell_binaryfile: Exec format error

(so the newer dash gives a clearer msg)

7 years agomips: fix typos for the recently added test
Petar Jovanovic [Wed, 27 Sep 2017 14:48:22 +0000 (16:48 +0200)] 
mips: fix typos for the recently added test

Correct name of the recently added test in Makefile.am.

7 years agomips: fix VKI_SIOCATMARK, VKI_SIOCSPGRP and VKI_SIOCGPGRP macros
Petar Jovanovic [Wed, 27 Sep 2017 14:04:31 +0000 (16:04 +0200)] 
mips: fix VKI_SIOCATMARK, VKI_SIOCSPGRP and VKI_SIOCGPGRP macros

Set correct values from Linux kernel.
See ./arch/mips/include/uapi/asm/sockios.h

This issue is covered by newly introduced memcheck test mips32/bad_sioc.

7 years agomips: new Memcheck test, bad_sioc
Petar Jovanovic [Wed, 27 Sep 2017 13:55:16 +0000 (15:55 +0200)] 
mips: new Memcheck test, bad_sioc

Check if Memcheck is able to recognize errors related to uninitialized
parameters in ioctl(SIOCSPGRP / SIOCATMARK) calls.

Test by Aleksandar Rikalo.

7 years agoReorder allocatable registers for s390x so that the callee saved are listed first.
Ivo Raisr [Tue, 26 Sep 2017 07:33:27 +0000 (09:33 +0200)] 
Reorder allocatable registers for s390x so that the callee saved are listed first.

Helper calls always trash all caller saved registers. By listing the callee saved
first then VEX register allocator (both v2 and v3) is more likely to pick them
and does not need to spill that much before helper calls.

7 years agoSupport all Apple clang/LLVM 5.1+
Rhys Kidd [Sun, 10 Sep 2017 15:40:21 +0000 (11:40 -0400)] 
Support all Apple clang/LLVM 5.1+

clang has been reasonably good at standards compliance for a while now, and
the Apple-shipped clang-variant in Xcode remains fairly close to upstream.

Let's assume that the Apple-shipped clang-variant is sufficient for
building valgrind, provided it is above a minimum version of 5.1.

7 years agoFollow up to 'On ppc, add generic_start_main.isra.0 as a below main function'
Philippe Waroquiers [Sat, 23 Sep 2017 14:41:18 +0000 (16:41 +0200)] 
Follow up to 'On ppc, add generic_start_main.isra.0 as a below main function'

massif/tests/mmapunmap on ppc now indicates a below main function.

Note: this ppc53 specific file is needed because the valgrind stack unwinder
does not properly unwind in main.
At the mmap syscall, gdb backtrace gives:
Breakpoint 3, 0x00000000041dbae0 in .__GI_mmap () from /lib64/libc.so.6
(gdb) bt

while the valgrind stack trace gives:
Thread 1: status = VgTs_Runnable (lwpid 64207)
==64207==    at 0x41DBAE0: mmap (in /usr/lib64/libc-2.17.so)
==64207==    by 0x10000833: f (mmapunmap.c:9)
==64207==    by 0x40E6BEB: (below main) (in /usr/lib64/libc-2.17.so)
client stack range: [0x1FFEFF0000 0x1FFF00FFFF] client SP: 0x1FFF00ECE0
valgrind stack top usage: 15632 of 1048576

7 years agoOn ppc, add generic_start_main.isra.0 as a below main function
Philippe Waroquiers [Sat, 23 Sep 2017 11:49:05 +0000 (13:49 +0200)] 
On ppc, add generic_start_main.isra.0 as a below main function

We can have stacktraces such as:
==41840==    by 0x10000927: a1 (deep.c:27)
==41840==    by 0x1000096F: main (deep.c:35)
==41840==    by 0x4126BEB: generic_start_main.isra.0 (in /usr/lib64/libc-2.17.so)
==41840==    by 0x4126E13: __libc_start_main (in /usr/lib64/libc-2.17.so)

So, add generic_start_main.isra.0 as a below main function.
This fixes the test  massif/tests/deep-D

7 years agomassif: match --ignore-fn with the first IP that has a fnname
Philippe Waroquiers [Sat, 23 Sep 2017 11:26:12 +0000 (13:26 +0200)] 
massif: match --ignore-fn with the first IP that has a fnname

Currently, --ignore-fn is only matched with the top IP entries that
have a fnname. With this change, we first search for the first IP that
has a fnname.
This e.g. allows to ignore the allocation for a stacktrace such as:
   0x1 0x2 0x3 fn_to_ignore otherfn

This is then used in massif c++ tests new-cpp and overloaded-new to ignore
the c++ libstdc++ allocation similar to:
==10754== 72,704 bytes in 1 blocks are still reachable in loss record 10 of 10
==10754==    at 0x4C2BBCD: malloc (vg_replace_malloc.c:299)
==10754==    by 0x4EC39BF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)
==10754==    by 0x400F8A9: call_init.part.0 (dl-init.c:72)
==10754==    by 0x400F9BA: call_init (dl-init.c:30)
==10754==    by 0x400F9BA: _dl_init (dl-init.c:120)
==10754==    by 0x4000C59: ??? (in /lib/x86_64-linux-gnu/ld-2.24.so)

7 years agoFollow up to 345307 - Warning about "still reachable" memory when using libstdc...
Philippe Waroquiers [Fri, 22 Sep 2017 21:50:35 +0000 (23:50 +0200)] 
Follow up to  345307 - Warning about "still reachable" memory when using libstdc++ from gcc 5

The bug itself was solved in 3.12 by the addition of __gnu_cxx::__freeres
in the libstdc++ and have valgrind calling it before exit.

However, depending on the version of the libstdc++, the test leak_cpp_interior
was giving different results.

This commit adds some filtering specific to the test, so as to not depend
anymore of the absolute number of bytes leaked, and adds a suppression entry to
ignore the memory allocated by libstdc++.

This allows to have only 2 .exp files, instead of 4 (or worse, if
we would have to handle yet other .exp files depending on the libstdc++
version).

7 years agoImplement static TLS code for more platforms
Philippe Waroquiers [Tue, 19 Sep 2017 21:17:48 +0000 (23:17 +0200)] 
Implement static TLS code for more platforms

gdbserver_tests/hgtls is failing on a number of platforms
as it looks like static tls handling is now needed.
So, omplement static tls for a few more platforms.
The formulas that are platform dependent are somewhat wild guesses
obtained with trial and errors.
Note that arm/arm64/ppc32 are not (yet) done

7 years agoFix assert on ppc32 due to typo for GPR28
Philippe Waroquiers [Tue, 19 Sep 2017 21:12:35 +0000 (23:12 +0200)] 
Fix assert on ppc32 due to typo for GPR28

The below commit introduced a regression on ppc32
ommit 00d4667295a821fef9eb198abcb0c942dffb6045
Author: Ivo Raisr <ivosh@ivosh.net>
Date:   Wed Sep 6 08:10:36 2017 +0200

    Reorder allocatable registers for AMD64, X86, and PPC so that the callee saved are listed first.

    Helper calls always trash all caller saved registers. By listing the callee saved
    first then VEX register allocator (both v2 and v3) is more likely to pick them
    and does not need to spill that much before helper calls.

Investigation/fix done by Ivo.

7 years agoFix a typo bug in VEX register allocator v3.
Ivo Raisr [Sat, 16 Sep 2017 16:48:36 +0000 (18:48 +0200)] 
Fix a typo bug in VEX register allocator v3.

Also scanning a few more instructions ahead helps producing
better code.

7 years agomips: finetune none/tests/(mips32|64)/test_math test
Petar Jovanovic [Fri, 15 Sep 2017 16:29:29 +0000 (18:29 +0200)] 
mips: finetune none/tests/(mips32|64)/test_math test

Compiler may optimize out call to cbrt. Change test to prevent that.
Otherwise, the test does not exercise a desired codepath for cbrt, and it
prints precalculated value.

7 years agomips: add clearing $ra to CLEAR_CALLER_SAVED_REGS macro
Petar Jovanovic [Fri, 15 Sep 2017 14:04:18 +0000 (16:04 +0200)] 
mips: add clearing $ra to CLEAR_CALLER_SAVED_REGS macro

Return address register belongs to caller saved registers, and compiler can
use it to store temporary values. Clear it.

7 years agoReorder allocatable registers for AMD64, X86, and PPC so that the callee saved are...
Ivo Raisr [Wed, 6 Sep 2017 06:10:36 +0000 (08:10 +0200)] 
Reorder allocatable registers for AMD64, X86, and PPC so that the callee saved are listed first.

Helper calls always trash all caller saved registers. By listing the callee saved
first then VEX register allocator (both v2 and v3) is more likely to pick them
and does not need to spill that much before helper calls.

7 years agoFix Bug 255603 - exp-sgcheck Assertion '!already_present' failed
Philippe Waroquiers [Wed, 13 Sep 2017 20:47:11 +0000 (22:47 +0200)] 
Fix Bug 255603 - exp-sgcheck Assertion '!already_present' failed

The code handling array bounds is not ready to accept a reference
to something else (not very clear what this reference could be) :
the code only expects directly the value of a bound.
So, it was using the reference (i.e. an offset somewehere in the debug
info) as the value of the bound.
This then gave huge bounds for some arrays, causing an overlap
in the stack variable handling code in exp-sgcheck.

Such references seems to be used sometimes for arrays with variable
size stack allocated.

Fix (or rather bypass) the problem by not considering that we have
a usable array bound when a reference is given.

7 years agoUpdate AUTHORS
Rhys Kidd [Sun, 10 Sep 2017 15:08:20 +0000 (11:08 -0400)] 
Update AUTHORS

7 years agoFix syscall param msg->desc.port.name on macOS 10.12. bz#379373
Rhys Kidd [Sun, 10 Sep 2017 05:12:15 +0000 (01:12 -0400)] 
Fix syscall param msg->desc.port.name on macOS 10.12. bz#379373

Based upon patch from Louis Brunner.

7 years agoReduce number of spill instructions generated by VEX register allocator v3.
Ivo Raisr [Sat, 9 Sep 2017 20:08:21 +0000 (22:08 +0200)] 
Reduce number of spill instructions generated by VEX register allocator v3.

Keeps track whether the bound real register has been reloaded from a virtual
register recently and if this real reg is still equal to that spill slot.
Avoids unnecessary spilling that vreg later, when this rreg needs
to be reserved, usually as a caller save register for a helper call.

Fixes BZ#384526.

7 years agoSmall performance enhancement to VEX register allocator v2.
Ivo Raisr [Mon, 4 Sep 2017 07:21:05 +0000 (09:21 +0200)] 
Small performance enhancement to VEX register allocator v2.

Iterate only over real registers of the target hreg class.

7 years agoFix missing pselect syscall (OS X 10.11). bz#379748
Rhys Kidd [Sun, 3 Sep 2017 16:55:52 +0000 (12:55 -0400)] 
Fix missing pselect syscall (OS X 10.11). bz#379748

Based upon patch from Louis Brunner.

7 years agoSmall fixes to notes about Inner/Outer setup.
Ivo Raisr [Fri, 1 Sep 2017 15:27:08 +0000 (17:27 +0200)] 
Small fixes to notes about Inner/Outer setup.

7 years agoImprove the implementation of expensiveCmpEQorNE.
Julian Seward [Thu, 31 Aug 2017 09:11:25 +0000 (11:11 +0200)] 
Improve the implementation of expensiveCmpEQorNE.

.. so that the code it creates runs in approximately half the time it did
before.  This is in support of making the cost of expensive (exactly)
integer EQ/NE as low as possible, since the day will soon come when we'll
need to enable this by default.

7 years agoFix eflags handling in amd64 instruction tests
Tom Hughes [Wed, 30 Aug 2017 18:26:37 +0000 (19:26 +0100)] 
Fix eflags handling in amd64 instruction tests

In 64 bit mode there's no way to just save eflags so we save the
whole of rflags but we were doing so to a 32 bit variable!

Replace that with proper rflags support that knows it is dealing
with the full 64 bit flags word in 64 bit mode.

7 years agoamd64 back end: handle CmpNEZ64(And64(x,y)) better; ditto the 32 bit case.
Julian Seward [Wed, 30 Aug 2017 17:43:59 +0000 (19:43 +0200)] 
amd64 back end: handle CmpNEZ64(And64(x,y)) better; ditto the 32 bit case.

Handle CmpNEZ64(And64(x,y)) by branching on flags, similarly to
CmpNEZ64(Or64(x,y)).  Ditto the 32 bit equivalents.  Also, remove expensive
DEFINE_PATTERN/DECLARE_PATTERN uses there and hardwire the matching logic.

n-i-bz.  This is in support of reducing the cost of expensiveCmpEQorNE
in memcheck.

7 years agoFix FMRI of built Solaris packages.
Ivo Raisr [Tue, 29 Aug 2017 14:13:02 +0000 (16:13 +0200)] 
Fix FMRI of built Solaris packages.

7 years agoReduce lfedora1.sendmail diff lines.
Mark Wielaard [Tue, 29 Aug 2017 09:09:41 +0000 (11:09 +0200)] 
Reduce lfedora1.sendmail diff lines.

The mailinglist was rejecting the nightly emails because they were too big.

7 years agoFix building Solaris package from git SCM.
Ivo Raisr [Tue, 29 Aug 2017 08:13:20 +0000 (10:13 +0200)] 
Fix building Solaris package from git SCM.

7 years agoMention AddrCheck at Memcheck's command line option --undef-value-errors=no
Ivo Raisr [Mon, 28 Aug 2017 06:00:12 +0000 (08:00 +0200)] 
Mention AddrCheck at Memcheck's command line option --undef-value-errors=no

7 years agoVEX register allocator version 3.
Ivo Raisr [Fri, 25 Aug 2017 22:19:05 +0000 (00:19 +0200)] 
VEX register allocator version 3.

Implements a new version of VEX register allocator which
keeps the main state per virtual registers, as opposed
to real registers in v2. This results in a simpler and
cleaner design and much simpler implementation.
It has been observed that the new allocator executes 20-30%
faster than the previous one but could produce slightly worse
spilling decisions. Overall performance improvement when running
the Valgrind performance regression test suite has been observed
in terms of a few percent.

The new register allocator (v3) is now the default one.
The old register allocator (v2) is still kept around and can be
activated with command line option '--vex-regalloc-version=2'.

Fixes BZ#381553.

7 years agoFollow up to 9f9ad501 : ensure we only have a single X if several files modified
Philippe Waroquiers [Sat, 26 Aug 2017 07:01:42 +0000 (09:01 +0200)] 
Follow up to 9f9ad501 : ensure we only have a single X if several files modified

7 years agoAdd to -v --version commit date+(optional) trailing X char if some files are changed
Philippe Waroquiers [Sat, 26 Aug 2017 06:47:46 +0000 (08:47 +0200)] 
Add to -v --version commit date+(optional) trailing X char if some files are changed

7 years agomips: remove incorrect implementation of several Iops
Petar Jovanovic [Tue, 22 Aug 2017 14:05:00 +0000 (16:05 +0200)] 
mips: remove incorrect implementation of several Iops

Remove incorrect implementation of
  Iop_DivModU64to32
  Iop_DivModS64to32
  Iop_DivModU128to64
  Iop_DivModS128to64

7 years agomips: reimplement handling of div, divu and ddivu
Petar Jovanovic [Tue, 22 Aug 2017 13:53:15 +0000 (15:53 +0200)] 
mips: reimplement handling of div, divu and ddivu

Previous implementation misused some opcodes, and a side effect was
dead code emission.
To reimplement handling of these instructions, three new IoPs have been
introduced:

      Iop_DivModU64to64, // :: I64,I64 -> I128
                         // of which lo half is div and hi half is mod
      Iop_DivModS32to32, // :: I32,I32 -> I64
                         // of which lo half is div and hi half is mod
      Iop_DivModU32to32, // :: I32,I32 -> I64
                         // of which lo half is div and hi half is mod

Patch by Aleksandra Karadzic and Tamara Vlahovic.

7 years agoRecognize signal 151 (SIGLIBRT) sent by gdb.
Ivo Raisr [Fri, 18 Aug 2017 14:53:57 +0000 (16:53 +0200)] 
Recognize signal 151 (SIGLIBRT) sent by gdb.

It has been observed that gdb on Solaris sends this signal to
child processes. Unfortunately array "pass_signals" was too small
to accomodate this signal and subsequently VG_(clo_vex_control).iropt_verbosity
was overwritten.
This has been fixed now.

7 years agoAdd missing error kinds for Memcheck into XML output protocol 4.
Ivo Raisr [Thu, 17 Aug 2017 08:18:21 +0000 (10:18 +0200)] 
Add missing error kinds for Memcheck into XML output protocol 4.

Error kinds have been re-ordered to match MC_ErrorTag.
Patch by: John Davis <jedavis@alumni.cmu.edu>

7 years agoFix out-of-tree build on Solaris.
Ivo Raisr [Thu, 17 Aug 2017 20:38:18 +0000 (22:38 +0200)] 
Fix out-of-tree build on Solaris.

Simply #include config.h with no path at all.
Path by: Rob Boehne <robb@datalogics.com>

7 years agomips32: finetune vfp test to avoid compiler warnings
Petar Jovanovic [Thu, 17 Aug 2017 18:08:17 +0000 (20:08 +0200)] 
mips32: finetune vfp test to avoid compiler warnings

This patch removes two compiler warnings from the test:

vfp.c: In function 'handler':
vfp.c:260:4: warning: implicit declaration of function 'exit'
[-Wimplicit-function-declaration]
    exit(0);
    ^
vfp.c:260:4: warning: incompatible implicit declaration of built-in
function 'exit'
vfp.c: At top level:
vfp.c:258:13: warning: 'handler' defined but not used [-Wunused-function]
 static void handler(int sig)
             ^

7 years agomips: mute 'uninitialized' value compiler warning
Petar Jovanovic [Thu, 17 Aug 2017 17:10:25 +0000 (19:10 +0200)] 
mips: mute 'uninitialized' value compiler warning

fadvise64.c deliberately uses uninitialized value.
This patch removes the following warning:

warning: 'x' is used uninitialized in this function

7 years agoAdd nightly config file for Solaris Trunk x86.
Ivo Raisr [Tue, 15 Aug 2017 21:37:41 +0000 (21:37 +0000)] 
Add nightly config file for Solaris Trunk x86.

7 years ago Small improvement to user manual: capitalise another occurence of memcheck
Philippe Waroquiers [Tue, 15 Aug 2017 21:30:46 +0000 (23:30 +0200)] 
 Small improvement to user manual: capitalise another occurence of memcheck

   (yes, I am experimenting with valgrind git repository :)

7 years agoSmall improvement to user manual: capitalise one occurence of memcheck
Philippe Waroquiers [Tue, 15 Aug 2017 21:06:28 +0000 (23:06 +0200)] 
Small improvement to user manual: capitalise one occurence of memcheck

7 years agoAdd nightly config file for Solaris 11.3 x86.
Ivo Raisr [Tue, 15 Aug 2017 20:06:25 +0000 (22:06 +0200)] 
Add nightly config file for Solaris 11.3 x86.