Commit Graph

6247 Commits

Author SHA1 Message Date
Xinliang David Li b83ab8508e Speculatively fix MIPS build bot failures
MIPS build bots failed due to lack of 64bit atomic operations.
The fix is to disable VP for MIPS target until a better solution
is found.

llvm-svn: 253687
2015-11-20 18:31:45 +00:00
Alexey Samsonov 3e49a7bc32 [TSan] Fix custom scripts that validate TSan on non-standard buildbot.
llvm-svn: 253682
2015-11-20 18:13:03 +00:00
Reid Kleckner fad356c4ac Speculativley try to fix FreeBSD buildbots, which apparently cannot use stdint.h
llvm-svn: 253681
2015-11-20 18:11:50 +00:00
Hans Wennborg 43db5b7daa Disable the cfi tests on Windows
They are currently broken and there seems to be no bot coverage
for this configuration so it's essentially unspported.

llvm-svn: 253673
2015-11-20 16:29:53 +00:00
Kuba Brecka 1f73ba6053 [sanitizer] Implement internal_fork and internal_forkpty for OS X
On Linux, we have internal_fork that forks without invoking user's pthread_atfork handlers, which is important for spawning external symbolizers. Let's implement this for OS X as well (using __fork). This patch also adds internal_forkpty which re-implements forkpty and uses __fork in it as well.

Differential Revision: http://reviews.llvm.org/D14869

llvm-svn: 253666
2015-11-20 14:28:33 +00:00
Kuba Brecka e08533577f [tsan] Replace POSIX semaphores with pthread condition variables in vptr_benign_race.cc
OS X doesn't support POSIX semaphores (but it does have the API for it, which returns ENOSYS - "Function not implemented").

Differential Revision: http://reviews.llvm.org/D14865

llvm-svn: 253665
2015-11-20 14:17:43 +00:00
Kuba Brecka 1a26ff7d17 [tsan] Fix deadlock_detector_stress_test.cc testcase for OS X
On OS X, we don't have pthread spinlocks, let's just use a regular mutex instead. Secondly, pthread_rwlock_t is much larger (200 bytes), so `char padding_[64 - sizeof(pthread_rwlock_t)]` actually underflows.

Differential Revision: http://reviews.llvm.org/D14862

llvm-svn: 253659
2015-11-20 11:13:36 +00:00
Kuba Brecka 8aa56d3cc8 [tsan] Make tests that use CLOCK_MONOTONIC portable
Several tests rely on CLOCK_MONOTONIC, which doesn't exist on OS X. This patch fixes these tests by either disabling them (in case of cond_version.c which doesn't make sense on OS X), or by porting the test to also work on OS X.

Differential Revision: http://reviews.llvm.org/D14861

llvm-svn: 253658
2015-11-20 11:07:16 +00:00
George Burgess IV 362352c6be Attempt to fix build breakage caused by r253646.
Apparently check_c_compiler_flag isn't a thing everywhere. Not being
incredibly well-versed in cmake, I'm hoping that check_cxx_compiler_flag
serves a similar purpose. :)

llvm-svn: 253648
2015-11-20 05:02:08 +00:00
George Burgess IV b47c02f39b Silence "unrecognised -std=c99" warning on MSVC.
Thanks to angelsl for the patch!

Differential Revision: http://reviews.llvm.org/D13692

llvm-svn: 253646
2015-11-20 03:37:12 +00:00
Alexey Samsonov 145e4d6471 Tell clang-format that (most) sanitizers are written using Google style guide.
llvm-svn: 253608
2015-11-19 22:11:10 +00:00
Kuba Brecka c7157bfd55 [tsan] Replace new/delete with a local variable in ThreadSpecificDtors unit test
On OS X, this unit test (ThreadSpecificDtors) fails, because the new and delete operators actually call the overridden operators, which end up using TLVs and crash. Since C++'s new and delete is not important in this test, let's just replace them with a local variable. This fixes the test on OS X.

Differential Revision: http://reviews.llvm.org/D14826

llvm-svn: 253583
2015-11-19 17:50:07 +00:00
Kuba Brecka 153594694b [tsan] Implement "%env_tsan_opts" substitution to inherit default TSAN_OPTIONS
We already have %env_asan_opts for ASan, let's implement the same for TSan.

Differential Revision: http://reviews.llvm.org/D14698

llvm-svn: 253579
2015-11-19 17:28:46 +00:00
Alexey Samsonov 89d7ff5de6 [LSan] Fix tests with some libstdc++ implementations.
Summary:
Newer libstdc++ has global pool, which is filled with objects
allocated during libstdc++ initialization, and never released.
Using use_globals=0 in the lit tests results in these objects
being treated as leaks.

Fix this by porting several tests to plain C, and introducing
a simple sanity test case for __lsan::ScopedDisabler.

Reviewers: kcc, ygribov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D14798

llvm-svn: 253576
2015-11-19 17:18:02 +00:00
Kuba Brecka f503d51e5b [tsan] For OS X thread finalization, remove g_thread_finalize_key in favor of libpthread hooks
On OS X, the thread finalization is fragile due to thread-local variables destruction order. I've seen cases where the we destroy the ThreadState too early and subsequent thread-local values' destructors call interceptors again. Let's replace the TLV-based thread finalization method with libpthread hooks. The notification PTHREAD_INTROSPECTION_THREAD_TERMINATE is called *after* all TLVs have been destroyed.

Differential Revision: http://reviews.llvm.org/D14777

llvm-svn: 253560
2015-11-19 12:06:20 +00:00
Kuba Brecka 9eb6df9f1e [tsan] Recognize frames coming from "libclang_rt.tsan_*" module as internal
On OS X, we build a dylib of the TSan runtime, which doesn't necessarily need to contain debugging symbols (and file and line information), so llvm-symbolizer might not be able to find file names for TSan internal frames.  FrameIsInternal currently only considers filenames, but we should simply treat all frames within `libclang_rt.tsan_osx_dynamic.dylib` as internal.  This patch treats all modules starting with `libclang_rt.tsan_` as internal, because there may be more runtimes for other platforms in the future.

Differential Revision: http://reviews.llvm.org/D14813

llvm-svn: 253559
2015-11-19 12:03:48 +00:00
Kuba Brecka 6e90edf803 [tsan] Mark tests that need pthread barriers with "UNSUPPORTED: darwin"
Several testcases need pthread barriers (e.g. all bench_*.cc which use test/tsan/bench.h) which are not available on OS X. Let's mark them with "UNSUPPORTED: darwin".

Differential Revision: http://reviews.llvm.org/D14636

llvm-svn: 253558
2015-11-19 12:02:02 +00:00
Kuba Brecka efd92b3d16 [tsan] Handle dispatch_once on OS X
Reimplement dispatch_once in an interceptor to solve these issues that may produce false positives with TSan on OS X:

1) there is a racy load inside an inlined part of dispatch_once,
2) the fast path in dispatch_once doesn't perform an acquire load, so we don't properly synchronize the initialization and subsequent uses of whatever is initialized,
3) dispatch_once is already used in a lot of already-compiled code, so TSan doesn't see the inlined fast-path.

This patch uses a trick to avoid ever taking the fast path (by never storing ~0 into the predicate), which means the interceptor will always be called even from already-compiled code. Within the interceptor, our own atomic reads and writes are not written into shadow cells, so the race in the inlined part is not reported (because the accesses are only loads).

Differential Revision: http://reviews.llvm.org/D14811

llvm-svn: 253552
2015-11-19 10:35:35 +00:00
Yury Gribov dd679b334b [asan] Enable halt_on_error tests on ARM targets.
Differential Revision: http://reviews.llvm.org/D14751

llvm-svn: 253549
2015-11-19 08:36:26 +00:00
Xinliang David Li e8efaeae4d [PGO] Minor cleanups (from review feedback)
1. fix naming problem of file/buffer writer
2. change BufferOrFile to WriterCtx
3. move writer and writerctx together

llvm-svn: 253545
2015-11-19 07:21:47 +00:00
Reid Kleckner 4029426b17 [msan] Don't unpoison phdrs on dlopen(NULL, 0)
Summary:
dlopen(NULL, ...) is intended to give you back a handle to the
executable for use with dlsym. Casting it to link_map and using it with
ForEachMappedRegion results in a crash.

We also shouldn't unpoison the globals of a DSO that is already in
memory. This ensures that we don't do it for the executable, but in
general, MSan may have false negatives if the DSO is already loaded.

Reviewers: eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D14795

llvm-svn: 253530
2015-11-19 00:55:45 +00:00
Xinliang David Li b035bd03e4 Fix format in comments.
llvm-svn: 253510
2015-11-18 22:09:41 +00:00
Xinliang David Li c5c32cbec2 [PGO] Minor cleanups (formating, comments etc) (NFC)
1. Added missing public API decl in InstrProfiling.h
2. Clang formatting fix
3. Added more comments for new VP code
4. refactor the VP allocation code to make it more readable.

llvm-svn: 253508
2015-11-18 21:54:40 +00:00
Mike Aizatsky b2c5e1b263 Removing memory leak to appease windows bots.
Differential Revision: http://reviews.llvm.org/D14785

llvm-svn: 253507
2015-11-18 21:44:33 +00:00
Xinliang David Li 6e55716509 Fix format of previous patch (NFC)
llvm-svn: 253503
2015-11-18 21:11:46 +00:00
Xinliang David Li 1d8d46ae39 [PGO] Refactor File and Buffer API profile writing code
With this change, Buffer API and File API implementations
are unified.

Differential Revision: http://reviews.llvm.org/D14692

llvm-svn: 253500
2015-11-18 21:08:03 +00:00
Mike Aizatsky 52025af820 Disable gvn non-local speculative loads under asan.
Summary: Fix for https://llvm.org/bugs/show_bug.cgi?id=25550

Differential Revision: http://reviews.llvm.org/D14764

llvm-svn: 253499
2015-11-18 20:43:20 +00:00
Xinliang David Li 13cd7f3cf7 Fix for loop initial decl used outside c99 mode error
llvm-svn: 253496
2015-11-18 20:20:15 +00:00
Betul Buyukkurt e7891d033e [PGO] Fix the build failures due to 253483 and 253489.
llvm-svn: 253492
2015-11-18 19:39:20 +00:00
Betul Buyukkurt b8dc674f65 [PGO] Removed an extra ')' in the LLVM_ALIGNAS(x) macro.
llvm-svn: 253489
2015-11-18 19:11:31 +00:00
Betul Buyukkurt 808385f1ae [PGO] Runtime support for value profiling.
This change adds extends the data structures and adds in the routines
for handling runtime calls for value profiling. The profile data format
is modified and the version number is incremented.

llvm-svn: 253483
2015-11-18 18:12:35 +00:00
Kuba Brecka b2b07aa925 [tsan] Skip malloc/free interceptors when we're inside symbolizer on OS X
Symbolizers can call malloc/realloc/free/..., which we don't want to intercept. This is already implemented on Linux, let's do it for OS X as well.

Differential Revision: http://reviews.llvm.org/D14710

llvm-svn: 253460
2015-11-18 14:50:40 +00:00
Yury Gribov 4c3baeb686 [asan] Use proper macro in runline.
llvm-svn: 253457
2015-11-18 13:38:45 +00:00
Alexey Samsonov 1f4cb4d3d4 [TSan] List only amd64 asm file in Makefile.old (attempt 2)
llvm-svn: 253416
2015-11-18 00:56:37 +00:00
Alexey Samsonov 3408ea64ed [TSan] List only amd64 asm file in Makefile.old
llvm-svn: 253407
2015-11-18 00:31:00 +00:00
Alexey Samsonov de6fb1d9c7 [ASan] Be consistent and refer to reported issues as "errors" in hints.
llvm-svn: 253406
2015-11-18 00:24:32 +00:00
Yury Gribov 6689df85ee [asan] Enable halt_on_error tests on OS X.
llvm-svn: 253342
2015-11-17 16:34:39 +00:00
Dmitry Vyukov 3dd7fe6d86 tsan: replace macro check with constant check
As per comments in 252892 commit.

llvm-svn: 253216
2015-11-16 15:55:38 +00:00
Adhemerval Zanella 2f7f5e3535 [compiler-rt] [tsan] Enable intercept setjmp/longjmp for AArch64
This patch adds assembly routines to enable setjmp/longjmp for aarch64
on linux.  It fixes:

 * test/tsan/longjmp2.cc
 * test/tsan/longjmp3.cc
 * test/tsan/longjmp4.cc
 * test/tsan/signal_longjmp.cc

I also checked with perlbench from specpu2006 (it fails to run
with missing setjmp/longjmp intrumentation).

llvm-svn: 253205
2015-11-16 13:55:19 +00:00
Yury Gribov bdf8751609 [asan] Restored asynch signal test.
llvm-svn: 253204
2015-11-16 13:54:32 +00:00
Kuba Brecka 04d512133f Reverting r253080 ([tsan] Don't demangle names not starting with "_Z").
This caused bot failures on ARM, e.g. http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9068

llvm-svn: 253129
2015-11-14 10:42:08 +00:00
Kostya Serebryany fb484cedb4 [asan] add an experimental flag protect_shadow_gap. If set to false, the shadow gap will not be mprotect-ed and all hell may break loose. But this makes CUDA's cuInit() pass.
llvm-svn: 253108
2015-11-14 00:50:23 +00:00
Xinliang David Li b6c81d2b92 [PGO] Ensure profile section symbols are created (linux)
- This is to handle a corner case where profile lib is linked
  in but non of the modules are instrumented (On linux, since
  we avoided the overhead to emit runtime hook use functions so
  this is the side effect of that size optimization).
- Added a profile runtime test case to cover all scenarios of
  shared library builds. 

Differential Revision: http://reviews.llvm.org/D14468

llvm-svn: 253098
2015-11-13 22:33:07 +00:00
Kuba Brecka 1f219dcb98 [tsan] Don't demangle names not starting with "_Z"
I noticed that when a symbol is named just "x", it gets demangled to "long long". On POSIX, AFAIK, mangled names always start with "_Z", so lets just require that.

Differential Revision: http://reviews.llvm.org/D14637

llvm-svn: 253080
2015-11-13 20:47:29 +00:00
Kuba Brecka 7291b88e9a [tsan] Fix finalization of detached threads on OS X
Currently, we crash on finalization of detached threads, because we'll try to clear the ThreadState twice.

Differential Revision: http://reviews.llvm.org/D14644

llvm-svn: 253079
2015-11-13 20:45:27 +00:00
Kuba Brecka d07e069d79 [tsan] Fix a typo in tsan_test_util.h
There is a typo in tsan_test_util.h, it shouldn't be `APPLE`, but `__APPLE__`.

Differential Revision: http://reviews.llvm.org/D14647

llvm-svn: 253078
2015-11-13 20:42:57 +00:00
Kuba Brecka 52d02ab9d9 [tsan] Expect memmove interceptor to be called from memcpy
On OS X, memcpy and memmove are actually aliases of the same function, so the memmove interceptor can be invoked on a call to memcpy. This patch updates the tests to expect either memmove or memcpy on a stack trace.

Differential Revision: http://reviews.llvm.org/D14638

llvm-svn: 253077
2015-11-13 20:41:37 +00:00
Kuba Brecka 6c0b367297 [tsan] Mark dl_iterate_phdr.cc test as unsupported on OS X
The dl_iterate_phdr is not present on OS X.

Differential Revision: http://reviews.llvm.org/D14643

llvm-svn: 253076
2015-11-13 20:40:02 +00:00
Kuba Brecka 770dac4382 [tsan] Don't require full paths to be present on stack traces
The OS X symbolizers (namely AtosSymbolizer) don't return full file paths, only file names. This patch modifies `mutexset*.cc` tests not to require a path to be present in the symbol on the stack trace.

Differential Revision: http://reviews.llvm.org/D14642

llvm-svn: 253075
2015-11-13 20:36:08 +00:00
Chris Bieneman 4f7f57e166 [CMake] [macho_embedded] [builtins] Always use OS X sysroot, even for arm.
Turns out that there are some checks in the backend that change code generation for armv7 if you are building against an iOS sys root. For the macho_embedded builtins we really don't want that.

llvm-svn: 253064
2015-11-13 19:14:58 +00:00