Commit Graph

16198 Commits

Author SHA1 Message Date
Mark Wielaard
49ca1853fc Also test memcheck/tests/vbit-test on any secondary arch.
If we are building a secondary arch then also build and run the
memcheck vbit-test for that architecture.
2018-12-23 22:20:44 +01:00
Julian Seward
d43c20b391 Bug 402481 - vbit-test fails on x86 for Iop_CmpEQ64 iselInt64Expr Sar64(Sub64(t14,Shr64(t14,0x1:I8)),0x3F:I8).
Fixes the failure by implementing Iop_Sar64 in the x86 back end.
2018-12-23 22:02:03 +01:00
Philippe Waroquiers
59f0855049 Fix 402395 coregrind/vgdb-invoker-solaris.c: 2 * poor error checking
2 size_t variables were used as return value of read syscalls,
while ssize_t must be used.
2018-12-23 14:49:25 +01:00
Julian Seward
3b2f8bf69e amd64 back end: generate improved SIMD64 code.
For most SIMD operations that happen on 64-bit values (as would arise from MMX
instructions, for example, such as Add16x4, CmpEQ32x2, etc), generate code
that performs the operation using SSE/SSE2 instructions on values in the low
halves of XMM registers.  This is much more efficient than the previous scheme
of calling out to helper functions written in C.  There are still a few SIMD64
operations done via helpers, though.
2018-12-22 19:01:50 +01:00
Julian Seward
b17d5ffdb8 amd64 back end: generate better code for 2x64<-->V128 and 4x64<-->V256 transfers ..
.. by adding support for MOVQ xmm/ireg and using that to implement 64HLtoV128,
4x64toV256 and their inverses.  This reduces the number of instructions,
removes the use of memory as an intermediary, and avoids store-forwarding
stalls.
2018-12-22 18:04:42 +01:00
Julian Seward
dda0d80f3d amd64 pipeline: improve performance of cvtdq2ps and cvtps2dq (128 and 256 bit versions) ..
.. by giving them their own vector IROps rather than doing each lane individually.
2018-12-22 16:11:39 +01:00
Julian Seward
901f3d3813 amd64 back end: generate better code for 128/256 bit vector shifts by immediate. n-i-bz. 2018-12-22 13:34:11 +01:00
Julian Seward
b078fabb56 amd64 pipeline: generate much better code for pshufb mm/xmm/ymm. n-i-bz.
pshufb mm/xmm/ymm rearranges byte lanes in vector registers.  It's fairly
widely used, but we generated terrible code for it.  With this patch, we just
generate, at the back end, pshufb plus a bit of masking, which is a great
improvement.
2018-12-22 07:23:00 +01:00
Julian Seward
6cb6bdbd0a amd64 hosts: detect SSSE3 (not SSE3) capabilities on the host. As-yet unused. n-i-bz. 2018-12-22 06:06:19 +01:00
Julian Seward
3af8e12b0d Fix memcheck/tests/undef_malloc_args failure.
Try harder to trigger a memcheck error if a value is (partially) undefined.
2018-12-20 22:47:00 +01:00
Julian Seward
01f1936b12 Adjust ppc set_AV_CR6 computation to help Memcheck instrumentation.
* changes set_AV_CR6 so that it does scalar comparisons against zero,
  rather than sometimes against an all-ones word.  This is something
  that Memcheck can instrument exactly.

* in Memcheck, requests expensive instrumentation of Iop_Cmp{EQ,NE}64
  by default on ppc64le.

https://bugs.kde.org/show_bug.cgi?id=386945#c62
2018-12-20 22:46:59 +01:00
Mark Wielaard
3ef4b2c780 Implement ppc64 lxvb16x as 128-bit vector load with reversed double words.
This makes it possible for memcheck to know which part of the 128bit
vector is defined, even if the load is partly beyond an addressable block.

Partially resolves bug 386945.
2018-12-20 22:46:59 +01:00
Mark Wielaard
8d12697b15 memcheck: Allow unaligned loads of 128bit vectors on ppc64[le].
On powerpc partial unaligned loads of vectors from partially invalid
addresses are OK and could be generated by our translation of lxvd2x.

Adjust partial_load memcheck tests to allow partial loads of 16 byte
vectors on powerpc64.

Part of resolving bug #386945.
2018-12-20 22:46:59 +01:00
Mark Wielaard
98a73de1c0 Implement ppc64 lxvd2x as 128-bit load with double word swap for ppc64le.
This makes it possible for memcheck to know which part of the 128bit
vector is defined, even if the load is partly beyond an addressable block.

Partially resolves bug 386945.
2018-12-20 22:46:59 +01:00
Mark Wielaard
5ecdecdcd3 memcheck: Allow unaligned loads of words on ppc64[le].
On powerpc partial unaligned loads of words from partially invalid
addresses are OK and could be generated by our translation of ldbrx.

Adjust partial_load memcheck tests to allow partial loads of words
on powerpc64.

Part of resolving bug #386945.
2018-12-20 22:46:59 +01:00
Mark Wielaard
0ed17bc9f6 Implement ppc64 ldbrx as 64-bit load and Iop_Reverse8sIn64_x1.
This makes it possible for memcheck to analyse the new gcc strcmp
inlined code correctly even if the ldbrx load is partly beyond an
addressable block.

Partially resolves bug 386945.
2018-12-20 22:46:59 +01:00
Bart Van Assche
5b4029b8cc drd/tests/tsan_thread_wrappers_pthread.h: Fix MyThread::ThreadBody()
See also https://bugs.kde.org/show_bug.cgi?id=402341.
2018-12-19 18:13:31 -08:00
Mark Wielaard
a751b5be01 PR402134 assert fail in mc_translate.c (noteTmpUsesIn) Iex_VECRET on arm64
This happens when processing openssl aes_v8_set_encrypt_key
(aesv8-armx.S:133). The noteTmpUsesIn () function is new since
PR387664 Memcheck: make expensive-definedness-checks be the default.
It didn't handle Iex_VECRET which is used in the arm64 crypto
instruction dirty handlers.
2018-12-19 20:52:29 +01:00
Mark Wielaard
e4dde1327e PR402327 Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x13 DW_OP_drop
readdwarf.c (dwarfexpr_to_dag) didn't handle DW_OP_drop.
Implement it by simply popping the last element on the stack.
2018-12-19 20:14:03 +01:00
Mark Wielaard
2e2ae5bda8 Implement minimal ptrace support for ppc64[le]-linux. 2018-12-14 14:41:57 +01:00
Mark Wielaard
43fe4bc236 arm64: Fix PTRACE_TRACEME memcheck/tests/linux/getregset.vgtest testcase.
The sys_ptrace post didn't mark the thread as being in traceme mode.
This occassionally would make the memcheck/tests/linux/getregset.vgtest
testcase fail. With this patch it reliably passes.
2018-12-14 14:32:27 +01:00
Petar Jovanovic
c4ab123605 mips64: fix build break introduced by be7a730
Follow up to
commit be7a730045

that broke the build for mips64.
2018-12-13 16:20:28 +01:00
Petar Jovanovic
71be91d2dd make outputs of drd/tests/fork* deterministic
Wait for children to finish before terminating the main process.

This fixes occasional failures of the following tests:

drd/tests/fork-parallel                  (stderr)
drd/tests/fork-serial                    (stderr)
2018-12-12 17:53:43 +00:00
Mark Wielaard
be7a730045 Mark helper regs defined in final_tidyup before freeres_wrapper call.
In final_tidyup we setup the guest to call the freeres_wrapper, which
will (possibly) call __gnu_cxx::__freeres() and/or __libc_freeres().

In a couple of cases (ppc64be, ppc64le and mips32) this involves setting
up one or more helper registers. Since we setup these guest registers
we should make sure to mark them as fully defined. Otherwise we might
see spurious warnings about undefined value usage if the guest register
happened to not be fully defined before.

This fixes PR402006.
2018-12-12 14:15:28 +01:00
Nicholas Nethercote
46fb3eb81c Fix path handling in the new Cachegrind and Callgrind tests. 2018-12-12 20:52:33 +11:00
Nicholas Nethercote
e6e8377521 Add a --show-percs option to cg_annotate and callgrind_annotate.
Because it's very useful. As part of this, the "percentage of events
annotated" numbers at the bottom of the output is changed to "events
annotated" so that --show-percs doesn't compute a percentage of a
percentage.

Example output lines:
```
4,967,137,442 (100.0%)  PROGRAM TOTALS

4,543 (25.23%)    17,566 ( 0.43%)    47,993 ( 0.92%) /build/glibc-OTsEL5/glibc-2.27/elf/dl-lookup.c

1 ( 0.01%) 2,000,001 (49.29%) 3,000,004 (57.36%)     for (int i = 0; i < 1000000; i++) {
```

The commit also adds some much-needed tests for cg_annotate and
callgrind_annotate.
2018-12-10 14:14:20 +11:00
Mark Wielaard
0c701ba2a4 Fix sigkill.stderr.exp for glibc-2.28.
glibc 2.28 filters out some bad signal numbers and returns
Invalid argument instead of passing such bad signal numbers
the kernel sigaction syscall. So we won't see such bad signal
numbers and won't print "bad signal number" ourselves.

Add a new memcheck/tests/sigkill.stderr.exp-glibc-2.28 to catch
this case.
2018-12-07 14:05:15 +01:00
Mark Wielaard
a0d97e88ec Bug 401822 Fix asm constraints for ppc64 jm-vmx jm-insns.c test.
The mfvscr and vor instructions in jm-insns.c had a "=vr" constraint.
This should have been an "=v" constraint. This resolved assembler
warnings and the testcase failing on ppc64le with gcc 8.2 and
binutils 2.30.
2018-12-06 20:52:36 +01:00
Mark Wielaard
cf00e0e59d Bug 401627 - Add wcsncmp override and testcase.
glibc 2.28 added an avx2 optimized variant of wstrncmp which memcheck
cannot proof correct. Add a simple override in vg_replace_strmem.c.
2018-12-06 16:40:34 +01:00
Andreas Arnez
43699f30f6 Add Emacs configuration files
This adds a configuration file ".dir-locals.el" for Emacs to the topmost
directory of the Valgrind source tree, and another such file to the
directory drd/tests.  These files contain per-directory local Emacs
variables.

The following settings are performed:

* The base C style is set to "Linux", indentation is set to 3 columns
  per level, the use of tabs for indentation is disabled, and the fill
  column is set to 80.

* The source files in drd/tests use 2 instead of 3 columns per indentation
  level.
2018-12-05 18:15:57 -08:00
Mark Wielaard
206e81e8ad Fix tsan_unittest.cpp compile error with older compilers.
Older compilers (g++ 4.8.5) don't like '>>':
  error: ‘>>’ should be ‘> >’ within a nested template argument list.
Add an extra space.
2018-12-02 12:39:27 +01:00
Bart Van Assche
65dcbc70db drd/tests: Fix remaining gcc 8 compiler warnings 2018-12-01 21:53:59 -08:00
Bart Van Assche
4b90a2e668 Add drd/tests/fork-serial and drd/tests/fork-parallel 2018-12-01 11:05:26 -08:00
Bart Van Assche
66a7a592c0 drd: Add fork test program 2018-12-01 10:45:51 -08:00
Bart Van Assche
df10905d33 drd: Fix fork() handling
The thread ID passed to DRD_(drd_thread_atfork_child)() is a Valgrind
thread ID instead of a DRD thread ID. This patch fixes bug 401578.
2018-12-01 10:45:51 -08:00
Bart Van Assche
bb7086d063 drd/test: Fix most gcc 8 compiler warnings 2018-12-01 10:45:51 -08:00
Vadim Barkov
86bd889458 Bug 385411 s390x: Tests and internals for z13 vector FP support
Add test cases for the z13 vector FP support.  Bring s390-opcodes.csv
up-to-date, reflecting that the z13 vector instructions are now supported.
Also remove the non-support disclaimer for the vector facility from
README.s390.

The patch was contributed by Vadim Barkov, with some clean-up and minor
adjustments by Andreas Arnez.
2018-11-30 14:29:39 +01:00
Vadim Barkov
600a0099a1 Bug 385411 s390x: Add z13 vector floating point support
This adds support for the z/Architecture vector FP instructions that were
introduced with z13.

The patch was contributed by Vadim Barkov, with some clean-up and minor
adjustments by Andreas Arnez.
2018-11-30 14:29:39 +01:00
Julian Seward
f2c03ce3ba Bug 401112 - LLVM 5.0 generates comparison against partially initialized data.
This generalises the existing spec rules for W of 32 bits:

             W  <u   0---(N-1)---0 1 0---0  or

(that is, B/NB after SUBL, where dep2 has the above form), to also cover

             W  <=u  0---(N-1)---0 0 1---1

(that is, BE/NBE after SUBL, where dept2 has the specified form).

Patch from Nicolas B. Pierron (nicolas.b.pierron@nbp.name).
2018-11-28 14:15:06 +01:00
Philippe Waroquiers
7c26e71c09 Always output all leak kinds in a xtree leak result file.
- The option --xtree-leak=yes (to output leak result in xtree format)
  automatically activates the option --show-leak-kinds=all,
  as xtree visualisation tools such as kcachegrind can in any case
  select what kind of leak to visualise.
2018-11-25 19:51:53 +01:00
Andreas Arnez
ddfc274b24 s390x: More fixes for z13 support
This patch addresses the following:

* Fix the implementation of LOCGHI.  Previously Valgrind performed 32-bit
  sign extension instead of 64-bit sign extension on the immediate value.

* Advertise VXRS in HWCAP.  If no VXRS are advertised, but the program
  uses vector registers, this could cause problems with a glibc built with
  "-march=z13".
2018-11-22 13:45:56 +01:00
Julian Seward
27fe22378d Add support for Iop_{Sar,Shr}8 on ppc. --expensive-definedness-checks=yes needs them. 2018-11-20 12:09:03 +01:00
Julian Seward
cb5d7e0475 VEX/priv/ir_opt.c
fold_Expr: transform PopCount64(And64(Add64(x,-1),Not64(x))) into CtzNat64(x).

This is part of the fix for bug 386945.
2018-11-20 11:46:55 +01:00
Julian Seward
81d9832226 ppc front end: use new IROps added in 42719898.
This pertains to bug 386945.

VEX/priv/guest_ppc_toIR.c:

gen_POPCOUNT: use Iop_PopCount{32,64} where possible.

gen_vpopcntd_mode32: use Iop_PopCount32.

for cntlz{w,d}, use Iop_CtzNat{32,64}.

gen_byterev32: use Iop_Reverse8sIn32_x1 instead of lengthy sequence.

verbose_Clz32: remove (was unused anyway).
2018-11-20 11:36:53 +01:00
Julian Seward
e221eca26b Add Memcheck support for IROps added in 42719898.
memcheck/mc_translate.c:

Add mkRight{32,64} as right-travelling analogues to mkLeft{32,64}.

doCmpORD: for the cases of a signed comparison against zero, compute
definedness of the 3 result bits (lt,gt,eq) separately, and, for the lt and eq
bits, do it exactly accurately.

expensiveCountTrailingZeroes: no functional change.  Re-analyse/verify and add
comments.

expensiveCountLeadingZeroes: add.  Very similar to
expensiveCountTrailingZeroes.

Add some comments to mark unary ops which are self-shadowing.

Route Iop_Ctz{,Nat}{32,64} through expensiveCountTrailingZeroes.
Route Iop_Clz{,Nat}{32,64} through expensiveCountLeadingZeroes.

Add instrumentation for Iop_PopCount{32,64} and Iop_Reverse8sIn32_x1.

memcheck/tests/vbit-test/irops.c

Add dummy new entries for all new IROps, just enough to make it compile and
run.
2018-11-20 11:28:42 +01:00
Julian Seward
97d336b79e Add ppc host-side isel and instruction support for IROps added in previous commit.
VEX/priv/host_ppc_defs.c, VEX/priv/host_ppc_defs.h:

Dont emit cnttz{w,d}.  We may need them on a target which doesn't support
them.  Instead we can generate a fairly reasonable alternative sequence with
cntlz{w,d} instead.

Add support for emitting popcnt{w,d}.

VEX/priv/host_ppc_isel.c

Add support for: Iop_ClzNat32 Iop_ClzNat64

Redo support for: Iop_Ctz{32,64} and their Nat equivalents, so as to not use
cnttz{w,d}, as mentioned above.

Add support for: Iop_PopCount64 Iop_PopCount32 Iop_Reverse8sIn32_x1
2018-11-20 11:09:30 +01:00
Julian Seward
4271989815 Add some new IROps to support improved Memcheck analysis of strlen etc.
This is part of the fix for bug 386945.  It adds the following IROps, plus
their supporting type- and printing- fragments:

Iop_Reverse8sIn32_x1: 32-bit byteswap.  A fancy name, but it is consistent
with naming for the other swapping IROps that already exist.

Iop_PopCount64, Iop_PopCount32: population count

Iop_ClzNat64, Iop_ClzNat32, Iop_CtzNat64, Iop_CtzNat32: counting leading and
trailing zeroes, with "natural" (Nat) semantics for a zero input, meaning, in
the case of zero input, return the number of bits in the word.  These
functionally overlap with the existing Iop_Clz64, Iop_Clz32, Iop_Ctz64,
Iop_Ctz32.  The existing operations are undefined in case of a zero input.
Adding these new variants avoids the complexity of having to change the
declared semantics of the existing operations.  Instead they are deprecated
but still available for use.
2018-11-20 10:52:33 +01:00
Julian Seward
7f1dd9d5ae get_otrack_shadow_offset_wrk for ppc32 and ppc64: add missing cases for XER_OV32, XER_CA32 and C_FPCC.
The missing cases were discovered whilst testing fixes for bug 386945, but are
otherwise unrelated to that bug.
2018-11-20 10:28:13 +01:00
Nicholas Nethercote
18d4bf8f0c Fix Cachegrind's --help message. 2018-11-16 16:48:13 +11:00
Andreas Arnez
50bd2282bc Bug 397187 s390x: Add vector register support for vgdb
On s390x machines with a vector facility, Valgrind's gdbserver didn't
represent the vector registers.  This is fixed.
2018-11-14 16:24:06 +01:00