Commit Graph

6700 Commits

Author SHA1 Message Date
Anna Zaks 2c5c33dc38 [asan] Fixup r258849 by updating warning in the test
The error message has been changed in code as of r258849 (http://reviews.llvm.org/D16546). Update the test as well.

llvm-svn: 259452
2016-02-02 02:01:21 +00:00
Anna Zaks c77a080bdb [asan] Add iOS support.
llvm-svn: 259451
2016-02-02 02:01:17 +00:00
Alexey Samsonov a7be03d66b [CMake] Use LLVM_MAIN_SRC_DIR instead of LLVM_SOURCE_DIR.
The former will be properly initialized in standalone CMake build of
compiler-rt.

llvm-svn: 259407
2016-02-01 21:08:16 +00:00
Reid Kleckner b3e847ebac [ubsan] Stop thinking we can rely on C++ ABI knowledge on Windows
We already disabled various tests relying on C++ ABI knowledge, but we
still tried to build in this configuration on Windows which was a
mistake.

Fixes PR26415.

llvm-svn: 259388
2016-02-01 19:13:28 +00:00
Ismail Donmez 7bf46bfcdf Fix build with VS2015
llvm-svn: 259301
2016-01-30 07:14:31 +00:00
Vedant Kumar a06e8ca6c5 [profile] Support hostname expansion in LLVM_PROFILE_FILE
This patch adds support for expanding "%h" out to the machine hostname
in the LLVM_PROFILE_FILE environment variable.

Patch by Daniel Waters!

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

llvm-svn: 259272
2016-01-29 23:52:11 +00:00
Evgeniy Stepanov dfef2cf502 [cfi] Simplify the code in CfiSlowPathCommon.
llvm-svn: 259085
2016-01-28 19:58:26 +00:00
Evgeniy Stepanov 3cf771e367 [cfi] Get rid of a fixed size buffer for the library path in test.
llvm-svn: 259082
2016-01-28 19:37:03 +00:00
Xinliang David Li ec8d086c64 Minor cleanup /NFC
llvm-svn: 259068
2016-01-28 18:37:43 +00:00
Mike Aizatsky 343322bb93 putting requires on one line - ppc still executes my tests.
llvm-svn: 259012
2016-01-28 02:24:35 +00:00
Evgeniy Stepanov 4a09234cb7 [cfi] Fix recovery from out-of-bounds vtable error.
llvm-svn: 259007
2016-01-28 00:37:54 +00:00
Mike Aizatsky b4c48d1e15 [sancov] run sancov test on x86_64 linux only
llvm-svn: 259006
2016-01-28 00:35:17 +00:00
Mike Aizatsky c22e72e6b0 GetArgv returns null on widnows, do not crash
llvm-svn: 259005
2016-01-28 00:31:49 +00:00
Mike Aizatsky ecaeb1d93b [sancov] running sancov test on linux only
llvm-svn: 259004
2016-01-28 00:27:13 +00:00
Mike Aizatsky adc0a67a55 using /system/bin/sh on android in tests.
Subscribers: tberghammer, danalbert, srhines

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

llvm-svn: 259001
2016-01-27 23:58:23 +00:00
Mike Aizatsky 2654299d6a [sanitizers] generating html report on coverage dump
Subscribers: tberghammer, danalbert, srhines

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

llvm-svn: 258999
2016-01-27 23:51:36 +00:00
Evgeniy Stepanov e7f8b23716 [cfi] Fix a warning in tests.
test/cfi/cross-dso/dlopen.cpp:67:45: warning: GCC does not allow 'aligned' attribute in this position on a function definition [-Wgcc-compat]
extern "C" void do_nothing() __attribute__((aligned(4096))) {}

llvm-svn: 258992
2016-01-27 21:49:03 +00:00
Alexey Samsonov d9272422a2 [CMake] Set llvm_tools_dir to LLVM_TOOLS_BINARY_DIR instead of LLVM_TOOLS_DIR
In this way, it should work for both in-LLVM and standalone
compiler-rt build.

llvm-svn: 258991
2016-01-27 21:36:38 +00:00
Evgeniy Stepanov 7cced3ba82 [cfi] Disable vtable diagnostics when no cxxabi.
This should fix the build on Mac 10.8 and earlier.

llvm-svn: 258988
2016-01-27 21:15:10 +00:00
Mike Aizatsky 48c26de04e [sanitizers] using execv instead of execve with null env.
Differential Revision: http://reviews.llvm.org/D16646

llvm-svn: 258983
2016-01-27 20:35:18 +00:00
Evgeniy Stepanov ecfa524ee3 [cfi] Fix gcc build.
llvm-svn: 258977
2016-01-27 19:33:00 +00:00
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