Commit Graph

3900 Commits

Author SHA1 Message Date
Dmitry Vyukov 4bfb4cb1e7 tsan: add pthread_barrier_t test
llvm-svn: 204810
2014-03-26 14:13:49 +00:00
Dmitry Vyukov 5da31e03bf tsan: fix deadlock during fork
ReportRace takes the two mutexes in the opposite order

llvm-svn: 204809
2014-03-26 14:13:31 +00:00
Dmitry Vyukov b979a55607 tsan: fix another compiler-injected memset
newer gcc inserts memset here

llvm-svn: 204808
2014-03-26 14:13:00 +00:00
Evgeniy Stepanov 16d89fc356 [sanitizer] Intercept __aeabi_mem(set|cpy|move).
llvm-svn: 204800
2014-03-26 12:14:34 +00:00
Viktor Kutuzov 9068dfa6a7 Define uintptr_t in the profiling sources on x86_64 FreeBSD in 32-bit mode
llvm-svn: 204799
2014-03-26 12:00:44 +00:00
Alexander Potapenko 7caa0b9e36 [ASan] Fix a thinko spotted by Evgeniy Stepanov: use REAL(memcpy) on non-OSX systems.
llvm-svn: 204794
2014-03-26 11:18:25 +00:00
Evgeniy Stepanov 1382fabd97 [msan] Enable SelectPartial test.
Fixed in r204716.

llvm-svn: 204717
2014-03-25 13:09:14 +00:00
Evgeniy Stepanov 1611ed8879 [tsan] Fix more warnings in TSan tests.
llvm-svn: 204715
2014-03-25 13:01:32 +00:00
Evgeniy Stepanov 0f08043aeb [tsan] Fix compiler warnings in TSan tests.
llvm-svn: 204712
2014-03-25 11:17:14 +00:00
Evgeniy Stepanov 517ff05ffb [msan] Fix compiler warning in msan_test.cc.
llvm-svn: 204708
2014-03-25 10:03:39 +00:00
Evgeniy Stepanov 90384ad60e [msan] A disabled test for inexact "select" instrumentation.
llvm-svn: 204707
2014-03-25 09:36:15 +00:00
Duncan P. N. Exon Smith 21b98a6c83 InstrProf: Change the extension of the default profile
Change the name of the default profile dumped by compiler-rt to
default.profraw.  This distinguishes it more clearly from the
(incompatible) format output by llvm-profdata that is read by clang
-fprofile-instr-use.

llvm-svn: 204676
2014-03-24 21:53:42 +00:00
Dmitry Vyukov d23118c3b2 tsan: optimize vector clock operations
Make vector clock operations O(1) for several important classes of use cases.
See comments for details.
Below are stats from a large server app, 77% of all clock operations are handled as O(1).

Clock acquire                     :         25983645
  empty clock                     :          6288080
  fast from release-store         :         14917504
  contains my tid                 :          4515743
  repeated (fast)                 :          2141428
  full (slow)                     :          2636633
  acquired something              :          1426863
Clock release                     :          2544216
  resize                          :             6241
  fast1                           :           197693
  fast2                           :          1016293
  fast3                           :             2007
  full (slow)                     :          1797488
  was acquired                    :           709227
  clear tail                      :                1
  last overflow                   :                0
Clock release store               :          3446946
  resize                          :           200516
  fast                            :           469265
  slow                            :          2977681
  clear tail                      :                0
Clock acquire-release             :           820028

llvm-svn: 204656
2014-03-24 18:54:20 +00:00
Dmitry Vyukov f49921ba53 tsan: reorder SyncVar members to reduce contention
llvm-svn: 204655
2014-03-24 18:51:37 +00:00
Dmitry Vyukov 781eca5f71 tsan: use read lock instead of write in atomic operations when possible
llvm-svn: 204654
2014-03-24 18:51:13 +00:00
Dmitry Vyukov 775b11cc53 tsan: reduce default number of threads in benchmarks
buildbots seem to OOM with that many threads

llvm-svn: 204610
2014-03-24 15:23:05 +00:00
Dmitry Vyukov 238bd23534 tsan: add benchmarks for synchronization handling
llvm-svn: 204608
2014-03-24 14:32:59 +00:00
Alexey Samsonov c41ca6d31a [CMake] Rename the variable
llvm-svn: 204602
2014-03-24 13:29:20 +00:00
Timur Iskhodzhanov 59ce9e07a4 Fix a VS compile-time warning
warning C4345: behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized

llvm-svn: 204597
2014-03-24 10:47:37 +00:00
Viktor Kutuzov 276fefb8d9 A fix for sanitizers' TLS support on FreeBSD
llvm-svn: 204595
2014-03-24 10:01:54 +00:00
Alexey Samsonov 1847401332 [CMake] Respect CMAKE_CXX_FLAGS in custom clang_compile commands
llvm-svn: 204593
2014-03-24 09:42:12 +00:00
Alexey Samsonov 8c956460d3 Make MSan unittest -Werror=sign-compare clean
llvm-svn: 204592
2014-03-24 09:41:11 +00:00
Evgeniy Stepanov ce002ad3b2 [asan] Disable setjmp/sigsetjmp tests.
Failing due to PR19207.

llvm-svn: 204590
2014-03-24 08:30:59 +00:00
Evgeniy Stepanov d7f06ee3c7 [asan] Fix a comment.
llvm-svn: 204589
2014-03-24 08:27:31 +00:00
Duncan P. N. Exon Smith 96cf6c3892 InstrProf: Indicate pointer size in raw profile
Since the profile can come from 32-bit machines, the reader needs to
check the pointer size.  Change the magic number to facilitate this.

<rdar://problem/16400648>

llvm-svn: 204556
2014-03-23 03:38:05 +00:00
David Blaikie 089b5c9174 Avoid GCC's "cast from pointer to integer of different size" warning.
This is a bit of a stab in the dark as I'm not sure I've got these
source files compiling correctly locally. (and the warning only
reproduces on a 32bit build anyway)

llvm-svn: 204521
2014-03-21 21:45:49 +00:00
Duncan P. N. Exon Smith 8d02a2ac21 InstrProf: Remove MSVC-specific logic
Apparently, MSVC has stdint.h now?  Let's see if the buildbots complain.
I'm not convinced that the build system is even set up for MSVC to build
this file, but...

llvm-svn: 204515
2014-03-21 20:59:08 +00:00
Duncan P. N. Exon Smith a128956243 InstrProf: Change magic number to have non-text characters
Include non-text characters in the magic number so that text files can't
match.

<rdar://problem/15950346>

llvm-svn: 204514
2014-03-21 20:42:40 +00:00
Duncan P. N. Exon Smith f1c9361326 InstrProf: __ => _ in header guards
llvm-svn: 204502
2014-03-21 18:47:23 +00:00
Duncan P. N. Exon Smith 812dcae09c InstrProf: Unify logic in two profile writers
<rdar://problem/15943240>

llvm-svn: 204500
2014-03-21 18:29:24 +00:00
Duncan P. N. Exon Smith 117cf2bd1f InstrProf: Write the __llvm_profile_write_buffer()
Write __llvm_profile_write_buffer(), which uses the same logic as
__llvm_profile_write_file(), but writes directly to a provided `char*`
buffer instead.

<rdar://problem/15943240>

llvm-svn: 204499
2014-03-21 18:29:22 +00:00
Duncan P. N. Exon Smith cf4bb960bd InstrProf: If libc is available, use it; no functionality change
It was misguided to plan to rely on __llvm_profile_write_buffer() in
__llvm_profile_write_file().  It's less complex to duplicate the writing
logic than to mmap the file.

Since it's here to stay, move `FILE*`-based writing logic into
InstrProfilingFile.c.

<rdar://problem/15943240>

llvm-svn: 204498
2014-03-21 18:29:19 +00:00
Duncan P. N. Exon Smith be0a5e176b InstrProf: Reorganize files; no functionality change
Move functions around to prepare for some other changes.

  - Merge InstrProfilingExtras.h with InstrProfiling.h.  There's no
    benefit to having these split.

  - Rename InstrProfilingExtras.c to InstrProfilingFile.c.

  - Split actual buffer writing code out of InstrProfiling.c into
    InstrProfilingBuffer.c.

  - Drive-by corrections of a couple of header comments.

<rdar://problem/15943240>

llvm-svn: 204497
2014-03-21 18:29:15 +00:00
Duncan P. N. Exon Smith 76e8731b09 InstrProf: Write raw binary profile from runtime
Write a raw binary profile from the runtime.

<rdar://problem/15950346>

llvm-svn: 204495
2014-03-21 18:25:56 +00:00
Alexander Potapenko 25e204e194 [libsanitizer] Add descriptions for the common flags.
Use new(allocator_for_flags) instead of allocator_for_flags.Allocate()
Fix the description output format a bit.

llvm-svn: 204484
2014-03-21 17:28:12 +00:00
Kostya Serebryany 3df5d87da4 [sanitizer] print threads in deadlock report
llvm-svn: 204461
2014-03-21 13:00:18 +00:00
Kostya Serebryany 7317d9499b [sanitizer] more human-readable deadlock reports
llvm-svn: 204454
2014-03-21 11:37:43 +00:00
Sergey Matveev fa76f3b3a5 [MSan] Add __msan_unpoison_string() to the public interface.
Using __msan_unpoison() on null-terminated strings is awkward because
strlen() can't be called on a poisoned string. This case warrants a special
interface function.

llvm-svn: 204448
2014-03-21 10:12:17 +00:00
Alexander Potapenko c6afaace15 [ASan] Move the flag descriptions from comments to ParseFlag arguments.
llvm-svn: 204440
2014-03-21 08:37:59 +00:00
Greg Fitzgerald 8288afb5fe fixed check_lint.sh in standalone build
Change-Id: I30d340bbe6b2028cc0f831399b62521912dcac60
llvm-svn: 204419
2014-03-21 00:45:21 +00:00
Duncan P. N. Exon Smith 4543aac96e PGO: Indicate errors in profile runtime API
Return 0 for success, non-0 for failure.

llvm-svn: 204415
2014-03-21 00:27:50 +00:00
Duncan P. N. Exon Smith e5edc8869b PGO: Substitute pid for %p in filename
Add logic to do a printf-style substitution of %p for the process pid in
the filename.

It's getting increasingly awkward to work on lib/profile without test
infrastructure.  This needs to be fixed!

<rdar://problem/16383358>

llvm-svn: 204414
2014-03-21 00:27:48 +00:00
Duncan P. N. Exon Smith 71704754d6 PGO: Declare zero-argument C functions as foo(void)
It turns out this is C code.  Specify foo(void).

<rdar://problem/15943240>

llvm-svn: 204396
2014-03-20 20:55:00 +00:00
Duncan P. N. Exon Smith 9edbae0f16 PGO: Change runtime prefix from pgo to profile
These functions are in the profile runtime.  PGO comes later.

Unfortunately, there's only room for 16 characters in a Darwin section,
so use __llvm_prf_ instead of __llvm_profile_ for section names.

<rdar://problem/15943240>

llvm-svn: 204391
2014-03-20 20:00:44 +00:00
Duncan P. N. Exon Smith bb8345b791 Add vim swap files to .gitignore
llvm-svn: 204387
2014-03-20 19:44:33 +00:00
Duncan P. N. Exon Smith f1212176ac PGO: Add function to reset counters at runtime
Adding __llvm_pgo_reset_counters(), which sets all the counters to 0.

<rdar://problem/15943240>

llvm-svn: 204386
2014-03-20 19:44:31 +00:00
Duncan P. N. Exon Smith c962cda1db PGO: Add missing file...
llvm-svn: 204384
2014-03-20 19:39:01 +00:00
Duncan P. N. Exon Smith 54cc0e2d81 PGO: Update interface for writing instrumentation data to file
__llvm_pgo_write_default_file() was a bad name, since it checked the
environment (it wasn't just a default file).

  - Change __llvm_pgo_write_file() to __llvm_pgo_write_file_with_name()
    and make it static.

  - Rename __llvm_pgo_write_default_file() to __llvm_pgo_write_file().

  - Add __llvm_pgo_set_filename(), which sets the filename for
    subsequent calls to __llvm_pgo_write_file().

<rdar://problem/15943240>

llvm-svn: 204381
2014-03-20 19:23:55 +00:00
Duncan P. N. Exon Smith 775c178a90 PGO: Add explicit static initialization
Instead of relying on explicit static initialization from translation
units, create a new file, InstrProfilingRuntime.cc, with an
__llvm_pgo_runtime variable.  After this commit (and its pair in clang),
the driver will create a use of this variable.  Unless the user defines
their own version, the new object file will get pulled in, including
that C++ static initialization that calls
__llvm_pgo_register_write_atexit.

The result is that, at least on Darwin, static initialization typically
consists of a single function call, which registers a writeout functino
atexit.  Furthermore, users can skip even this behaviour by defining
their own __llvm_pgo_runtime.

<rdar://problem/15943240>

llvm-svn: 204380
2014-03-20 19:23:53 +00:00
Duncan P. N. Exon Smith 9cee5e0e92 PGO: Moving files for clarity
<rdar://problem/15943240>

llvm-svn: 204373
2014-03-20 18:43:09 +00:00
Evgeniy Stepanov d17b061eed [msan] Use new -fsanitize-memory-track-origins= flag in MSan tests.
llvm-svn: 204347
2014-03-20 15:00:39 +00:00
Alexander Potapenko d23359c3e3 [libsanitizer] Implement IntrusiveList<T>::Iterator, use IntrusiveList in sanitizer_flags.cc
llvm-svn: 204342
2014-03-20 13:49:21 +00:00
Dmitry Vyukov 454abc0093 tsan: deflake test
llvm-svn: 204340
2014-03-20 13:27:11 +00:00
Alexander Potapenko 1296436cbf [libsanitizer] Introduce flag descriptions.
Extend ParseFlag to accept the |description| parameter, add dummy values for all existing flags.
As the flags are parsed their descriptions are stored in a global linked list.
The tool can later call __sanitizer::PrintFlagDescriptions() to dump all the flag names and their descriptions.
Add the 'help' flag and make ASan, TSan and MSan print the flags if 'help' is set to 1.

llvm-svn: 204339
2014-03-20 12:52:52 +00:00
Dmitry Vyukov d3466b9e5e tsan: remove unused function declarations
llvm-svn: 204328
2014-03-20 10:39:46 +00:00
Dmitry Vyukov c9e12aa323 tsan: deobfuscate global ctx variable
llvm-svn: 204327
2014-03-20 10:36:20 +00:00
Dmitry Vyukov 6e2557769c tsan: use stack depot for goroutine creation stacks (as C++ threads do)
llvm-svn: 204326
2014-03-20 10:19:02 +00:00
Dmitry Vyukov 9cf08c46a6 tsan: remove unused declaration
llvm-svn: 204324
2014-03-20 10:13:30 +00:00
Alexey Samsonov 6c3f7fcb8a Mark this test as 64-bit specific
llvm-svn: 204319
2014-03-20 07:37:45 +00:00
Duncan P. N. Exon Smith ecf2256dfe PGO: Implement Darwin linker magic for instrumentation
Use Darwin linker magic to find bounds of instrumentation data sections
at link time instead of runtime.

<rdar://problem/15943240>

llvm-svn: 204302
2014-03-20 03:57:33 +00:00
Duncan P. N. Exon Smith da0de8a237 PGO: Split out initialization of section bounds
Currently we register instrumentation data at runtime to determine the
bounds of the sections where the data lives.  Soon we'll implement
platform-specific linker magic to determine this at link time.

Move this logic to a separate file, so that our build system can choose
the correct platform-specific code.

No functionality change intended.

<rdar://problem/15943240>

llvm-svn: 204299
2014-03-20 03:23:10 +00:00
Duncan P. N. Exon Smith a84dae2c2c PGO: Constify references to instrumentation data
<rdar://problem/15943240>

llvm-svn: 204298
2014-03-20 03:19:15 +00:00
Duncan P. N. Exon Smith d1a3bebeeb PGO: Use past-the-end semantics for pointer range
llvm-svn: 204278
2014-03-19 22:45:28 +00:00
Duncan P. N. Exon Smith fb4447688f PGO: Appease buildbots after r204268
llvm-svn: 204276
2014-03-19 22:28:32 +00:00
Duncan P. N. Exon Smith 8353a26e85 PGO: Splitting implementation files; no functionality change
Split implementation files along a uses-libc/shouldn't-use-libc
boundary.

  - InstrProfiling.h is a shared header.

  - InstrProfiling.c provides an API to extract profiling data from the
    runtime, but avoids the use of libc.  Currently this is a lie:
    __llvm_pgo_write_buffer() uses `FILE*` and related functions.  It
    will be updated soon to write to a `char*` buffer instead.

  - InstrProfilingExtras.c provides a more convenient API for
    interfacing with the profiling runtime, but has logic that does (and
    will continue to) use libc.

<rdar://problem/15943240>

llvm-svn: 204268
2014-03-19 22:10:27 +00:00
Duncan P. N. Exon Smith 61c97335c6 PGO: Fix obviously wrong typedefs for MS
llvm-svn: 204267
2014-03-19 22:10:24 +00:00
Joerg Sonnenberger 0883e48f7e Sort. Fix missing NetBSD.
llvm-svn: 204249
2014-03-19 16:06:36 +00:00
Alexey Samsonov a7b8472397 One more attempt to fix Makefile build
llvm-svn: 204241
2014-03-19 15:26:54 +00:00
Dmitry Vyukov 1af191e1f4 tsan: add test for second_deadlock_stack flag
llvm-svn: 204240
2014-03-19 15:00:38 +00:00
Alexey Samsonov 725122eca3 [Make] Build sanitizer runtimes with -std=c++11
llvm-svn: 204239
2014-03-19 14:50:10 +00:00
Alexey Samsonov a2fdd8e253 [CMake] Fix build of ASan tests on Mac
llvm-svn: 204238
2014-03-19 14:45:40 +00:00
Kostya Serebryany 78f2e7bd62 [sanitizer] use some c++11 to simplify the code (we can now). Fix one place where a mutex acquisition stack trace was not properly remembered
llvm-svn: 204237
2014-03-19 14:19:31 +00:00
Alexey Samsonov 17703c1092 [CMake] Build sanitizer unit tests with -std=c++11
llvm-svn: 204234
2014-03-19 13:57:33 +00:00
Kostya Serebryany 2483acce21 [sanitizer] when recycling deadlock graph nodes, properly recycle edges
llvm-svn: 204233
2014-03-19 13:53:37 +00:00
Dmitry Vyukov cc579aeba6 tsan: use attribute instead of compiler flag for tls-model=initial-exec as asked in comments for r203111
llvm-svn: 204232
2014-03-19 13:24:52 +00:00
Dmitry Vyukov ecc3456fd6 tsan: fix copy-pasted comment
llvm-svn: 204231
2014-03-19 13:19:39 +00:00
Evgeniy Stepanov a57750482f [msan] Fix line numbers in test.
This corresponds to a fix in llvm::SplitBlockAndInsertIfThen.

llvm-svn: 204229
2014-03-19 12:56:38 +00:00
Dmitry Vyukov bbbe6bba8a tsan: preliminary support for Go deadlock detector
llvm-svn: 204228
2014-03-19 12:50:47 +00:00
Dmitry Vyukov 17efa197bf tsan: fix large stack frame in deadlock detector
In member function 'virtual void __sanitizer::DD::MutexBeforeLock(__sanitizer::DDCallback*, __sanitizer::DDMutex*, bool)':
error: the frame size of 544 bytes is larger than 512 bytes [-Werror=frame-larger-than=]

The code is now [arguably] better as well.

llvm-svn: 204227
2014-03-19 12:49:46 +00:00
Kostya Serebryany 2ea796e05f [sanitizer] deadlock detector: a) initial support for suppressions, b) be more robust in case we failed to extract a stack trace for one of the locks
llvm-svn: 204225
2014-03-19 12:26:33 +00:00
Timur Iskhodzhanov 364b8b8fe5 [ASan] Print mmap errno/GetLastError in a readable and consistent way
Reviewed at http://llvm-reviews.chandlerc.com/D3107

llvm-svn: 204218
2014-03-19 08:23:00 +00:00
Joerg Sonnenberger 4e08a634e1 Don't take short cuts trying to avoid conditionals. This leads to
negative shift amounts and/or shifts wider than the type. VAX traps on
the former, X86 and other platforms produce incorrect results on the
latter.

llvm-svn: 204193
2014-03-18 22:10:36 +00:00
Justin Bogner bc9c856161 profile: Include the function hash in PGO profiles
llvm-svn: 204185
2014-03-18 21:57:58 +00:00
Joerg Sonnenberger 14743127b7 Use CRT_HAS_128BIT.
llvm-svn: 204182
2014-03-18 21:35:30 +00:00
Joerg Sonnenberger bbc979be52 Spacing
llvm-svn: 204179
2014-03-18 20:41:31 +00:00
Sergey Matveev 34b26458cb [sanitizer] Fix a bug in AdjustStackSize().
If the user requests OS default stack size, do not adjust it to our minimum
stack size (which is usually much less than the OS default).

llvm-svn: 204173
2014-03-18 19:48:48 +00:00
Dmitry Vyukov c5b7c66bc3 tsan: fix malloc/munmap mismatch
llvm-svn: 204154
2014-03-18 14:28:17 +00:00
Evgeniy Stepanov 412d973980 [msan] Origin tracking with history, compiler-rt part.
Compiler-rt part of MSan implementation of advanced origin tracking,
when we record not only creation point, but all locations where
an uninitialized value was stored to memory, too.

llvm-svn: 204152
2014-03-18 13:45:19 +00:00
Dmitry Vyukov 3cd028c0b2 tsan: deadlock detector: add deadlock detector flags
the first flags is to enable printing of the second stack per edge

llvm-svn: 204150
2014-03-18 13:13:47 +00:00
Dmitry Vyukov b72bc2ec9c tsan: deadlock detector: print 2 stacks per deadlock edge
llvm-svn: 204149
2014-03-18 12:53:05 +00:00
Dmitry Vyukov 7fbceb2a3f tsan: addrhashmap: fix bug with initialization of addresses in add array
llvm-svn: 204148
2014-03-18 12:52:11 +00:00
Dmitry Vyukov 17fff3268d tsan: deadlock detector: add ability to ignore destruction of global mutexes
llvm-svn: 204146
2014-03-18 12:50:41 +00:00
Alexey Samsonov bcce1979e3 [CMake] Build compiler-rt libraries with -std=c++11
llvm-svn: 204145
2014-03-18 12:49:22 +00:00
Dmitry Vyukov 9e5341d64a tsan: lazily initialize deadlock detector runtime
this is necessaary because dlsym can call malloc, which can lock mutexes that we intercept

llvm-svn: 204141
2014-03-18 11:23:51 +00:00
Alexey Samsonov f88f317d35 Fix -Werror build
llvm-svn: 204139
2014-03-18 11:17:01 +00:00
Evgeniy Stepanov 0b5b3295e5 Move Android ucontext.h out of third_party.
Google is re-licensing this code under the standard dual license of
compiler-rt.

llvm-svn: 204128
2014-03-18 08:32:14 +00:00
Dmitry Vyukov 3458425d81 tsan: support up to 1<<20 mutexes in standalone deadlock detector
llvm-svn: 204127
2014-03-18 08:31:11 +00:00
Dmitry Vyukov a3b21b1d14 tsan: better addr->object hashmap
still experimental

llvm-svn: 204126
2014-03-18 08:30:14 +00:00
Dmitry Vyukov 24c833e1a4 tsan: add missing interceptor for embed symbolizer
llvm-svn: 204124
2014-03-18 08:28:39 +00:00
Dmitry Vyukov eac8cc7a42 tsan: fix flaky test
llvm-svn: 204119
2014-03-18 06:37:31 +00:00