Commit Graph

3519 Commits

Author SHA1 Message Date
Evgeniy Stepanov a6eb1bb59e [sanitizer] Intercept __bzero on Mac.
This should make memset_test pass on Mac.

llvm-svn: 204929
2014-03-27 14:20:34 +00:00
Evgeniy Stepanov 1189734413 [sanitizer] Fix Android build.
llvm-svn: 204927
2014-03-27 14:06:15 +00:00
Evgeniy Stepanov 89602651e8 [msan] Implement __msan_set_death_callback.
llvm-svn: 204926
2014-03-27 14:04:58 +00:00
Timur Iskhodzhanov e6303d1224 Add support for _expand[_dbg] so we don't crash when _aligned_* allocation functions are used
llvm-svn: 204925
2014-03-27 14:01:11 +00:00
Evgeniy Stepanov 9dcd5a353a [msan] Intercept several malloc-related functions.
llvm-svn: 204923
2014-03-27 13:29:29 +00:00
Kostya Serebryany 88d0eac412 [asan] Do not sanitize kernel area on 32-bit targets, patch by Yuri Gribov
llvm-svn: 204897
2014-03-27 07:36:26 +00:00
Peter Collingbourne 5d167dae7d Add function to get the number of DFSan labels allocated.
Expose the number of DFSan labels allocated by adding function dfsan_get_label_count().

Patch by Sam Kerner!

Differential Revision: http://llvm-reviews.chandlerc.com/D3109

llvm-svn: 204854
2014-03-26 21:09:53 +00:00
Rafael Espindola 5e46070516 Avoid aliases to weak aliases in interceptors.
The interceptors had code that after macro expansion ended up looking like

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("memalign")));

That is,
* __interceptor_memalign is a function
* memalign is a weak alias to __interceptor_memalign
* __interceptor___libc_memalign is an alias to memalign

Both gcc and clang produce assembly that look like

__interceptor_memalign:
...
        .weak   memalign
memalign = __interceptor_memalign
        .globl  __interceptor___libc_memalign
__interceptor___libc_memalign = memalign

What it means in the end is that we have 3 symbols pointing to the
same position in the file, one of which is weak:

     8: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor_memalign
     9: 0000000000000000     1 FUNC    WEAK   DEFAULT    1 memalign
    10: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor___libc_memalign

In particular, note that __interceptor___libc_memalign will always
point to __interceptor_memalign, even if we do link in a strong symbol
for memalign. In fact, the above code produces exactly the same binary
as

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("__interceptor_memalign")));

If nothing else, this patch makes it more obvious what is going on.

llvm-svn: 204823
2014-03-26 15:48:59 +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
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 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