Commit Graph

6729 Commits

Author SHA1 Message Date
Daniel Sanders de098c9767 [compiler-rt] list_union() is actually an intersect operation. Rename it.
Summary:
Given:
  set(T1 a b c)
  set(T2 b c d)
  message("T1=${T1}")
  message("T2=${T2}")
  list_union(T3 T1 T2)
  message("T3=${T3}")
cmake emitted:
  T1=a;b;c
  T2=b;c;d
  T3=b;c

Reviewers: beanz

Subscribers: llvm-commits

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

llvm-svn: 258916
2016-01-27 09:28:01 +00:00
Xinliang David Li 0747c5c808 Fix a bug in test case (both ir,fe instr were turned on
llvm-svn: 258913
2016-01-27 07:42:41 +00:00
Xinliang David Li 763545c6d7 Sync up with master file
llvm-svn: 258890
2016-01-27 00:14:15 +00:00
Evgeniy Stepanov a25dde68d9 [cfi] Exclude __cfi_slowpath_diag from the non-diag rtl.
Calls to __cfi_slowpath_diag are only emitted when building with
diagnostics, and linking the diag rtl.

llvm-svn: 258881
2016-01-26 23:42:41 +00:00
Evgeniy Stepanov 40d7d02d3d [cfi] Better handling of wild target address.
This change enables diagnostics when the target address for a CFI
check is out of bounds of any known library, or even not in the
limits of the address space. This happens when casting pointers to
uninitialized memory.

Ubsan code does not yet handle some of these situations correctly,
so it is still possible to see a segmentation fault instead of a
proper diagnostic message once in a while.

llvm-svn: 258879
2016-01-26 23:36:28 +00:00
Mike Aizatsky abae3a44af [sanitizers] execve & waitpid on mac.
llvm-svn: 258874
2016-01-26 22:53:52 +00:00
Chris Bieneman 63a81b1415 Remove autoconf support for building runtime libraries.
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

    "I am the punishment of God... If [autoconf] had not committed great sins, God would not have sent a punishment like me upon [it]."
    -Genghis Khan

Reviewers: chandlerc, grosbach, bob.wilson, zaks.anna, kubabrecka, samsonov, echristo

Subscribers: iains, llvm-commits

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

llvm-svn: 258863
2016-01-26 21:31:12 +00:00
Evgeniy Stepanov 79685810f1 [cfi] Hide runtime implementation in a namespace.
Move all internal stuff into namespace __cfi.
Remove the double underscore prefix from anything that's now inside
the namespace.

llvm-svn: 258859
2016-01-26 21:06:26 +00:00
Evgeniy Stepanov a9e0584cce [cfi] Support for dlopen and dlclose.
Add dlopen/dlclose interceptors to update CFI shadow for loaded/unloaded libraries.

llvm-svn: 258857
2016-01-26 20:53:09 +00:00
Mike Aizatsky 4a93316c8c [sanitizers] extracted process management functions
Differential Revision: http://reviews.llvm.org/D16546

llvm-svn: 258849
2016-01-26 20:10:01 +00:00
Evgeniy Stepanov 226965259d [cfi] Cross-DSO CFI diagnostic mode (compiler-rt part)
* add __cfi_slowpath_diag with a 3rd parameter which is a pointer to
  the diagnostic info for the ubsan handlers.
*__cfi_check gets a 3rd parameter as well.
* unify vcall/cast/etc and icall diagnostic info format, and merge
  the handlers to have a single entry point (actually two points due
  to abort/noabort variants).
* tests

Note that this comes with a tiny overhead in the non-diag mode:
cfi_slowpath must pass 0 as the 3rd argument to cfi_check.

llvm-svn: 258744
2016-01-25 23:34:38 +00:00
Bill Seurer 3108513a99 [powerpc] make test case as xfail
This test case which worked for a while is now failing again.  I was unable to
trace the change in status to any particular revision.

llvm-svn: 258739
2016-01-25 23:03:04 +00:00
Xinliang David Li 3aa113321b [PGO] Add a test case covering IR based VP instrumentation
llvm-svn: 258732
2016-01-25 22:33:29 +00:00
Xinliang David Li 19c45e2e12 [PGO] Add test case covering clang FE based VP instrumentation
llvm-svn: 258730
2016-01-25 22:09:30 +00:00
Xinliang David Li 2409d0ff06 sync up InstrProfData.h -- typo fix
llvm-svn: 258717
2016-01-25 20:38:40 +00:00
Mike Aizatsky 92f0f7c2f3 Revert "[sanitizers] extracted process management functions"
This reverts commit e5b34d5a2bf4c882bc647dd26a8cea2adc76f63c.

llvm-svn: 258713
2016-01-25 19:52:25 +00:00
Mike Aizatsky e71c99c7e2 fixed clang-tidy config
llvm-svn: 258711
2016-01-25 19:43:55 +00:00
Mike Aizatsky 53849fee26 [sanitizers] extracted process management functions
Differential Revision: http://reviews.llvm.org/D16542

llvm-svn: 258710
2016-01-25 19:43:52 +00:00
Evgeniy Stepanov 2531584daa [asan] Don't use sysconf(_SC_PAGESIZE) on Android.
This is broken in the current (post-MNC) master branch.
Use EXEC_PAGESIZE instead, the same as on x86 Linux.

This change fixes startup crashes in the existing tests on AOSP
master.

llvm-svn: 258706
2016-01-25 19:25:20 +00:00
Nico Weber 6a4e0dd1a6 When building without DIA SDK, don't set suppressions.cpp fail
This test requires llvm-symbolizer to be able to convert a stack
address into a function name.  It is only able to do this if the
DIA SDK was found at cmake time.  Add a lit feature for this,
and let the test depend on it.

See also discussion in D15363.

llvm-svn: 258545
2016-01-22 20:26:10 +00:00
Mike Aizatsky 6e9b970805 .clang-tidy for sanitizer package to override root llvm style
Summary:
sanitizer-common follows Google code style, override
clang-tidy config.

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

llvm-svn: 258449
2016-01-21 23:21:31 +00:00
Xinliang David Li 8b1f80779b Resubmit test case with more restriction
The original submittion triggered a BFD linker bug (2.24) on Aarch64 only. Before
the build bot is upgraded to more recent linker, restrict the test to be 
executed only with gold linker.

llvm-svn: 258437
2016-01-21 21:59:19 +00:00
Alexey Samsonov c8adcb4af6 [MSan] Add a test case for r258339.
llvm-svn: 258413
2016-01-21 17:51:08 +00:00
Alexey Samsonov 25f5913ddf [MSan] Clear parameters shadow before invoking malloc/free hooks.
MSan runtime is not itself instrumented, so we need to explicitly
clear shadow for function arguments before calling user-provided
functions from runtime (e.g. we already do this for several
interceptors).

I'm still crafting a test case that would demonstrate this issue
reliably, and will commit it later today.

llvm-svn: 258339
2016-01-20 19:56:04 +00:00
Kostya Serebryany af69f1c690 [asan] print an additional hint when reporting a container overflow
llvm-svn: 258337
2016-01-20 19:49:12 +00:00
Renato Golin 533c32bdda Revert "[coverage] Add a test case to cover coverage testing with comdat"
This reverts commit r258255 and r258274, as it was breaking the AArch64 bot.

llvm-svn: 258314
2016-01-20 14:27:50 +00:00
Vedant Kumar 0b9df44cf1 [test] Add a short explanation to instrprof-comdat.h
llvm-svn: 258274
2016-01-20 02:31:25 +00:00
Xinliang David Li 6900596040 [coverage] Add a test case to cover coverage testing with comdat
llvm-svn: 258255
2016-01-20 00:11:36 +00:00
Mike Aizatsky 7d866cb145 using const instead of constexpr: MSVC troubles
llvm-svn: 258253
2016-01-19 23:46:27 +00:00
Mike Aizatsky dba78e676f [sancov] NFC: simplifying DumpOffsets.
Summary: Extracting GetRangeOffset function before report-on-dump
functionality.

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

llvm-svn: 258211
2016-01-19 22:47:38 +00:00
Nico Weber 72f564f818 Fix another -Wexpansion-to-defined warning in compiler-rt.
llvm-svn: 258202
2016-01-19 22:07:55 +00:00
Nico Weber 82210fbc1e Fix -Wexpansion-to-defined warnings in compiler-rt.
llvm-svn: 258200
2016-01-19 22:02:12 +00:00
Dmitry Vyukov f8f2d46002 tsan: add back __tls_get_addr interceptor
Removal of the interceptor broke libtsan interface in gcc:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68824
Add back a simple interceptor.

llvm-svn: 258119
2016-01-19 12:28:00 +00:00
Maxim Ostapenko 1965cc6258 [asan] Optionally print reproducer cmdline in ASan reports.
Differential Revision: http://reviews.llvm.org/D16070

llvm-svn: 258037
2016-01-18 07:55:12 +00:00
Yabin Cui f7ebaf889a [tsan] Do nothing in ScopedInterceptor's destructor if thr is not inited.
Summary:
It is part of http://reviews.llvm.org/D15301, but missed when I committed
that patch.

Reviewers: kubabrecka, kcc, eugenis, llvm-commits, dvyukov

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

llvm-svn: 258021
2016-01-17 21:33:42 +00:00
Peter Collingbourne f5571f5248 Fix stats.cpp test on 32-bit Windows.
llvm-svn: 257981
2016-01-16 02:08:55 +00:00
Peter Collingbourne d73cd4ab01 Attempt to fix sanitizer-windows bot.
llvm-svn: 257978
2016-01-16 01:15:19 +00:00
Alexey Samsonov 95cd990588 [LSan] Ignore all allocations made inside pthread_create.
Thread stack/TLS may be stored by libpthread for future reuse after
thread destruction, and the linked list it's stored in doesn't
even hold valid pointers to the objects, the latter are calculated
by obscure pointer arithmetic.

With this change applied, LSan test suite passes with
"use_ld_allocations" flag defaulted to "false". It still requires more
testing to check if the default can be switched.

llvm-svn: 257975
2016-01-16 00:57:25 +00:00
Peter Collingbourne 5788e1259b Introduce stats and stats_client libraries.
This is part of a new statistics gathering feature for the sanitizers.
See clang/docs/SanitizerStats.rst for further info and docs.

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

llvm-svn: 257972
2016-01-16 00:31:29 +00:00
Nico Weber 230af4047d Re-disable suppressions.cpp on Windows.
See discussion in http://reviews.llvm.org/D15363

llvm-svn: 257952
2016-01-15 23:19:39 +00:00
Yabin Cui 19e8c0e2f7 [tsan] Fix some tiny errors.
Summary:
1. Fix spell error for sigaction.
2. Make line_length <= 80.

Reviewers: llvm-commits, eugenis, kcc, dvyukov

Subscribers: tberghammer, danalbert, srhines

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

llvm-svn: 257872
2016-01-15 06:21:46 +00:00
Yabin Cui bd3a772e9f [tsan] Store the pointer to ThreadState in TLS slot on Android.
Summary:
1. Android doesn't support __thread keyword. So allocate ThreadState
dynamically and store its pointer in one TLS slot provided by Android.
2. On Android, intercepted functions can be called before ThreadState
is initialized. So add test of thr_->is_inited in some places.
3. On Android, intercepted functions can be called after ThreadState
is destroyed. So add a fake dead_thread_state to represent all
destroyed ThreadStates. And that is also why we don't store the pointer
to ThreadState in shadow memory of pthread_self().

Reviewers: kcc, eugenis, dvyukov

Subscribers: kubabrecka, llvm-commits, tberghammer, danalbert, srhines

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

llvm-svn: 257866
2016-01-15 03:39:04 +00:00
Yabin Cui 66e5db99b3 [tsan] Use internal_sigfillset to replace REAL(sigfillset).
Summary:
Android doesn't intercept sigfillset, so REAL(sigfillset) is null.
And we can use internal_sigfillset() for all cases.

Reviewers: kcc, eugenis, kubabrecka, dvyukov

Subscribers: llvm-commits, tberghammer, danalbert

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

llvm-svn: 257862
2016-01-15 02:59:23 +00:00
Peter Collingbourne d2f24b62b5 Unbreak Windows build.
llvm-svn: 257860
2016-01-15 02:51:26 +00:00
Peter Collingbourne b825bf32b7 sanitizer_common: C++ify the IntrusiveList iterator interface.
llvm-svn: 257858
2016-01-15 02:19:20 +00:00
Alexey Samsonov 1f242d6a77 [LSan] Add "use_ld_allocations" flag to disable old way of DTLS handling.
This flag allows to disable old way of determining dynamic TLS by
filtering out allocations from dynamic linker. This will be eventually
superseded by __tls_get_addr interceptor (see r257785), after we:
1) Test it in several supported environments
2) Deal with existing problems (currently we can't find a pointer to
  DTV which is calloc()-ed in pthread_create).

llvm-svn: 257789
2016-01-14 19:16:05 +00:00
Alexey Samsonov 5535c51606 [LSan] Use __tls_get_addr interceptor to keep track of dynamic TLS.
Summary:
We have a way to keep track of allocated DTLS segments: let's use it
in LSan. Although this code is fragile and relies on glibc
implementation details, in some cases it proves to be better than
existing way of tracking DTLS in LSan: marking as "reachable" all
memory chunks allocated directly by "ld".

The plan is to eventually get rid of the latter, once we are sure
it's safe to remove.

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 257785
2016-01-14 18:50:09 +00:00
Sumanth Gundapaneni b76bf106b1 Fix the cross compilation of unit tests. NFC (second attempt)
With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compiling
environment, the unit tests fail to link. This patch does the following changes

>Rename COMPILER_RT_TEST_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS to reflect the 
way it's used.
>Add COMPILER_RT_TEST_COMPILER_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS so 
that cross-compiler would be able to build/compile the unit tests
>Add COMPILER_RT_UNITTEST_LINKFLAGS to COMPILER_RT_UNITTEST_CFLAGS so 
that cross-compiler would be able to link the unit tests (if needed)

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

llvm-svn: 257783
2016-01-14 18:18:49 +00:00
Xinliang David Li 944cd4d318 [Coverage] add test cases for coverage testing
1. One test covering coverage-mapping interfaction with linker GC
2. one test covering coverage-mapping with shared libaries

llvm-svn: 257782
2016-01-14 18:15:54 +00:00
Kuba Brecka 0626dd0d3b [tsan] Introduce a "ignore_interceptors_accesses" option
On OS X, TSan already passes all unit and lit tests, but for real-world applications (even very simple ones), we currently produce a lot of false positive reports about data races. This makes TSan useless at this point, because the noise dominates real bugs. This introduces a runtime flag, "ignore_interceptors_accesses", off by default, which makes TSan ignore all memory accesses that happen from interceptors. This will significantly lower the coverage and miss a lot of bugs, but it eliminates most of the current false positives on OS X.

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

llvm-svn: 257760
2016-01-14 12:24:37 +00:00
Kuba Brecka 9f5fde7081 [tsan] Fix the value of PTHREAD_MUTEX_RECURSIVE for OS X and FreeBSD
The value of the constant PTHREAD_MUTEX_RECURSIVE is not "1" on FreeBSD and OS X.

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

llvm-svn: 257758
2016-01-14 12:12:58 +00:00
Xinliang David Li c6615cdce5 sync up with master file
llvm-svn: 257746
2016-01-14 06:23:53 +00:00
Alexey Samsonov 38b3130c7a [Sanitizer] Pass proper values to DTLS_on_libc_memalign.
Fix a surprising typo: the old code used to think that dynamic TLS
segments were several times larger than they actually are.

llvm-svn: 257722
2016-01-14 00:04:37 +00:00
Hans Wennborg 7b9d2b6c87 Revert r257686 "With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compiling"
This broke the build. For example, from
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/1191/steps/cmake%20stage%201/logs/stdio:

	-- Compiler-RT supported architectures: aarch64
	CMake Error at projects/compiler-rt/cmake/Modules/AddCompilerRT.cmake:170 (string):
		string sub-command REPLACE requires at least four arguments.
	Call Stack (most recent call first):
		projects/compiler-rt/lib/CMakeLists.txt:4 (include)

llvm-svn: 257694
2016-01-13 22:50:24 +00:00
Sumanth Gundapaneni 2d2f2b5c80 With COMPILER_RT_INCLUDE_TESTS turned ON and in a cross compiling
environment, the unit tests fail to link. This patch does the following changes

>Rename COMPILER_RT_TEST_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS to reflect the 
way it's used.
>Add COMPILER_RT_TEST_COMPILER_CFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that 
cross-compiler would be able to build/compile the unit tests
>Add COMPILER_RT_UNITTEST_LINKFLAGS to COMPILER_RT_UNITTEST_CFLAGS so that 
cross-compiler would be able to link the unit tests (if needed)

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

llvm-svn: 257686
2016-01-13 22:09:47 +00:00
Dan Gohman 746cd84e3c [WebAssembly] Enable the builtins library for WebAssembly.
llvm-svn: 257619
2016-01-13 16:56:15 +00:00
Dan Gohman 01731fc150 [WebAssembly] clang supports int128_t on wasm32 in addition to wasm64.
llvm-svn: 257618
2016-01-13 16:47:51 +00:00
Dmitry Vyukov 529b940a77 tsan: check errors in test
Somebody reported flakiness of this test.
Let's start by checking errors.

llvm-svn: 257585
2016-01-13 10:14:05 +00:00
Chris Bieneman 1a4ae60f5a [CMake] Adding experimental support for tvOS and watchOS
Summary:
* Refactored the iOS config-ix.cmake code to be a more compact loop over supported embedded platforms.
* Added watchOS and tvOS as experimental platforms, they don't currently build so they are disabled by default

Reviewers: zaks.anna, kubabrecka, samsonov

Subscribers: llvm-commits

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

llvm-svn: 257544
2016-01-12 23:51:03 +00:00
Adhemerval Zanella c52448872b [compiler-rt] [msan] Remove stable-runtime requirement for insertvalue_origin.cc
This patch removes the requirement on stable-runtime on insertvalue_origin.cc
testcase, added due a instrumentation failure on aarch64-linux. This is fixed
on llvm code by r257375.

llvm-svn: 257479
2016-01-12 15:16:34 +00:00
Xinliang David Li 31ad54298e [PGO] Add Linux specific test cases for profile runtime
(second try with more strict config check)
Currently, only gc-sections related tests are added. Gold
linker currently is required due to PR19161 of bfd linker.

llvm-svn: 257456
2016-01-12 07:18:53 +00:00
Xinliang David Li 452f1a5576 Revert r257444 : arm build bots failure
llvm-svn: 257446
2016-01-12 05:39:26 +00:00
Xinliang David Li cfefae8a14 [PGO] Add Linux specific test cases for profile runtime
Currently, only gc-sections related tests are added. Gold
linker currently is required due to PR19161 of bfd linker.

llvm-svn: 257444
2016-01-12 04:54:24 +00:00
Xinliang David Li 385612c5b4 Fix comment of test
llvm-svn: 257443
2016-01-12 03:57:14 +00:00
Kostya Serebryany e3580956ea [libFuzzer] extend the weak memcmp/strcmp/strncmp interceptors to receive the result of the computations. With that, don't do any mutations if memcmp/etc returned 0
llvm-svn: 257423
2016-01-12 00:43:42 +00:00
Evgeniy Stepanov 6742d75952 [cfi] Fix __cfi_slowpath and __cfi_check signature.
The first argument is uint64_t, not uintptr_t.

llvm-svn: 257233
2016-01-08 23:42:30 +00:00
Xinliang David Li d85c32cdfa Fix typo in comment
llvm-svn: 257232
2016-01-08 23:42:28 +00:00
Xinliang David Li a692421adb [PGO] Add runtime hook so that IR instrumentation can override version
IR level instrumentation needs to override version with variant bits.
No change for FE instrumentation is needed. Test case is added to
detect version mismatch.

llvm-svn: 257230
2016-01-08 23:31:57 +00:00
Xinliang David Li f5a58834c1 [PGO] Introducing version mask macro/NFC (sync)
llvm-svn: 257225
2016-01-08 22:55:54 +00:00
Kostya Serebryany abc2c998d2 [tsan] don't crash on closedir(0)
llvm-svn: 257223
2016-01-08 22:48:19 +00:00
Evgeniy Stepanov cfe331042a Fix CMake warning in CFI tests.
CFI tests do not require the CFI runtime library on Windows.
Do not add "cfi" as a dependency of "check-cfi" in that case.

llvm-svn: 257202
2016-01-08 20:04:01 +00:00
Evgeniy Stepanov 6922ab1ff6 Revert "Fix CMake warning in CFI tests."
This is a bit more complex than that.

llvm-svn: 257201
2016-01-08 19:56:45 +00:00
Evgeniy Stepanov bec6f6b731 Fix CMake warning in CFI tests.
Fix incorrect condition for enabling the CFI tests. This removes the following CMake warnings on Windows:

The dependency target "cfi" of target "check-all" does not exist.
The dependency target "cfi" of target "check-cfi-and-supported" does not exist.

llvm-svn: 257199
2016-01-08 19:46:18 +00:00
Xinliang David Li bc1197e3ca Sync up InstrProfData.inc
llvm-svn: 257195
2016-01-08 19:22:05 +00:00
Nico Weber 2beaab358c Make ubsan suppression test pass on Windows.
llvm-svn: 257183
2016-01-08 17:26:03 +00:00
Xinliang David Li ec58c819fa Use more strict checks for merge Profile results
llvm-svn: 257151
2016-01-08 06:18:18 +00:00
Xinliang David Li bfb5d7c71b [PGO] Use new macro introduced/NFC
llvm-svn: 257147
2016-01-08 06:03:19 +00:00
Xinliang David Li 6d464151a6 [PGO] Update test to match sorted output
llvm-svn: 257146
2016-01-08 05:45:54 +00:00
Peter Collingbourne f6594a06f7 profile: Do not pass -fPIC on Windows.
Unbreaks clang-cl build (cl warns on this flag, clang-cl errors on it).

llvm-svn: 257136
2016-01-08 02:03:25 +00:00
Vedant Kumar 750a629555 [profile] Add comments to portability macros for readability (NFC)
llvm-svn: 257126
2016-01-08 00:49:34 +00:00
Xinliang David Li d2fb0f68f4 Sync up InstrProfData.inc
llvm-svn: 257124
2016-01-08 00:39:51 +00:00
Vedant Kumar b626231a50 [cmake] Indentation fix (NFC)
llvm-svn: 257118
2016-01-08 00:07:50 +00:00
Vedant Kumar c5b779cb92 [cmake] Add InstrProfilingWriter to libclang_rt on Darwin
llvmBufferWriter and a few related symbols were missing from libclang_rt
on Darwin (PR26002). This should fix the problem.

Patch by Dan Peebles!

llvm-svn: 257110
2016-01-07 22:54:46 +00:00
Xinliang David Li 911a4fb324 Sync up InstrProfData.inc file
llvm-svn: 257109
2016-01-07 22:47:04 +00:00
Dimitry Andric 6e8526358f Ensure safestack overflow test doesn't segfault
Summary:
In rL255491, the safestack overflow test was disabled for aarch64, since
it "is currently failing on an AArch64 buildbot with a segfault, but it
is currently passing on other configuration".

While testing on FreeBSD on x86, I also encountered a segfault.  This is
because the `fct()` function actually writes before and after `buffer`,
and on FreeBSD this crashes because `buffer` is usually allocated at the
end of a page.  That this runs correctly on Linux is probably just by
accident.

I propose to fix this by adding a pre and post buffer, to act as a
safety zone.  The pre and post buffers must be accessed in an 'unsafe'
way, otherwise -fsanitize=safestack will allocate them on the safe
stack, and they will not bookend `buffer` itself.  Therefore, I create
them large enough for `fct()`, and call it on both of them.

On FreeBSD, this makes the test run as expected, without segfaulting,
and I suppose this will also fix the segfault on AArch64.  I do not have
AArch64 testing capabilities, so if someone could try that out, I would
be much obliged.

Reviewers: pcc, kcc, zatrazz

Subscribers: llvm-commits, aemerson, emaste

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

llvm-svn: 257106
2016-01-07 22:19:12 +00:00
Kuba Brecka 490b7f8b6d Follow-up fix for r256988 to unbreak the Linux buildbot.
llvm-svn: 257042
2016-01-07 09:14:41 +00:00
Anna Zaks ef9a56faa0 [compiler-rt] On Darwin, link all frameworks with -fapplication-extension
The ASan dylib as well as other compiler-rt dylibs work with app extensions,
so we should add -fapplication-extension to the link line when building them.
This will avoid linker warnings when using the dylibs in app extensions.

(APIs unavailable to app extensions are listed here: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionOverview.html#//apple_ref/doc/uid/TP40014214-CH2-SW6)

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

llvm-svn: 256989
2016-01-06 23:15:04 +00:00
Anna Zaks 56c302fee6 [sanitizers] Log all output to CrashReport on OS X
Log all of sanitizers' output (not just ASan bug reports) to CrashReport,
which simplifies diagnosing failed checks as well as other errors. This
also allows to strip the color sequences early from the printed buffer,
which is more efficient than what we had perviously.

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

llvm-svn: 256988
2016-01-06 23:15:01 +00:00
Nathan Slingerland 2517253184 [compiler-rt] Fix empty translation unit warning
Change to not compile in WindowsMMap.c on anything except WIN32.

llvm-svn: 256947
2016-01-06 16:55:21 +00:00
Nathan Slingerland ba86c9279b [PGO] Enable building compiler-rt profile support library on Windows
Summary: This change configures Windows builds to build the complier-rt profile support library (clang_rt.profile-i386.lib). Windows API incompatibilities in the compiler-rt profile lib are also fixed.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

llvm-svn: 256848
2016-01-05 17:27:01 +00:00
Mike Aizatsky cc56ac3669 [sancov] adding internal function
llvm-svn: 256806
2016-01-05 02:09:54 +00:00
Mike Aizatsky 54fc6575c5 [sancov] coverage pc buffer
Differential Revision: http://reviews.llvm.org/D15871

llvm-svn: 256804
2016-01-05 01:49:39 +00:00
Xinliang David Li 74ec5db4bd [PGO] Sync up template file with master
llvm-svn: 256722
2016-01-04 01:22:55 +00:00
Xinliang David Li 4eb2cd64ff [PGO] Sync up template file with master
llvm-svn: 256711
2016-01-03 18:36:30 +00:00
Xinliang David Li 3e0e6e75d7 [PGO]: Eliminate custom typedefs in the FreeBSD case
Patch by: Sean Bruno 

Use o/s provided sys/types.h to bring in Profiling types.

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

llvm-svn: 256647
2015-12-30 19:18:55 +00:00
Xinliang David Li cda3bc2062 [PGO]: Refactor VP data writer
Extract the buffered filer writer code used by value profile 
writer and turn it into common/sharable buffered fileIO 
interfaces. Added a test case for the buffered file writer and
rewrite the VP dumping using the new APIs.

llvm-svn: 256604
2015-12-29 23:54:41 +00:00
Dimitry Andric 2d82f915c2 For the asan_symbolize.py script, use addr2line as the default system
symbolizer on FreeBSD too.  This allows the asan-symbolize-bad-path.cc
test to succeed.

llvm-svn: 256578
2015-12-29 21:36:34 +00:00
Xinliang David Li 54dd683726 [PGO]: Do not update Data->Value field during profile write.
The profile reader no longer depends on this field to be updated and point
to owning func's vp data. The VP data also no longer needs to be allocated
in a contiguous memory space.

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

llvm-svn: 256543
2015-12-29 07:13:59 +00:00
Xinliang David Li 69773fb0d2 Add more testing checks
llvm-svn: 256538
2015-12-29 06:42:12 +00:00
Xinliang David Li ebc4c25a50 [PGO] Make the test case more robust
Make the testing results not depending on function 
output order. This allows more strict result check.

llvm-svn: 256537
2015-12-29 06:28:44 +00:00
Xinliang David Li c30c88a240 Check test results more strictly (NFC)
llvm-svn: 256536
2015-12-29 06:26:43 +00:00
Bill Seurer 8a39ce8d32 [power] Fix test case target checks
Several test cases that used to fail on both power LE and BE
now run correctly on LE.

llvm-svn: 256391
2015-12-24 20:21:36 +00:00
Nico Weber 95ef4b3bf0 XFAIL ubsan suppressions.cpp test on Windows for now.
llvm-svn: 256307
2015-12-23 00:30:32 +00:00
Evgeniy Stepanov f02b782aa7 [cfi] Fix handling of uninstrumented libraries.
CFI shadow for non-CFI libraries should be "unchecked", not "invalid".

llvm-svn: 256285
2015-12-22 21:40:09 +00:00
Xinliang David Li baf55d8266 [PGO] Move buffer write callback to a common file
This is a NFC refactoring enabling code sharing by file writer.

llvm-svn: 256264
2015-12-22 18:57:15 +00:00
Nico Weber 6341a79387 fix a gcc warning
llvm-svn: 256256
2015-12-22 17:22:25 +00:00
Evgeniy Stepanov ed61ae6cde [asan] Add mincore test.
ASan does not really do anything interesting with mincore, but this
test verifies that the function still works correctly.

llvm-svn: 256207
2015-12-21 22:35:03 +00:00
Adhemerval Zanella b2910ea67e [compiler-rt] [tsan] Add support for PIE build on AArch64
This patch adds PIE executable support for aarch64-linux.  It adds
two more segments:

- 0x05500000000-0x05600000000: 39-bits PIE program segments
- 0x2aa00000000-0x2ab00000000: 42-bits PIE program segments

Fortunately it is possible to use the same transformation formula for
the new segments range with some adjustments in shadow to memory
formula (it adds a constant offset based on the VMA size).

A simple testcase is also added, however it is disabled on x86 due the
fact it might fail on newer kernels [1].

[1] https://git.kernel.org/linus/d1fd836dcf00d2028c700c7e44d2c23404062c90

llvm-svn: 256184
2015-12-21 19:27:57 +00:00
Kostya Serebryany 1d1be3dd88 [asan] fix fopen interceptor to not crash if path is NULL
llvm-svn: 256182
2015-12-21 19:22:26 +00:00
Xinliang David Li d1c84b078a [PGO] testing _WIN64 instead of _WIN32
llvm-svn: 256129
2015-12-20 19:55:15 +00:00
Xinliang David Li f82944db76 [PGO] Implement BOOL_CMPXCHG for Windows
llvm-svn: 256128
2015-12-20 19:11:44 +00:00
Xinliang David Li f48a1f54dd [PGO] Fix build failure with MSVC
llvm-svn: 256103
2015-12-19 19:16:32 +00:00
Alexey Samsonov 081a24e3a7 [UBSan] Implement runtime suppressions (PR25066).
Summary:
Add the ability to suppress UBSan reports for files/functions/modules
at runtime. The user can now pass UBSAN_OPTIONS=suppressions=supp.txt
with the contents of the form:

signed-integer-overflow:file-with-known-overflow.cpp
alignment:function_doing_unaligned_access
vptr:shared_object_with_vptr_failures.so

Suppression categories match the arguments passed to -fsanitize=
flag (although, see below). There is no overhead if suppressions are
not provided. Otherwise there is extra overhead for symbolization.

Limitations:
1) sometimes suppressions need debug info / symbol table to function
   properly (although sometimes frontend generates enough info to
   do the match).
2) it's only possible to suppress recoverable UB kinds - if you've
   built the code with -fno-sanitize-recover=undefined, suppressions
   will not work.
3) categories are fine-grained check kinds, not groups like "undefined"
   or "integer", so you can't write "undefined:file_with_ub.cc".

Reviewers: rsmith, kcc

Subscribers: cfe-commits

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

llvm-svn: 256018
2015-12-18 19:56:42 +00:00
Kuba Brecka 3aac36ad01 Revert r255996 ("[tsan] Add a DCHECK to verify __tsan_read* and __tsan_write function aren't called from ScopedInterceptor").
There are some test failures on the Linux buildbots.

llvm-svn: 255997
2015-12-18 13:52:08 +00:00
Kuba Brecka 15dd456236 [tsan] Add a DCHECK to verify __tsan_read* and __tsan_write function aren't called from ScopedInterceptor
Interceptors using ScopedInteceptor should never call into user's code before the ScopedInterceptor is out of scope (and its destructor is called). Let's add a DCHECK to enforce that.

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

llvm-svn: 255996
2015-12-18 13:08:15 +00:00
Kuba Brecka f9cc9d7392 [tsan] Fix scoping of ScopedInteceptor in libdispatch support
Some interceptors in tsan_libdispatch_mac.cc currently wrongly use TSAN_SCOPED_INTERCEPTOR/ScopedInterceptor. Its constructor can start ignoring memory accesses, and the destructor the stops this -- however, e.g. dispatch_sync can call user's code, so the ignoring will extend to user's code as well. This is not expected and we should only limit the scope of ScopedInterceptor to TSan code.  This patch introduces annotations that mark the beginning and ending of a callback into user's code.

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

llvm-svn: 255995
2015-12-18 11:16:24 +00:00
Xinliang David Li 01d06100dd Fix typo in MSC path
llvm-svn: 255938
2015-12-17 23:37:30 +00:00
Xinliang David Li abfd553c2b [PGO] cleanup: unify prefix for portability macros
llvm-svn: 255748
2015-12-16 03:29:15 +00:00
Evgeniy Stepanov 72b0111ce6 [cfi] Exclude ubsan runtime library from non-diag CFI builds.
Split the CFI runtime in two: cfi and cfi_diag. The latter includes
UBSan runtime to allow printing diagnostics.

llvm-svn: 255735
2015-12-16 00:38:41 +00:00
Evgeniy Stepanov 702a773988 [cfi] Fix GCC build.
llvm-svn: 255733
2015-12-16 00:34:30 +00:00
Evgeniy Stepanov 65c3a4b9c0 [cfi] Limit cross-dso tests to Linux.
Mac is missing the driver support to link the CFI runtime library.

llvm-svn: 255730
2015-12-16 00:24:18 +00:00
Evgeniy Stepanov b99d6c8b2a [cfi] Fix shadow sanity check.
The current check may break if the starting address in fill_shadow is
not page-aligned.

llvm-svn: 255725
2015-12-16 00:18:04 +00:00
Evgeniy Stepanov da1cf9287c Cross-DSO control flow integrity (compiler-rt part).
This is an initial version of the runtime cross-DSO CFI support
library.

It contains a number of FIXMEs, ex. it does not support the
diagnostic mode nor dlopen/dlclose, but it works and can be tested.
Diagnostic mode, in particular, would require some refactoring (we'd
like to gather all CFI hooks in the UBSan library into one function
so that we could easier pass the diagnostic information down to
__cfi_check). It will be implemented later.

Once the diagnostic mode is in, I plan to create a second test
configuration to run all existing tests in both modes. For now, this
patch includes only a few new cross-DSO tests.

llvm-svn: 255695
2015-12-15 23:00:33 +00:00
Xinliang David Li 1fbae3b76a [PGO] Improve prof library portability
Patch by: Johan Engelen

Introduce LLVM_LIBRARY_WEAK macro. Define LLVM_LIBRARY_WEAK
and LLVM_LIBRARY_VISIBIITY for MSVC

llvm-svn: 255688
2015-12-15 22:38:18 +00:00
Xinliang David Li be49271399 [PGO] Open file with explict binary mode
Patch by: Johan Engelen

On windows, opening in text mode will result in
line ending chars to be appended leading to
profile corruption.

llvm-svn: 255684
2015-12-15 22:18:11 +00:00
Kostya Serebryany 48b840dda1 [asan] try to fix ARM bots
llvm-svn: 255594
2015-12-15 01:05:35 +00:00
Kostya Serebryany 354bbb2ccd [asan] add option: handle_sigill
llvm-svn: 255588
2015-12-15 00:33:45 +00:00
Evgeniy Stepanov 04621bd888 [msan] Intercept ctermid, ctermid_r.
llvm-svn: 255566
2015-12-14 22:57:49 +00:00
Bill Schmidt e193989c17 [TSAN, PPC64] Fix obvious typo of supported virtual memory sizes
llvm-svn: 255507
2015-12-14 16:26:00 +00:00
Adhemerval Zanella ac764fabb8 [compiler-rt] [msan] Variadic support for AArch64
Now with variadic support for msan on aarch6 there is no need for
XFAIL signal_stress_test anymore.  Also to garantee aligned stores
for the FP/SIMD arguments enforce the '__msan_va_arg_tls' alignment
to sizeof the SIMD register (16).

llvm-svn: 255496
2015-12-14 14:15:32 +00:00
Kuba Brecka 2cdb522a5a [tsan] Update dispatch_group support to avoid using a disposed group object
We're using the dispatch group itself to synchronize (to call Release() and Acquire() on it), but in dispatch group notifications, the group can already be disposed/deallocated. This causes a later assertion failure at `DCHECK_EQ(*meta, 0);` in `MetaMap::AllocBlock` when the same memory is reused (note that the failure only happens in debug builds).

Fixing this by retaining the group and releasing it in the notification. Adding a stress test case that reproduces this.

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

llvm-svn: 255494
2015-12-14 13:32:57 +00:00
Adhemerval Zanella c974545cde [compiler-rt] [safestack] Silent overflow.c test on aarch64
The safestack overflow.c test is currently failing on an aarch64
buildbot with a segfault, but it is currently passing on other
configuration.

This patch silent the issue for now on aarch64 by setting to all
supported architectures the 'stable-runtime' configure and set
the test to requires it.

llvm-svn: 255491
2015-12-14 11:58:43 +00:00
Adhemerval Zanella eaf1162687 [compiler-rt] [safestack] Enable for aarch64
This patch enables the safestack for aarch64. The frontend already have
it enabled on all supported architectures and no adjustment is required
in llvm.

The compiler-rt adjustments are basically add on the cmake configuration
to enable the tests and fix the pagesize debug check by getting its
value at runtime (since aarch64 has multiple pagesize depending of
kernel configuration).

llvm-svn: 255345
2015-12-11 17:38:38 +00:00
Xinliang David Li dad2b8f79a [PGO] add a test case in profiler runtime
Add a test case to cover profile dumping of functions with no
value sites, functions with value sites but no dynamic VP data, 
and functions with runtime VP data.

llvm-svn: 255327
2015-12-11 05:43:55 +00:00
Xinliang David Li 449133d8b4 [PGO] Split value profiling runtime into its own file
Value profile runtime depends on libc which breaks
buffer API implemenation with current file organization.

Test case is also updated to check more symbols.

llvm-svn: 255294
2015-12-10 20:24:09 +00:00
Xinliang David Li 060037e0d2 Sync up with master
llvm-svn: 255293
2015-12-10 20:14:13 +00:00
Xinliang David Li 497c51cb8a [PGO] Move impl specific decl to InstrProfilingInternal.h (NFC)
llvm-svn: 255290
2015-12-10 19:50:04 +00:00
Alexey Samsonov c63c0d1cc0 [TSan] Try harder to avoid compiler-generated memcpy calls.
check_memcpy test added in r254959 fails on some configurations due to
memcpy() calls inserted by Clang. Try harder to avoid them by using
internal_memcpy() where applicable.

llvm-svn: 255287
2015-12-10 19:24:27 +00:00
Xinliang David Li e8c18a1bd1 [PGO] Move target-dependent macro to InstrProfilingPort.h (NFC)
llvm-svn: 255285
2015-12-10 19:20:25 +00:00
Xinliang David Li 26bcd193a8 [PGO] Header file cleanup (NFC)
InstrProfiling.h file declares profile runtime public APIs.
It has become a dumping place for many different things, which
needs cleanups. In this change, core type declarations and 
portability macros are moved to a new file InstrProfilingPort.h.

llvm-svn: 255270
2015-12-10 18:17:01 +00:00
Xinliang David Li b247bfb23b [PGO] use COMPILER_RT_HAS_ATOMTICS macro
llvm-svn: 255266
2015-12-10 17:27:53 +00:00
Bill Seurer 6845fb3671 [power] Fix test case target checks
Several test cases that used to fail on both power LE and BE
now run correctly on LE.

llvm-svn: 255262
2015-12-10 17:09:53 +00:00
Yury Gribov 90a36c5ba1 [asan] Use atomic_uintptr_t instead of atomic_uint64_t in SuppressErrorReport.
Some targets (e.g. Mips) don't have 64-bit atomics, so using atomic_uint64_t
leads to build failures. Use atomic_uintptr_t to avoid such errors.

Patch by Max Ostapenko. 

llvm-svn: 255242
2015-12-10 11:07:19 +00:00
Yury Gribov a8ffa6189e [asan] Move halt_on_error_suppress_equal_pcs.cc to Posix directory.
Patch by Max Ostapenko.

llvm-svn: 255230
2015-12-10 08:34:28 +00:00
Yury Gribov 6bfade1b81 [asan] Suppress duplicated errors in ASan recovery mode.
Patch by Max Ostapenko.

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

llvm-svn: 255228
2015-12-10 08:08:53 +00:00
Evgeniy Stepanov 2ad0192e6f Replace cmake check for printf with a check for fopen.
Printf is a builtin, and the check fails with -Werror because of a clang
warning about an incompatible redeclaration.

llvm-svn: 255189
2015-12-10 00:47:50 +00:00
Chris Bieneman 5c64ddfa88 Revert "[CMake] Provide options for toggling on and off various runtime libraries."
This reverts r255170. This change caused a bunch of bot failures and needs to be revised.

llvm-svn: 255184
2015-12-10 00:40:58 +00:00
Chris Bieneman a584158a25 [CMake] [Darwin] Log architecture test failures to CMakeError.log
This makes debugging configuration issues way easier.

llvm-svn: 255183
2015-12-10 00:39:57 +00:00
Xinliang David Li bf56c0a512 [PGO] Add cmake check to determine atomics op availability
This allows the profile runtime to pick the right impl
for cmp&swap for a given target.

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

llvm-svn: 255173
2015-12-09 22:46:49 +00:00
Chris Bieneman e82ad46f15 [CMake] Provide options for toggling on and off various runtime libraries.
Summary:
Rather than having to add new "experimental" options each time someone wants to work on bringing a sanitizer to a new platform, this patch makes options for all of them.

The default values for the options are set by the platform checks that would have enabled them, but they can be overridden on or off.

Reviewers: kubabrecka, samsonov

Subscribers: llvm-commits

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

llvm-svn: 255170
2015-12-09 22:45:03 +00:00
Yabin Cui 7f48808882 [tsan] Move emptyset/oldset to ThreadSignalContext.
Summary:
Android doesn't support __thread keyword. So move emptyset/oldset
from THREADLOCAL to ThreadSignalContext.

Reviewers: kcc, eugenis, dvyukov

Subscribers: llvm-commits, tberghammer, danalbert

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

llvm-svn: 255168
2015-12-09 22:40:31 +00:00
Yabin Cui 4ddbe8508a [tsan] Use REAL(malloc) instead of __libc_malloc for Android.
Summary:
Android doesn't have __libc_malloc and related allocation
functions. As its dynamic linker doesn't use malloc, so
we can use REAL(malloc) to replace __libc_malloc safely.

Reviewers: kcc, eugenis, dvyukov

Subscribers: llvm-commits, tberghammer, danalbert, srhines

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

llvm-svn: 255167
2015-12-09 22:32:38 +00:00
Sumanth Gundapaneni dbb8a1d8e7 Fix the target specific "-msse3" flag check in CMake. NFC
msse3 is a target dependent flag and must be guarded as check_cxx_compiler_flag()
checks only for compiler error messages and ignores warnings. Earlier COMPILER_RT_HAS_MSSE3_FLAG
is set to "TRUE" for all targets as clang emits warnings and the compilation spits unnecessary 
warnings for non-X86 targets. This issue is fixed by coupling the flag with "-Werror"

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

llvm-svn: 255165
2015-12-09 22:26:38 +00:00
Yabin Cui 903ab8a2a3 [tsan] Disable interceptors not supported in Android.
Reviewers: kcc, eugenis, dvyukov

Subscribers: llvm-commits, tberghammer, danalbert, srhines

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

llvm-svn: 255164
2015-12-09 22:23:47 +00:00
Hans Wennborg 63011e91d1 asan_win_dynamic_runtime_thunk.cc: declare atexit
MSVC apparently makes atexit available even without including stdlib.h,
but clang-cl does not. This makes the file build also with clang-cl.

llvm-svn: 255160
2015-12-09 21:43:03 +00:00
Alexey Samsonov 9c54984d43 [TSan] Try harder to avoid compiler-generated memset calls.
check_memcpy test added in r254959 fails on some configurations due to
memset() calls inserted by Clang. Try harder to avoid them:
* Explicitly use internal_memset() instead of empty braced-initializer.
* Replace "new T()" with "new T", as the former generates zero-initialization
  for structs in C++11.

llvm-svn: 255136
2015-12-09 18:48:10 +00:00
Yabin Cui d28ffacc99 [tsan] Define sigaction_t for Android.
Reviewers: kcc, eugenis, dvyukov

Subscribers: llvm-commits, tberghammer, danalbert, srhines

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

llvm-svn: 255135
2015-12-09 18:37:27 +00:00
Bill Schmidt 4514a87c4d Avoid extended mnemonic 'mfvrsave' in assembly code
llvm-svn: 255116
2015-12-09 15:18:30 +00:00
Alexey Samsonov aff20ac3bd [UBSan] Clarify the way we disable de-duplication of reports from unrecoverable handlers.
Let unrecoverable handlers be responsbile for killing the
program with Die(), and let functions which print the error
report know if it's going to happen. Re-write the comments to
describe the situation.

llvm-svn: 255081
2015-12-09 00:12:57 +00:00
Reid Kleckner 0497da4643 Adjust line numbers to account for new XFAIL comments
llvm-svn: 255076
2015-12-08 23:36:35 +00:00
Alexey Samsonov b4a852f219 [UBSan] Remove "-fsanitize=" prefix from ubsan_checks.inc. NFC.
llvm-svn: 255075
2015-12-08 23:29:36 +00:00
Alexey Samsonov 46442df8de [UBSan] Always calculate ErrorType (kind of UB) before printing a report.
Currently, this is an NFC. However, knowing out the kind of error
report before we bring up all the reporting machinery (implemented in
ScopedReport class) is important once we teach UBSan runtime
suppressions.

llvm-svn: 255074
2015-12-08 23:29:33 +00:00
Xinliang David Li 27e48f4e4e Fix typo
llvm-svn: 255068
2015-12-08 22:51:40 +00:00
Bill Schmidt 6b63d576c3 [PPC64, TSAN] Provide setjmp interceptor support for PPC64
This patch provides the assembly support for setjmp/longjmp for use
with the thread sanitizer.  This is a big more complicated than for
aarch64, because sibcalls are only legal under our ABIs if the TOC
pointer is unchanged.  Since the true setjmp function trashes the TOC
pointer, and we have to leave the stack in a correct state, we emulate
the setjmp function rather than branching to it.

We also need to materialize the TOC for cases where the _setjmp code
is called from libc.  This is done differently under the ELFv1 and
ELFv2 ABIs.

llvm-svn: 255059
2015-12-08 22:14:34 +00:00
Bill Schmidt 2979162732 [PPC64, TSAN] LLVM basic enablement of thread sanitizer for PPC64 (BE and LE)
This patch is by Simone Atzeni with portions by Adhemerval Zanella.

This contains the LLVM patches to enable the thread sanitizer for
PPC64, both big- and little-endian.  Two different virtual memory
sizes are supported:  Old kernels use a 44-bit address space, while
newer kernels require a 46-bit address space.

There are two companion patches that will be added shortly.  There is
a Clang patch to actually turn on the use of the thread sanitizer for
PPC64.  There is also a patch that I wrote to provide interceptor
support for setjmp/longjmp on PPC64.

Patch discussion at reviews.llvm.org/D12841.

llvm-svn: 255057
2015-12-08 21:54:39 +00:00
Chris Bieneman 4604ece66b [CMake] Adding simulator supported runtimes should be done in the block that tests simulator capabilities.
Not sure why I put this in the iOS block originally, it shouldn't be there.

llvm-svn: 255046
2015-12-08 19:31:33 +00:00
Alexey Samsonov 02824d0e59 [TSan] Remove legacy Makefile.old!
Summary:
It was barely supported for a several years for now, somewhat
rotten and doesn't correspond to the way we build/test TSan runtime
in Clang anymore.

CMake build has proper compile flags, library layout, build
dependencies etc.

Shell scripts that depended on the output of Makefile.old are
either obsolete now (check_cmake.sh), or moved to lit tests
(check_memcpy.sh), or kept as a standalone scripts not suitable
for generic test suite, but invoked on bots (check_analyze.sh).

It is not used on bots anymore: all "interesting" configurations
(gcc/clang as a host compiler; debug/release build types) are now
tested via CMake.

Reviewers: dvyukov, kcc

Subscribers: llvm-commits

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

llvm-svn: 255032
2015-12-08 17:59:33 +00:00
Alexey Samsonov f49d159c8a [CMake] Remove debug output leftovers.
llvm-svn: 255031
2015-12-08 17:59:30 +00:00
Dmitry Vyukov eee690b29a tsan: fix test invisible barrier
Another attempt at fixing tsan_invisible_barrier.
Current implementation causes:
https://llvm.org/bugs/show_bug.cgi?id=25643

There were several unsuccessful iterations for this functionality:

Initially it was implemented in user code using REAL(pthread_barrier_wait). But pthread_barrier_wait is not supported on MacOS. Futexes are linux-specific for this matter.
Then we switched to atomics+usleep(10). But usleep produced parasitic "as-if synchronized via sleep" messages in reports which failed some output tests.
Then we switched to atomics+sched_yield. But this produced tons of tsan- visible events, which lead to "failed to restore stack trace" failures.
Move implementation into runtime and use internal_sched_yield in the wait loop.
This way tsan should see no events from the barrier, so not trace overflows and
no "as-if synchronized via sleep" messages.

llvm-svn: 255030
2015-12-08 17:54:47 +00:00
Kuba Brecka 25dba9b781 [tsan] Add dispatch_group API interceptors and synchronization
This patch adds release and acquire semantics for dispatch groups, plus a test case.

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

llvm-svn: 255020
2015-12-08 14:54:43 +00:00
Kuba Brecka 1956244e5a [tsan] Fix memcmp interceptor to correctly use COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED
The memcmp interceptor checks COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED only after it calls COMMON_INTERCEPTOR_ENTER, which causes an early process launch crash when running TSan in iOS simulator. Let's fix this by checking COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED as the very first thing in the interceptor.

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

llvm-svn: 255019
2015-12-08 14:48:21 +00:00
Alexey Samsonov d20a13023b [TSan] Enforce TSan runtime doesn't include system headers with --sysroot flag.
llvm-svn: 254966
2015-12-07 23:21:36 +00:00
Alexey Samsonov e243d45285 [TSan] Use llvm-objdump+FileCheck instead of standalone .sh script.
llvm-svn: 254959
2015-12-07 22:43:30 +00:00
Alexey Samsonov dc37ee2226 [TSan] Port check_memcpy.sh script to a regular lit test.
Check that TSan runtime doesn't contain compiler-inserted calls
to memset/memmove functions.

In future, we may consider moving this test to test/sanitizer_common,
as we don't want to have compiler-inserted memcpy/memmove calls in
any sanitizer runtime.

llvm-svn: 254955
2015-12-07 21:53:59 +00:00
Xinliang David Li 55d927a4fd [PGO] Stop leaking libc function to buffer API impl
llvm-svn: 254943
2015-12-07 21:18:16 +00:00
Alexey Samsonov a8bf5099d6 [TSan] Slightly improve check_analyze script.
De-hardcode path to TSan-ified executable: pass it as an input to
the scripts. Fix them so that they don't write to the current
directory. Remove their invocation from Makefile.old: they are
broken there anyway, as check_analyze.sh now matches trunk Clang.

llvm-svn: 254936
2015-12-07 20:18:50 +00:00
Alexey Samsonov 5d47be186d [TSan] Delete legacy test_output.sh script.
This script is superseded by lit test suite integrated into CMake
for quite a while now. It doesn't support many tests, and require
custom hacks for a few other.

llvm-svn: 254932
2015-12-07 19:40:33 +00:00
Xinliang David Li 5bbbcbb3dc Use macro for common code pattern (NFC)
llvm-svn: 254831
2015-12-05 03:14:53 +00:00
Alexey Samsonov a330293af7 [CMake] Add COMPILER_RT_TSAN_DEBUG_OUTPUT option.
This option builds TSan runtime with extra debug printfs
and stats collection. This build configuration is developer-only
and should rarely be used, but we need to keep it to make sure
it doesn't bitrot.

llvm-svn: 254818
2015-12-05 01:37:17 +00:00
Dan Albert c8bdae1074 Check multilib dir for asan_device_setup.
Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 254789
2015-12-04 22:51:03 +00:00
Evgeniy Stepanov 2f107ce132 [asan] Remove the use of system properties on Android.
System properties are not accessible through NDK (we've been using
hacks to get to them) and they are unavailable during ASan
initialization in .preinit_array. Use environment variables and
files instead (ex. ASAN_OPTIONS=include_if_exists=/path).

No test changes. This feature was not tested because the properties
are system-wide and would conflict with the parallel test runner. Yet
another reason to get rid of it.

llvm-svn: 254783
2015-12-04 22:28:27 +00:00
Xinliang David Li 4c8a5e37e2 Move macro defs closer (NFC)
llvm-svn: 254761
2015-12-04 20:09:55 +00:00
Alexander Potapenko b6a2537c60 [libsanitizer] Fix bugs and wiki links to point to GitHub.
llvm-svn: 254738
2015-12-04 17:50:03 +00:00
Alexander Potapenko a75f826117 [TSan] Fix the wikipage link.
llvm-svn: 254736
2015-12-04 17:38:47 +00:00
Alexander Potapenko 00bddf6406 [ASan] Fix the links to bugs and wikipages.
llvm-svn: 254735
2015-12-04 17:37:40 +00:00
Alexander Potapenko e3c0d5996c [ASan] Change the links in asa_flags.inc to point to GitHub.
llvm-svn: 254732
2015-12-04 17:26:40 +00:00
Alexander Potapenko 6f3fa20c76 [ASan] Retire mac_ignore_invalid_free, remove some dead code.
mac_ignore_invalid_free was helpful when ASan runtime used to intercept
CFAllocator and sometimes corrupted its memory. This behavior had been long
gone, and the flag was unused.
This patch also deletes ReportMacCfReallocUnknown(), which was used by the
CFAllocator realloc() wrapper.

llvm-svn: 254722
2015-12-04 16:17:55 +00:00
Kuba Brecka 87cd9c63df [tsan] Enable building and testing TSan Go runtime on OS X
The build and test actually work now, so let's just enable them.

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

llvm-svn: 254716
2015-12-04 14:29:11 +00:00
Yury Gribov b18e2c7110 [asan] Enable alloca_vla_interact.cc test on PowerPC64.
Patch by Max Ostapenko.

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

llvm-svn: 254708
2015-12-04 09:32:45 +00:00
Xinliang David Li da29bc41a6 [PGO] Fix build failure with -fprofile-instr-generate
and -no-integrated-as for source with static function.

The compiler generates assembly names containing \" in the
.s dump causing gnu assembler to complain. That issue will be
investigated separately. 

llvm-svn: 254705
2015-12-04 06:06:07 +00:00
Xinliang David Li d31c1ba19a [PGO] Fix mips test failure with new test case
cmp&swap is not well supported -- the new test
case triggers some assembler error.

This is a partial fix to the general problem (lack
of atomics operation support for certain targets).

llvm-svn: 254701
2015-12-04 04:22:59 +00:00
Xinliang David Li ffb827f2bc [PGO] Unify VP data format between raw and indexed profile (runtime)
With the latest refactoring and code sharing patches landed, 
it is possible to unify the value profile implementation between
raw and indexed profile. This is part  in prfofile runtime.

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

llvm-svn: 254678
2015-12-04 01:02:24 +00:00
Joerg Sonnenberger d6487b23a9 Don't shadow a variable in the outer scope. Use canonical form of the
array size idiom.

llvm-svn: 254673
2015-12-04 00:40:07 +00:00
Chris Bieneman bcd09fef72 [CMake] CMake calls to set_property with APPEND string need to have a leading space.
llvm-svn: 254660
2015-12-03 22:56:21 +00:00
Chris Bieneman 1d7a2cf94c [CMake] set_target_properties doesn't append link flags
This fixes a bug I introduced in r254643.

llvm-svn: 254658
2015-12-03 22:52:22 +00:00
Chris Bieneman 69a372dc50 [CMake] Support externalizing debug info on Darwin
* Adds COMPILER_RT_EXTERNALIZE_DEBUGINFO option
* On Darwin this results in calling dsymutil and strip after linking
* This generates an error on non-darwin platforms, matching the LLVM behavior

llvm-svn: 254643
2015-12-03 20:08:22 +00:00
Xinliang David Li 9ea3064be5 [PGO] Introduce error report macro in profile-rt
Also added a test case for runtime error reporting.

llvm-svn: 254625
2015-12-03 18:31:59 +00:00
Kuba Brecka 2e2f84bfee [sanitizer] Replace a local array with InternalScopedString in MaybeReexec()
`MaybeReexec` contains a 1024-byte long local array, which produces a warning about frame size:

   .../lib/sanitizer_common/sanitizer_mac.cc:548:6: warning: stack frame size of 1132 bytes in function '__sanitizer::MaybeReexec' [-Wframe-larger-than=]

Let's replace it with InternalScopedString.

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

llvm-svn: 254619
2015-12-03 17:05:43 +00:00
Kuba Brecka 3daf7b4743 [sanitizer] Cache results of darwin_test_archs
For OS X builds of compiler-rt, we run `darwin_test_archs` to determine which architectures can the toolchain target. This detection takes quite a long time, and the result is always the same (as long as you don't upgrade your OS, system headers or toolchain). Let's cache the result.

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

llvm-svn: 254618
2015-12-03 17:02:07 +00:00
Kuba Brecka 0423e5cd57 [tsan] Add interceptors for Darwin-specific locking APIs
On OS X, there are other-than-pthread locking APIs that are used quite extensively - OSSpinLock and os_lock_lock. Let's add interceptors for those.

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

llvm-svn: 254611
2015-12-03 15:10:52 +00:00
Kuba Brecka ab43f42d9c Follow-up of r254600 to fix the dyld_insert_libraries_reexec.cc testcase on OS X 10.10.
llvm-svn: 254604
2015-12-03 11:34:16 +00:00
Kuba Brecka 74775eb5da [tsan] Enable ThreadSanitizer on OS X builds by default, take 2
Second attempt to enable building ThreadSanitizer (and running tests) on OS X by default.

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

llvm-svn: 254603
2015-12-03 11:02:43 +00:00
Kuba Brecka f642e88342 [tsan] Use MAP_ANON instead of MAP_ANONYMOUS
In mmap_large.cc, let's use MAP_ANON instead of MAP_ANONYMOUS, because MAP_ANONYMOUS is only available on OS X 10.11 and later.

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

llvm-svn: 254601
2015-12-03 10:46:26 +00:00
Kuba Brecka 65aa45e872 [tsan] Use re-exec method to enable interceptors on older versions of OS X
In AddressSanitizer, we have the MaybeReexec method to detect when we're running without DYLD_INSERT_LIBRARIES (in which case interceptors don't work) and re-execute with the environment variable set. On OS X 10.11+, this is no longer necessary, but to have ThreadSanitizer supported on older versions of OS X, let's use the same method as well. This patch moves the implementation from `asan/` into `sanitizer_common/`.

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

llvm-svn: 254600
2015-12-03 10:39:43 +00:00
Xinliang David Li ba904d4ecf Sync up with master file
llvm-svn: 254552
2015-12-02 21:48:22 +00:00
Andy Gibbs abd2a0bf0d Pass along correct 'make' to sub-builds.
If the top-level cmake has a custom make specified through -DCMAKE_MAKE_PROGRAM
then this must be passed along to the sub-build processes in compiler-rt or the
build process will fail.

llvm-svn: 254509
2015-12-02 13:46:56 +00:00
Kostya Serebryany 6c19d8c2ac [sanitizer coverage] when adding a bb trace instrumentation, do it instead, not in addition to, regular coverage. Do the regular coverage in the run-time instead
llvm-svn: 254483
2015-12-02 02:37:31 +00:00
Sumanth Gundapaneni c1c674c60b builtins: Fix the sysroot's reference to si_int in int_types.h
si_int is already defined in sysroot's siginfo.h
emutls.c includes pthread.h which includes asm/siginfo.h which
in turn includes asm-generic/siginfo.h and that defines si_int.
si_int is also defined in builtin's int_types.h and this leads to
errors. This patch fixes the issue by undefining the si_int in int_types.h

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

llvm-svn: 254472
2015-12-01 23:06:23 +00:00
Sumanth Gundapaneni 9af8961a86 builtins: Build emutls.c on MINGW builds
Differential Revision: http://reviews.llvm.org/D15083

llvm-svn: 254470
2015-12-01 23:04:33 +00:00
Sumanth Gundapaneni b32a22eab7 Fix the RUN on UBSAN unit tests
For the build set up which runs the unit tests using an emulator like QEMU,
the unit tests must be run using %run.

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

llvm-svn: 254467
2015-12-01 23:03:08 +00:00
Alexey Samsonov b6f28ef2c9 [Sanitizer] Increase kPcThreshold in slow unwinder after r254395.
llvm-svn: 254460
2015-12-01 20:58:44 +00:00
Kuba Brecka 1e9fd96c4c Revert r254417 ("[tsan] Enable Thread Sanitizer on OS X builds by default").
A ton of tests fail on OS X 10.10, because dyld auto-interposition is only available in 10.11.

llvm-svn: 254420
2015-12-01 15:56:38 +00:00
Kuba Brecka 6c800eb3f0 [tsan] Enable Thread Sanitizer on OS X builds by default
Differential Revision: http://reviews.llvm.org/D15109

llvm-svn: 254417
2015-12-01 15:00:16 +00:00
Kuba Brecka ac5f5d10d5 [tsan] Add interceptors and sychronization for libdispatch semaphores on OS X
This patch adds release and acquire semantics for libdispatch semaphores and a test case.

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

llvm-svn: 254412
2015-12-01 13:11:42 +00:00
Yury Gribov 67a001fd17 [asan] Correctly release memory allocated during early startup.
Calloc interceptor initially allocates memory from temp buffer (to serve dlsyms called during asan_init). There is a chance that some non-instrumented library (or executable) has allocated memory with calloc before asan_init and got pointer from the same temporary buffer which later caused problems with free.

Inspired by https://github.com/google/sanitizers/issues/626

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

llvm-svn: 254395
2015-12-01 09:22:41 +00:00
Adhemerval Zanella 7a096596b2 [compiler-rt] Remove SANITIZER_AARCH64_VMA usage
This patch complete removed SANITIZER_AARCH64_VMA definition and usage.
AArch64 ports now supports runtime VMA detection and instrumentation
for 39 and 42-bit VMA.

It also Rewrite print_address to take a variadic argument list
(the addresses to print) and adjust the tests which uses it to the new
signature.

llvm-svn: 254319
2015-11-30 19:43:03 +00:00
Chris Bieneman 9586a38870 [CMake] Moving -fvisibility-inlines-hidden append as per post-commit review
Thanks Alexey.

llvm-svn: 254316
2015-11-30 19:16:42 +00:00
Chris Bieneman 9b6d4ffdf9 [CMake] Add -fvisibility-inlines-hidden if the compiler supports it.
This results in a significant reduction in the size of the sanitizer libraries.

llvm-svn: 254308
2015-11-30 17:42:30 +00:00
Kuba Brecka 4809b1dca1 [sanitizer] Detect an invalid answer in AtosSymbolizer
On OS X, in AtosSymbolizer, if the answer from atos doesn't contain module name, let's bail and return false. There are some cases where this is beneficial, because we'll try DlAddrSymbolizer next (it's next in the symbolizer chain), which might be able to symbolize something that atos couldn't.

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

llvm-svn: 254301
2015-11-30 14:12:47 +00:00
Kuba Brecka 6c9122ffba [tsan] Change comments referencing code.google.com to point to GitHub instead. NFC.
Changing comments that have references to code.google.com to point to GitHub instead, because the current links are not redirected properly (they instead redirect to different issues, mostly ASan). NFC.

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

llvm-svn: 254300
2015-11-30 14:11:48 +00:00
Kuba Brecka 77ff411247 [tsan] Fix signals and setjmp/longjmp on OS X
1) There's a few wrongly defined things in tsan_interceptors.cc,
2) a typo in tsan_rtl_amd64.S which calls setjmp instead of sigsetjmp in the interceptor, and
3) on OS X, accessing an mprotected page results in a SIGBUS (and not SIGSEGV).

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

llvm-svn: 254299
2015-11-30 14:11:02 +00:00
Kuba Brecka 6fd0675925 [tsan] Fix weakly imported functions on OS X
On OS X, for weak function (that user can override by providing their own implementation in the main binary), we need extern `"C" SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE`.

Fixes a broken test case on OS X, java_symbolization.cc, which uses a weak function __tsan_symbolize_external.

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

llvm-svn: 254298
2015-11-30 13:27:18 +00:00
Yury Gribov fc4ba13622 [asan] Old Linux kernels (< 3.0) don't define ARM_VFPREGS_SIZE that leads to
build errors on ARM. Define it internally to avoid such errors.

Patch by Max Ostapenko.

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

llvm-svn: 254292
2015-11-30 09:19:22 +00:00
Kuba Brecka e14261a4c9 Fixup for r254228 ("Port tsan_rtl_amd64.S to OS X to add support for setjmp/longjmp") to fix the build of unit tests. We need to add the ASM file into RTTsan_dynamic as well.
llvm-svn: 254249
2015-11-29 08:48:47 +00:00
Xinliang David Li abf49140d4 sync up with master file
llvm-svn: 254245
2015-11-29 04:53:15 +00:00
Xinliang David Li a59bb52913 Sync up template file with master
llvm-svn: 254236
2015-11-28 19:12:23 +00:00
Kuba Brecka 8f9607a616 [tsan] Add release+acquire semantics for serial dispatch queues
Serial queues need extra happens-before between individual tasks executed in the same queue. This patch adds `Acquire(queue)` before the executed task and `Release(queue)` just after it (for serial queues only). Added a test case.

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

llvm-svn: 254229
2015-11-28 12:53:57 +00:00
Kuba Brecka f94bb99adc [tsan] Port tsan_rtl_amd64.S to OS X to add support for setjmp/longjmp
This patch ports the assembly file tsan_rtl_amd64.S to OS X, where we need several changes:

* Some assembler directives are not available on OS X (.hidden, .type, .size)
* Symbol names need to start with an underscore (added a ASM_TSAN_SYMBOL macro for that).
* To make the interceptors work, we ween to name the function "_wrap_setjmp" (added ASM_TSAN_SYMBOL_INTERCEPTOR for that).
* Calling the original setjmp is done with a simple "jmp _setjmp".
* __sigsetjmp doesn't exist on OS X.

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

llvm-svn: 254228
2015-11-28 12:44:23 +00:00
Kuba Brecka bdb5cef272 [tsan] Add a testcase for a race on a Obj-C instance variable
Let's add a testcase for a race on a Obj-C instance variable.

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

llvm-svn: 254226
2015-11-28 10:32:05 +00:00
Kuba Brecka 8910d652a9 [tsan] Mark a few more tests with "UNSUPPORTED: darwin"
There's a few more lit tests that require features not available on OS X (MAP_32BIT, pthread_setname_np), let's mark them with "UNSUPPORTED: darwin".

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

llvm-svn: 254225
2015-11-28 09:22:27 +00:00
Kuba Brecka fbbdd7bdee [tsan] Change mutexset6.cc to use a mutex instead of spinlock
Pthread spinlocks are not available on OS X and this test doesn't really require a spinlock.

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

llvm-svn: 254224
2015-11-28 09:18:43 +00:00
Kuba Brecka 11d8c1f8dd [tsan] Fix an assertion failure in FindThreadByUidLocked with recycled threads
When a race on file descriptors is detected, `FindThreadByUidLocked()` is called to retrieve ThreadContext with a specific unique_id. However, this ThreadContext might not exist in the thread registry anymore (it may have been recycled), in which case `FindThreadByUidLocked` will cause an assertion failure in `GetThreadLocked`. Adding a test case that reproduces this, producing:

    FATAL: ThreadSanitizer CHECK failed: sanitizer_common/sanitizer_thread_registry.h:92 "((tid)) < ((n_contexts_))" (0x34, 0x34)

This patch fixes this by replacing the loop with `FindThreadContextLocked`.

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

llvm-svn: 254223
2015-11-28 09:16:34 +00:00
Adhemerval Zanella f2d3dbfaca [compiler-rt] [dfsan] Unify aarch64 mapping
This patch reorganize the platform specific mapping information to
export the application mask on a external variable. This exported
variable will be used by intrumentation phase to create code to be
used on architecture with multiple VMA range.
    
The patch creates a new header, dfsan_platform.h, and move all the
mapping information and also create function accessors to the
mapping value.

Also for aarch64 it initialize application exported mask to the 
value based on runtime VMA detection.

llvm-svn: 254197
2015-11-27 12:43:33 +00:00
Adhemerval Zanella 066c5f0f92 [compiler-rt] [tsan] Unify aarch64 mapping
This patch unify the 39 and 42-bit support for AArch64 by using an external
memory read to check the runtime detected VMA and select the better mapping
and transformation.  Although slower, this leads to same instrumented binary
to be independent of the kernel.

Along with this change this patch also fix some 42-bit failures with
ALSR disable by increasing the upper high app memory threshold and also
the 42-bit madvise value for non large page set.

llvm-svn: 254151
2015-11-26 13:10:47 +00:00
Xinliang David Li 463e5ab205 Sync up with master InstrProfData.inc
llvm-svn: 254113
2015-11-26 00:03:34 +00:00
Ivan Krasin 00de6bc9b7 sanitizer_common: remove noisy warning about symbolizer not found.
Summary:
In r251553, I added a warning that proved to be super noisy,
especially in case of MSan. Removing it for now, and I will
probably add some additional diagnostics for symbolizer, when
I better understand how to make it properly.

Reviewers: eugenis

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

llvm-svn: 254102
2015-11-25 22:00:20 +00:00
Chris Bieneman f1f46b5766 [CMake] [Darwin] libclang_rt.eprintf should be built with the same CFLAGS as the other darwin builtin libraries.
llvm-svn: 254082
2015-11-25 19:32:32 +00:00
Kuba Brecka 4aa4a73f17 [sanitizer] Fix a crash with DlAddrSymbolizer and unnamed symbols
Apparently, dladdr() can succeed but return a NULL pointer, in which case strdup will crash.  Let's not call strdup on NULL pointers.

llvm-svn: 254068
2015-11-25 13:11:38 +00:00
Kuba Brecka ad986d5141 [asan] Fix the atos-symbolizer-dyld-root-path.cc test case
Due to a typo, atos-symbolizer-dyld-root-path.cc is currently being skipped all the time. There's a few more typos/copy-paste-errors. Let's fix them and enable this test.

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

llvm-svn: 254058
2015-11-25 07:59:00 +00:00
Adhemerval Zanella 29ffb68259 [compiler-rt] [msan] Couple of fixes for msan with libc++
This patch adds some fixes for MSAN with libc++ for aarch64:

1. Adds the libmsan_loadable name for aarch64.
2. Fixes some pthread_attr_setstacksize for aarch64, since glibc sets
   the mininum stack size to be higher than the x86_64 default (16KB
   vs 128KB).
3. Fixes a swprintf null char constant definition.

llvm-svn: 254015
2015-11-24 20:28:48 +00:00
Kuba Brecka 8443d187e6 [tsan] Fix signal number definitions for OS X
On OS X, SIGBUS is 10 and SIGSYS is 12.

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

llvm-svn: 253983
2015-11-24 13:44:54 +00:00
Kuba Brecka 440d08600b [tsan] Implement basic GCD interceptors for OS X
We need to intercept libdispatch APIs (dispatch_sync, dispatch_async, etc.) to add synchronization between the code that submits the task and the code that gets executed (possibly on a different thread). This patch adds release+acquire semantics for dispatch_sync, and dispatch_async (plus their "_f" and barrier variants). The synchronization is done on malloc'd contexts (separate for each submitted block/callback). Added tests to show usage of dispatch_sync and dispatch_async, for cases where we expect no warnings and for cases where TSan finds races.

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

llvm-svn: 253982
2015-11-24 13:36:06 +00:00
Kuba Brecka 6cb7f7a923 [tsan] Fix stack_sync_reuse.cc test on OS X
The test relies on two variables in different frames to end up being on the same address. For some reason, this isn't true on OS X. This patch adds `__attribute__((aligned(64)))` to the variables, which actually makes the variables occupy the same address. This is still not a guarantee, but it's more likely to work (the test looks very fragile already).

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

llvm-svn: 253981
2015-11-24 13:29:15 +00:00
Kuba Brecka 941d0a756a [tsan] Replace pthread semaphore in signal_cond.cc with barrier_wait
Pthread semaphores are not available on OS X. Let's replace sem_wait/sem_post with barrier_wait, which makes the test pass on OS X. I know that sem_wait/sem_post is intercepted by TSan, whereas barrier_wait is TSan-invisible, but the purpose of the test is not affected by this.

Also, let's properly initialize the mutex and cond variables.

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

llvm-svn: 253980
2015-11-24 13:28:27 +00:00
Kuba Brecka 377cafbbbc [tsan] Fix CallocOverflow unit test on OS X
On OS X, interceptors don't work in unit tests, so calloc() calls the system allocator. We need to use user_calloc() instead.

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

llvm-svn: 253979
2015-11-24 13:27:33 +00:00
Xinliang David Li bd1e84bc84 sync up InstrProfData.inc with master
llvm-svn: 253943
2015-11-24 00:37:45 +00:00
Xinliang David Li 39f4c2ca3b [PGO] sync up target instrument decl between runtime and llvm (NFC)
llvm-svn: 253911
2015-11-23 20:07:09 +00:00
Xinliang David Li d200b27f08 [PGO] Unify section name, section symbol definitions (Darwin)
Replace hard-coded references to names to key section and section
 symbols with common macro definitions.

llvm-svn: 253907
2015-11-23 19:48:25 +00:00
Xinliang David Li 7c7f120178 [PGO] Unify section name, section symbol definitions (Linux)
Replace hard-coded references to names to key section and section
 symbols with common macro definitions.

llvm-svn: 253897
2015-11-23 18:56:03 +00:00
Xinliang David Li 6376db52fe [PGO] Unify raw profile header definition
Replace duplicate definition raw header with
 common definition in InstrProfData.inc.

llvm-svn: 253896
2015-11-23 18:36:40 +00:00