Commit Graph

6397 Commits

Author SHA1 Message Date
Yury Gribov 7e3c7ee0b1 [asan] Fixed invalid check in test.
llvm-svn: 253037
2015-11-13 12:49:58 +00:00
Yury Gribov eed2daa80c [asan] Dump test output in case of error in single-threaded mode.
llvm-svn: 253035
2015-11-13 12:07:15 +00:00
Yury Gribov a085297030 [asan] Fix test to properly handle collisions.
llvm-svn: 253025
2015-11-13 10:32:13 +00:00
Yury Gribov b2f75136d1 [asan] Fix silly error when reporting multiple ASan errors in parallel.
llvm-svn: 253022
2015-11-13 09:46:12 +00:00
Yury Gribov 1e89f53902 [asan] Get rid of rand_r (not available on all targets).
llvm-svn: 253021
2015-11-13 09:43:30 +00:00
Kuba Brecka 49fd0c138d [tsan] Add global symbolication support into AtosSymbolizer
This patch adds support for symbolication of globals (implements `SymbolizeData`) for `AtosSymbolizer` on OS X.

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

llvm-svn: 253015
2015-11-13 06:45:49 +00:00
Martell Malone 5b7658c1a4 compiler-rt: add make solution to bootstrap mingw-w64
Differential Revision: http://reviews.llvm.org/D14290

llvm-svn: 252976
2015-11-13 00:21:34 +00:00
Chris Bieneman 14679e9f68 [CMake] [Darwin] Forcing -fPIC on for all darwin builtins except macho_embedded
We need to add -fPIC to the flags for the builtins in case PIC was turned off at a higher level. We also want to set ENABLE_PIC to Off when building the macho_embedded builtins so the top-level settings don't impact that build.

llvm-svn: 252966
2015-11-12 22:37:03 +00:00
Chris Bieneman 73d0562542 [CMake] [Darwin] [Builitins] Removing muloti4 from the blacklists for arm.
llvm-svn: 252965
2015-11-12 22:37:01 +00:00
Chris Bieneman 77e5eea728 [CMake] [Darwin] [Builtins] Sorting and uniquing blacklists. NFC.
llvm-svn: 252964
2015-11-12 22:36:57 +00:00
Reid Kleckner b8e3bff98a [Windows] Fix halt_on_error-1.c test on Windows with %env_asan_opts
llvm-svn: 252958
2015-11-12 21:58:28 +00:00
Evgeniy Stepanov 833c75e554 [asan] Mark halt_on_error-torture test unsupported on android.
Android libc is missing rand_r until API 21. ASan supports API 19.

llvm-svn: 252930
2015-11-12 19:30:38 +00:00
Chris Bieneman b3df467fc8 [CMake] [builtins] Removing a few non-source files from the arm list.
I was a little too aggressive about adding sources from the arm subdirectory.

llvm-svn: 252929
2015-11-12 19:27:29 +00:00
Chris Bieneman 7beed7eb6c [CMake] Actually adding the TODO comment I mentioned in r252927.
Turns out you need to save before committing.

llvm-svn: 252928
2015-11-12 19:17:05 +00:00
Chris Bieneman a2151fdceb [CMake] [builtins] Adding missing architecture-specific builtins.
Also added a TODO comment to make the build system throw an error if the CMakeLists gets out of sync again.

llvm-svn: 252927
2015-11-12 19:15:56 +00:00
Dmitry Vyukov b8da794ca1 tsan: fix windows Go build
Go build does not link in whatever library provides these symbols:

# runtime/race
race_windows_amd64.syso:gotsan.cc:(.text+0x578f): undefined reference to `__sanitizer::DumpProcessMap()'
race_windows_amd64.syso:gotsan.cc:(.text+0xee33): undefined reference to `EnumProcessModules'
race_windows_amd64.syso:gotsan.cc:(.text+0xeeb9): undefined reference to `GetModuleInformation'

llvm-svn: 252922
2015-11-12 18:50:19 +00:00
Dmitry Vyukov 8455cf0142 tsan: fix windows Go build
CompareModulesBase is an unused function.

llvm-svn: 252907
2015-11-12 16:29:24 +00:00
Kuba Brecka af9525dfff [tsan] Add global symbolication support into DlAddrSymbolizer
`DlAddrSymbolizer` is used on OS X when we're running inside a sandbox that prevents us from spawning an external symbolizer. This patch adds support for symbolication of globals (implements `SymbolizeData`) for `DlAddrSymbolizer`.

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

llvm-svn: 252899
2015-11-12 15:19:40 +00:00
Kuba Brecka 3ecce92a52 [tsan] Allow symbolizers that don't obtain global symbol sizes
The default symbolizer, `llvm-symbolizer` provides sizes for global symbols. On OS X, we want to also allow using `atos` (because it's available everywhere and users don't need to copy/install it) and `dladdr` (it's the only available option when running in a sandbox). However, these symbolizers do not supply the symbol sizes, only names and starting addresses. This patch changes the reporting functions to hide the size of the symbol when this value is unavailable, and modifies tests to make this part of the report "optional".

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

llvm-svn: 252896
2015-11-12 14:34:17 +00:00
Dmitry Vyukov bab2216dbb tsan: disable abort_on_error for Go
It does not work as expected.
Go runtime handles SIGABRT and crashes with a loud message.

llvm-svn: 252892
2015-11-12 14:03:20 +00:00
Kuba Brecka e342469c0a [tsan] Add a Darwin-specific lit test directory
Differential Revision: http://reviews.llvm.org/D14610

llvm-svn: 252887
2015-11-12 13:27:55 +00:00
Dmitry Vyukov 110094017c tsan: fix Go build on linux
librt is not linked in in Go build.

llvm-svn: 252877
2015-11-12 11:54:25 +00:00
Kuba Brecka ba85da8482 [asan] Remove system_malloc_zone
This seems to be dead code – `system_malloc_zone` is initialized as null and we never assign to it. This code is apparently currently never executed (in ASan), but is causes trouble for the TSan OS X port. Let's replace the checks with `COMMON_MALLOC_ENTER` (`ENSURE_ASAN_INITED()`).

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

llvm-svn: 252876
2015-11-12 11:29:21 +00:00
Dmitry Vyukov 317e98b1a2 tsan: fix unused function warning in Go build
llvm-svn: 252875
2015-11-12 11:14:35 +00:00
Dmitry Vyukov 1421ed42a6 tsan: fix mac Go build
cur_thread does not exist in Go.

llvm-svn: 252874
2015-11-12 11:12:18 +00:00
Kuba Brecka 14fb164a8e [tsan] Filter OS X architectures for unit testing
The TSan unit test build currently fails if we're also building the iOS parts of compiler-rt, because `TSAN_SUPPORTED_ARCH` contains ARM64. For unit tests, we need to filter this only to host architecture(s).

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

llvm-svn: 252873
2015-11-12 11:00:38 +00:00
Dmitry Vyukov 1041aabbb0 tsan: fix flakiness of sleep_sync2 test
llvm-svn: 252869
2015-11-12 10:24:22 +00:00
Kostya Serebryany 673283cc7c [sanitizer coverage] reset global counters in __sanitizer_reset_coverage
llvm-svn: 252815
2015-11-11 22:44:25 +00:00
Chris Bieneman 66c126a042 [CMake] [Darwin] [Builtins] Force setting the flags we care about at the end of the compiler command line
Setting CMAKE_*_FLAGS isn't sufficient here because CMAKE_*_FLAGS_${CMAKE_BUILD_TYPE} can override the flags, and there is no way to safely clear that because it is a cached variable (<sarcasm> YAY! </sarcasm>).

llvm-svn: 252807
2015-11-11 21:38:35 +00:00
Evgeniy Stepanov 77ef54288a [asan] Remove a flaky test.
llvm-svn: 252805
2015-11-11 21:37:12 +00:00
Reid Kleckner 99f23473a1 [Windows] Add exports for dll_host test broken by r252071 and r251071
llvm-svn: 252784
2015-11-11 19:34:01 +00:00
Dmitry Vyukov 3ed274e3ce tsan: fix unused variable in Go build
llvm-svn: 252746
2015-11-11 16:09:20 +00:00
Diego Novillo a245e40a55 Revert r252683 - "Sancov in C++."
This reverts commits r252683 and r252689. This tool should not live here. See
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/311862.html
for discussion.

llvm-svn: 252744
2015-11-11 15:54:31 +00:00
Yury Gribov 8fbd938641 [ASan] Improve portability of new tests.
llvm-svn: 252742
2015-11-11 15:42:26 +00:00
Kuba Brecka fcbb0ec06e [tsan] Rename tsan_test_util_linux.cc to tsan_test_util_posix.cc
Differential Revision: http://reviews.llvm.org/D14575

llvm-svn: 252741
2015-11-11 15:42:00 +00:00
Jay Foad 305586257c Implement some TLS support for PowerPC64.
Summary: This is enough to get the asan static_tls.cc test case working.

Reviewers: eugenis, samsonov

Subscribers: llvm-commits

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

llvm-svn: 252738
2015-11-11 15:37:47 +00:00
Kuba Brecka c603d25a19 Fixing #include order in tsan_new_delete.cc. Follow-up commit for r252284.
llvm-svn: 252735
2015-11-11 15:15:14 +00:00
Kuba Brecka c47620a838 [tsan] Add TSan unit test support for OS X
This patch enables building and running TSan unit tests on OS X.

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

llvm-svn: 252731
2015-11-11 14:53:57 +00:00
Jay Foad 6de11a494f Fix #if tests for PTRACE_GETREGS and others.
Summary:
On PowerPC64 Linux PTRACE_GETREGS is a #define and PT_GETREGS is not.
On other systems it's the other way round. Extend the #ifs to check for
both PTRACE_* and PT_*.

This fixes test/sanitizer_common/TestCases/Linux/ptrace.cc when msan is
enabled for PowerPC64.

Reviewers: zatrazz, kcc, eugenis, samsonov

Subscribers: llvm-commits

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

llvm-svn: 252730
2015-11-11 14:41:17 +00:00
Yury Gribov 159727d417 [ASan] Add stress test for asynch signals in nonhalting mode.
Differential Revision: http://reviews.llvm.org/D14241

llvm-svn: 252729
2015-11-11 14:02:33 +00:00
Yury Gribov e76a7c41e9 [Asan] Added missing hunk to previous commit.
llvm-svn: 252724
2015-11-11 12:23:59 +00:00
Yury Gribov 468d955b98 [ASan] Enable optional ASan recovery.
Differential Revision: http://reviews.llvm.org/D12318

llvm-svn: 252723
2015-11-11 11:59:38 +00:00
Dmitry Vyukov e38d3c8f9f sanitizer: speedup coverage by 33%
Atomic RMW is not necessary in InitializeGuardArray.
It is supposed to run when no user code runs.
And if user code runs concurrently, then the atomic
RMW won't help anyway. So replace it with non-atomic RMW.

InitializeGuardArray takes more than 50% of time during re2 fuzzing:

real	0m47.215s
51.56% a.out a.out [.] __sanitizer_reset_coverage

6.68%  a.out  a.out                [.] __sanitizer_cov
3.41%  a.out  a.out                [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long)
1.79%  a.out  a.out                [.] __asan::Allocator::Allocate(unsigned long, unsigned long,
With this change:

real 0m31.661s
26.21% a.out a.out [.] sanitizer_reset_coverage
10.12% a.out a.out [.] sanitizer_cov

5.38%  a.out  a.out                [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long)
2.53%  a.out  a.out                [.] __asan::Allocator::Allocate(unsigned long, unsigned long,
That's 33% speedup.

Reviewed in http://reviews.llvm.org/D14537

llvm-svn: 252715
2015-11-11 09:36:26 +00:00
Ismail Pazarbasi 26f70505f3 Implement `internal_start/join_thread` on Mac OS X
Summary: Depends on D9637

Test Plan:

Reviewers: kcc, glider, samsonov

Subscribers: llvm-commits

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

llvm-svn: 252696
2015-11-11 02:44:19 +00:00
Ismail Pazarbasi fcb8c7e407 [tsan] Pass correct interposed function prefix to report function
Summary:
On Darwin, interposed functions are prefixed with "wrap_". On Linux,
they are prefixed with "__interceptor_".

Reviewers: dvyukov, samsonov, glider, kcc, kubabrecka

Subscribers: zaks.anna, llvm-commits

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

llvm-svn: 252695
2015-11-11 02:38:38 +00:00
Mike Aizatsky a543f77bdb Disabling sancov.cc on windows.
It can't be built due to cxxabi missing. Will
fix later.

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

llvm-svn: 252689
2015-11-11 02:01:16 +00:00
Mike Aizatsky 125e636b96 Sancov in C++.
Summary:
First batch of sancov.py rewrite in C++.
Supports "-print" and "-covered_functions" commands.

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

llvm-svn: 252683
2015-11-11 01:26:57 +00:00
Chris Bieneman 45c40fff66 [CMake] [macho_embedded] Only set sys root if the variable is set, this prevents passing empty -isysroot arguments
This is a minor cleanup to the macho_embedded builtins.

llvm-svn: 252619
2015-11-10 17:26:40 +00:00
Chris Bieneman 9a6afeb84d [CMake] Cleaning up flags for Darwin builtins
* Setting CMAKE_*_FLAGS_${BUILD_TYPE} isn't really needed since we're setting the same value everywhere
* functions sanitize variables differently from macros, darwin_add_embedded_builtin_libraries should be a macro otherwise it won't alter the variables.

llvm-svn: 252618
2015-11-10 17:26:35 +00:00
Xinliang David Li 854dad77ec Rollback 252570 for further investigation
llvm-svn: 252575
2015-11-10 00:58:22 +00:00
Chris Bieneman 7d824da189 [CMake] Temporary workaround to support building builtins on darwin with a toolchain that may not support all x86 and arm architectures.
This is at least a little better than my first attempt. We still really need a way to do compile checks without linking.

llvm-svn: 252572
2015-11-10 00:41:18 +00:00
Xinliang David Li 7efc57bc19 [PGO] Add LLVM main include dir to profile runtime build
Runtime code implicitly depends on the defintions and const
values defined in LLVM proper, but currently such dependency
is made implicitly by duplicating code across two dirs. As 
part of the PGO cleanup effort, there will be changes to share
common sources. This is a preparation patch to enable it (NFC).

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

llvm-svn: 252570
2015-11-10 00:35:37 +00:00
Chris Bieneman 86af9e07ff Revert "[CMake] [macho_embedded] Check to make sure the compiler supports the architectures before generating build targets"
This commit reverts r252525. I was not really thinking about this fix properly. This doesn't work because it relys on try_compile checks which do a full compile & link. I'm going to put in a temporary solution as an interm step until we have a way to perform compiler checks without linking.

llvm-svn: 252569
2015-11-10 00:31:22 +00:00
Chris Bieneman a9437f5135 [CMake] Don't pass -fPIC when compiling the darwin builtins
This change makes CMake match autoconf.

llvm-svn: 252547
2015-11-09 23:48:58 +00:00
Chris Bieneman 7068fc369d [CMake] Fixing a typo in variable name ARG_*->LIB_*
llvm-svn: 252543
2015-11-09 23:37:45 +00:00
Chris Bieneman ccd9419266 [CMake] Removing extra underscore.
Fixing a typo.

llvm-svn: 252534
2015-11-09 23:20:43 +00:00
Chris Bieneman 7ccc6136b9 [CMake] [Darwin] Don't generate lipo commands if we don't have libraries to put into the fat archive.
Not making sure there are thin libraries results in some difficult to diagnose build failures. This check should make those build failures go away.

llvm-svn: 252527
2015-11-09 23:07:45 +00:00
Chris Bieneman 1ad0146498 [CMake] [macho_embedded] Check to make sure the compiler supports the architectures before generating build targets
If we don't check the compiler's capabilities we end up generating build targets that the compiler might not be able to build.

llvm-svn: 252525
2015-11-09 23:05:05 +00:00
Adhemerval Zanella 18b2258c92 [compiler-rt] [asan] Use same shadow offset for aarch64
This patch makes ASAN for aarch64 use the same shadow offset for all
currently supported VMAs (39 and 42 bits).  The shadow offset is the
same for 39-bit (36).

llvm-svn: 252497
2015-11-09 18:05:24 +00:00
Hans Wennborg dab6b25e38 CFI: try to make test/cfi/base-derived-destructor.cpp pass on Windows
llvm-svn: 252468
2015-11-09 14:25:08 +00:00
Kuba Brecka 8eab127307 [tsan] Skip building libcxx_tsan on OS X
The TSan-instrumented version of libcxx doesn't even build on OS X at this point. Let's skip it from the OS X build for now, since most of TSan functionality doesn't depend on it. This will enable `check-tsan` to be run.

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

llvm-svn: 252455
2015-11-09 09:53:38 +00:00
Xinliang David Li 470bfa9aaa [PGO] Cleanup: fix function-data field names
To make them the same as the common def in InstrProfData.inc.
This is a preparation to make the runtime code  to use the 
template as well. NFC

llvm-svn: 252421
2015-11-08 18:00:13 +00:00
Kuba Brecka be81c28ec6 [tsan] Turn lit test deadlocks into failures (OS X)
Several tests currently deadlock when the lit test suite is run on OS X. Let's mark them as unsupported.

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

llvm-svn: 252402
2015-11-07 14:29:38 +00:00
Chris Bieneman 472d937db7 [CMake] Need to filter ${arch}/*.c builtins as well as ${arch}/*.S builtins.
This was broken in r248542 when I refactored this to support builtins where ${arch} didn't match the directory prefix (i.e. armv7s).

llvm-svn: 252365
2015-11-06 23:19:29 +00:00
Alexey Samsonov edf18d20a0 [ASan] Add two new functions to DLL thunk.
llvm-svn: 252359
2015-11-06 23:04:00 +00:00
Kuba Brecka 9dcecefe67 [tsan] Add Darwin support for lit tests
This patch enables running lit tests on OS X:
1) Simply enable tests for Darwin (they were restricted to Linux and FreeBSD).
2) Disable using instrumented libcxx (libcxx_tsan) on Darwin.
3) On Darwin, override abort_on_error=0, otherwise all tests would generate crash logs and take much longer to process.

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

llvm-svn: 252309
2015-11-06 15:05:34 +00:00
Dmitry Vyukov 4cd631cd7c tsan: make invisible test barrier portable
The current implementation does not work on darwin and can have issues with other OSes in future.
See http://reviews.llvm.org/D14427
Make it portable once and for all (minus usleep call).

Reviewed in:
http://reviews.llvm.org/D14434

llvm-svn: 252292
2015-11-06 11:52:24 +00:00
Kuba Brecka 3a618b0317 [tsan] Enable new/delete C++ interceptors for OS X
This patch adds `tsan_new_delete.cc` into the OS X build.

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

llvm-svn: 252284
2015-11-06 11:07:26 +00:00
Kuba Brecka 1ef2414861 [tsan] Replace pthread_yield with sched_yield in lit tests
OS X doesn't have `pthread_yield`. Let's use `sched_yield` instead.

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

llvm-svn: 252283
2015-11-06 11:05:53 +00:00
Kuba Brecka dccffd4fcc Trying to fix the FreeBSD build breakage due to r251916.
http://lab.llvm.org:8011/builders/sanitizer_x86_64-freebsd/builds/6395

llvm-svn: 252277
2015-11-06 08:16:24 +00:00
Sergey Dmitrouk 195f3a15e6 [compiler-rt][aarch64] New tests for 128-bit floating-point builtins, fixes of tests and __fixuint
Summary:
The following tests for 128-bit floating-point type behaved in a strange way, thought it were bugs, but seem to be mistakes in tests:

 * `fixtfsi` test checked for `0x80000001` as a value returned for number less than can be represented, while `LONG_MIN` should be returned on saturation;
 * `fixunstfdi` wasn't enabled for AArch64, only for PPC, but there is nothing PPC specific in that test;
 * `multf3` tried to underflow multiplication by producing result with 16383 exponent, while there are still 112 bits of fraction plus implicit bit, so resultant exponent should be 16497.

Tests for some other builtins didn't exist:

 * `fixtfdi`
 * `fixtfti`
 * `fixunstfti`

They were made by copying similar files and adjusting for wider types and adding/removing some reasonable/extra checks.

Also `__fixuint` seems to have off by one error, updated tests to catch this case.

Reviewers: rengolin, zatrazz, howard.hinnant, t.p.northover, jmolloy, enefaim

Subscribers: aemerson, llvm-commits, rengolin

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

llvm-svn: 252180
2015-11-05 18:36:42 +00:00
Kuba Brecka 537b6090d1 [tsan] Fix build warnings on OS X
Fixing `tsan_interceptors.cc`, which on OS X produces a bunch of warnings about unused constants and functions.

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

llvm-svn: 252165
2015-11-05 14:32:56 +00:00
Kuba Brecka 9e0cf38d9b Lint warning fixup for r252160 ("[tsan] Fix pthread_once interceptor for OS X").
llvm-svn: 252163
2015-11-05 14:16:42 +00:00
Kuba Brecka 245bcf9eb9 [tsan] Fix the memcpy interceptor to be memmove compatible on OS X
On OS X, memcpy and memmove are actually aliases of the same implementation, which means the interceptor of memcpy is also invoked when memmove is called. The current implementation of the interceptor uses `internal_memcpy` to perform the actual memory operation, which can produce an incorrect result when memmove semantics are expected. Let's call `internal_memmove` instead.

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

llvm-svn: 252162
2015-11-05 14:03:26 +00:00
Kuba Brecka 3d8536240a [tsan] Allow memmove interceptor to be used when TSan is not initialized
A call to memmove is used early during new thread initialization on OS X. This patch uses the `COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED` check, similarly to how we deal with other early-used interceptors.

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

llvm-svn: 252161
2015-11-05 14:01:53 +00:00
Kuba Brecka 12bba1c2a0 [tsan] Fix pthread_once interceptor for OS X
TSan has a re-implementation of `pthread_once` in its interceptor, which assumes that the `pthread_once_t *once_control` pointer is actually pointing to a "storage" which is zero-initialized and used for the atomic operations. However, that's not true on OS X, where pthread_once_t is a structure, that contains a header (with a magic value) and the actual storage follows after that. This patch skips the header to make the interceptor work on OS X.

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

llvm-svn: 252160
2015-11-05 13:59:07 +00:00
Kuba Brecka cd18f28751 [tsan] Alternative ThreadState storage for OS X
This implements a "poor man's TLV" to be used for TSan's ThreadState on OS X. Based on the fact that `pthread_self()` is always available and reliable and returns a valid pointer to memory, we'll use the shadow memory of this pointer as a thread-local storage. No user code should ever read/write to this internal libpthread structure, so it's safe to use it for this purpose. We lazily allocate the ThreadState object and store the pointer here.

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

llvm-svn: 252159
2015-11-05 13:54:50 +00:00
Kuba Brecka 40ad607be6 [tsan] Use malloc zone interceptors on OS X, part 2
TSan needs to use a custom malloc zone on OS X, which is already implemented in ASan.  This patch uses the sanitizer_common implementation in `sanitizer_malloc_mac.inc` for TSan as well.

Reviewed at http://reviews.llvm.org/D14330

llvm-svn: 252155
2015-11-05 10:31:21 +00:00
Alexey Samsonov 96c6ecc842 [Sanitizer] Use ReportMmapFailureAndDie() in all applicable mmap variants on Posix.
llvm-svn: 252121
2015-11-05 01:16:48 +00:00
Alexey Samsonov e5739981d5 [TSan] Fix mmap/mmap64 interceptor signature.
mmap() offset argument has type off_t, not unsigned. off_t is usually
64-bit on 64-bit Linux.

llvm-svn: 252103
2015-11-05 00:00:36 +00:00
Juergen Ributzka d7dcffaea4 Revert "Reapply: [asan] On OS X, log reports to syslog and os_trace"
Looks like this commit is deadlocking the ASAN tests on the green dragon bot
(http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA/).

llvm-svn: 252076
2015-11-04 21:03:12 +00:00
Mike Aizatsky 1e41784f20 Asan: utility function to determine first wrongly poisoned byte in
container.

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

llvm-svn: 252071
2015-11-04 19:56:03 +00:00
Kuba Brecka ef731a9edc Whitespace fixup for r252052. NFC.
llvm-svn: 252053
2015-11-04 15:57:38 +00:00
Kuba Brecka 465cb8a6fa [tsan] Use malloc zone interceptors on OS X, part 1 (refactoring)
TSan needs to use a custom malloc zone on OS X, which is already implemented in ASan.  This patch is a refactoring patch (NFC) that extracts this from ASan into sanitizer_common, where we can reuse it in TSan.

Reviewed at http://reviews.llvm.org/D14330

llvm-svn: 252052
2015-11-04 15:43:45 +00:00
Kuba Brecka a1186b828f [tsan] Handle libdispatch worker threads on OS X
On OS X, GCD worker threads are created without a call to pthread_create. We need to properly register these threads with ThreadCreate and ThreadStart. This patch uses a libpthread API (`pthread_introspection_hook_install`) to get notifications about new threads and about threads that are about to be destroyed.

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

llvm-svn: 252049
2015-11-04 15:09:14 +00:00
Kuba Brecka 88bccf0344 [tsan] Shadow memory setup for OS X
Updating the shadow memory initialization in `tsan_platform_mac.cc` to also initialize the meta shadow and to mprotect the memory ranges that need to be avoided.

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

llvm-svn: 252044
2015-11-04 11:39:40 +00:00
Kuba Brecka 77f16f369b [tsan] Allow memchr interceptor to be used before initialization on OS X
On OS X, `memchr` is called on a newly created thread even before `__tsan_thread_start_func` is invoked, which means that the ThreadState object for that thread will not yet be initialized. Let's add `COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED` into the interceptor to simply call `internal_memchr` in these cases.

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

llvm-svn: 251935
2015-11-03 16:19:37 +00:00
Martell Malone 53f8a53fb6 Fix r251928 build error
llvm-svn: 251931
2015-11-03 16:04:28 +00:00
Martell Malone 40eb83ba56 Support for 32-bit mingw-w64 in compiler-rt.
Add chkstk/alloca for gcc objects.
Replace or instructions with test, the latter should be marginally more
efficent, as it does not write to memory.

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

Patch by vadimcn

llvm-svn: 251928
2015-11-03 15:46:23 +00:00
Kuba Brecka 127f669913 Fixup for r251923 to fix a warning about an extra semicolon.
llvm-svn: 251924
2015-11-03 14:45:32 +00:00
Kuba Brecka 149012153c Reapply r251916 ("[tsan] Port TSan interceptors on OS X").
llvm-svn: 251923
2015-11-03 14:43:39 +00:00
Kuba Brecka 9d71caa9a4 Revert r251916 ("[tsan] Port TSan interceptors on OS X").
llvm-svn: 251922
2015-11-03 14:42:03 +00:00
Kuba Brecka cf41c0c930 Reapply r251918 ("[tsan] Fix build errors for TSan on OS X").
llvm-svn: 251920
2015-11-03 14:33:39 +00:00
Kuba Brecka 646e1bef09 Revert r251918 ("[tsan] Fix build errors for TSan on OS X").
llvm-svn: 251919
2015-11-03 14:30:31 +00:00
Kuba Brecka 350a9aaeda [tsan] Fix build errors for TSan on OS X
This patch moves a few functions from `sanitizer_linux_libcdep.cc` to `sanitizer_posix_libcdep.cc` in order to use them on OS X as well. Plus a few more small build fixes.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.

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

llvm-svn: 251918
2015-11-03 14:26:00 +00:00
Kuba Brecka 0ca1e2c3f9 [tsan] Port TSan interceptors on OS X
This patch modifies `tsan_interceptors.cc` to be buildable on OS X. Several of the intercepted methods are not available on OS X, so we need to `#if !SANITIZER_MAC` them. Plus a few other fixes, e.g. `pthread_yield` doesn't exist, let's use `internal_sched_yield` instead.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.

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

llvm-svn: 251916
2015-11-03 14:22:51 +00:00
Kuba Brecka c9249498ce [tsan] CMake support for TSan on OS X
Hi, this patch adds a CMake flag called `COMPILER_RT_ENABLE_TSAN_OSX`, which is off by default. If enabled, the build system will be building the OS X version of the TSan runtime library (called `libclang_rt.tsan_osx_dynamic.dylib`). I'll submit patches that fix OS X build errors shortly.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.

llvm-svn: 251915
2015-11-03 14:13:59 +00:00
Alexey Samsonov a49cfd8f94 Revert "Apply modernize-use-default to compiler-rt."
This reverts commit r250823.

Replacing at least some of empty
constructors with "= default" variants is a semantical change which we
don't want. E.g. __tsan::ClockBlock contains a union of large arrays,
and it's critical for correctness and performance that we don't memset()
these arrays in the constructor.

llvm-svn: 251717
2015-10-30 18:52:31 +00:00
Saleem Abdulrasool d006c9368d Sanitizer: define WIN32_LEAN_AND_MEAN
Define WIN32_LEAN_AND_MEAN before including Windows.h.  This is already being
done in some places.  This does it more broadly.  This permits building ASAN on
Linux for Winndows, as well as reduces the amount of included declarations.

llvm-svn: 251649
2015-10-29 20:36:55 +00:00
Adhemerval Zanella 689724e578 [compiler-rt] [msan] Unify aarch64 mapping
This patch unify the 39-bit and 42-bit mapping for aarch64 to use only
one instrumentation algorithm.  A runtime check avoid mapping 42-bit 
only segments for 39-bit kernels.

The mapping to use now is for 39 and 42-bits:

    0x00000000000ULL-0x01000000000ULL  MappingDesc::INVALID
    0x01000000000ULL-0x02000000000ULL  MappingDesc::SHADOW
    0x02000000000ULL-0x03000000000ULL  MappingDesc::ORIGIN
    0x03000000000ULL-0x04000000000ULL  MappingDesc::SHADOW
    0x04000000000ULL-0x05000000000ULL  MappingDesc::ORIGIN
    0x05000000000ULL-0x06000000000ULL  MappingDesc::APP
    0x06000000000ULL-0x07000000000ULL  MappingDesc::INVALID
    0x07000000000ULL-0x08000000000ULL  MappingDesc::APP

And only for 42-bits:

    0x08000000000ULL-0x09000000000ULL  MappingDesc::INVALID
    0x09000000000ULL-0x0A000000000ULL  MappingDesc::SHADOW
    0x0A000000000ULL-0x0B000000000ULL  MappingDesc::ORIGIN
    0x0B000000000ULL-0x0F000000000ULL  MappingDesc::INVALID
    0x0F000000000ULL-0x10000000000ULL  MappingDesc::APP
    0x10000000000ULL-0x11000000000ULL  MappingDesc::INVALID
    0x11000000000ULL-0x12000000000ULL  MappingDesc::APP
    0x12000000000ULL-0x17000000000ULL  MappingDesc::INVALID
    0x17000000000ULL-0x18000000000ULL  MappingDesc::SHADOW
    0x18000000000ULL-0x19000000000ULL  MappingDesc::ORIGIN
    0x19000000000ULL-0x20000000000ULL  MappingDesc::INVALID
    0x20000000000ULL-0x21000000000ULL  MappingDesc::APP
    0x21000000000ULL-0x26000000000ULL  MappingDesc::INVALID
    0x26000000000ULL-0x27000000000ULL  MappingDesc::SHADOW
    0x27000000000ULL-0x28000000000ULL  MappingDesc::ORIGIN
    0x28000000000ULL-0x29000000000ULL  MappingDesc::SHADOW
    0x29000000000ULL-0x2A000000000ULL  MappingDesc::ORIGIN
    0x2A000000000ULL-0x2B000000000ULL  MappingDesc::APP
    0x2B000000000ULL-0x2C000000000ULL  MappingDesc::INVALID
    0x2C000000000ULL-0x2D000000000ULL  MappingDesc::SHADOW
    0x2D000000000ULL-0x2E000000000ULL  MappingDesc::ORIGIN
    0x2E000000000ULL-0x2F000000000ULL  MappingDesc::APP
    0x2F000000000ULL-0x39000000000ULL  MappingDesc::INVALID
    0x39000000000ULL-0x3A000000000ULL  MappingDesc::SHADOW
    0x3A000000000ULL-0x3B000000000ULL  MappingDesc::ORIGIN
    0x3B000000000ULL-0x3C000000000ULL  MappingDesc::APP
    0x3C000000000ULL-0x3D000000000ULL  MappingDesc::INVALID
    0x3D000000000ULL-0x3E000000000ULL  MappingDesc::SHADOW
    0x3E000000000ULL-0x3F000000000ULL  MappingDesc::ORIGIN
    0x3F000000000ULL-0x40000000000ULL  MappingDesc::APP

And although complex it provides a better memory utilization that
previous one.

[1] http://reviews.llvm.org/D13817

llvm-svn: 251625
2015-10-29 13:04:19 +00:00
Anna Zaks 7920eb0b1f Reapply: [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
        of the report to stderr. This patch changes this behavior and writes the full
        text of the report to syslog before we terminate the process. It also calls
        os_trace (Activity Tracing available on OS X and iOS) with a message saying
        that the report is available in syslog. This is useful, because this message
        will be shown in the crash log.

        For this to work, the patch makes sure we store the full report into
        error_message_buffer unconditionally, and it also strips out ANSI escape
        sequences from the report (they are used when producing colored reports).

        I've initially tried to log to syslog during printing, which is done on Android
        right now. The advantage is that if we crash during error reporting or the
        produced error does not go through ScopedInErrorReport, we would still get a
        (partial) message in the syslog. However, that solution is very problematic on
        OS X. One issue is that the logging routine uses GCD, which may spawn a new
        thread on its behalf. In many cases, the reporting logic locks threadRegistry,
        which leads to deadlocks.

        Reviewed at http://reviews.llvm.org/D13452

        (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid
         build failures on Linux.)

llvm-svn: 251577
2015-10-28 23:18:44 +00:00
Evgeniy Stepanov 2253d1c052 [asan] Fix asan_device_setup script on KitKat.
app_process32, when started via a shell script wrapper, needs a
different security context to satisty SELinux.

Patch by Abhishek Arya.

llvm-svn: 251572
2015-10-28 22:55:12 +00:00
Evgeniy Stepanov d10e6280cb [asan] Disable a flaky test on Android.
Bug: https://github.com/google/sanitizers/issues/618
llvm-svn: 251554
2015-10-28 20:45:52 +00:00
Ivan Krasin 1fe5fab905 sanitizer_common: be more verbose, when symbolizer is not found.
Summary:
I have othen been stuck when I got an ASAN report, but no symbols
are resolved. The reasons might be different, and it always 
requires a bit of detective work to track down.

These more verbose error messages will help the users like me.

Reviewers: samsonov

Subscribers: llvm-commits

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

llvm-svn: 251553
2015-10-28 20:45:34 +00:00
Anna Zaks 55fbb6d7f5 Revert "[asan] On OS X, log reports to syslog and os_trace"
This reverts commit 251447.

(Which caused failures on a Linux bot.)

llvm-svn: 251467
2015-10-27 23:15:05 +00:00
Daniel Sanders 6c583b8b25 [mips][asan] XFAIL ptrace.cc
It was recently enabled for non-x86 targets and doesn't seem to work for MIPS.
The reason is currently unclear so XFAILing while I investigate.

llvm-svn: 251466
2015-10-27 23:13:26 +00:00
Anna Zaks 9a95c9a633 [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
of the report to stderr. This patch changes this behavior and writes the full
text of the report to syslog before we terminate the process. It also calls
os_trace (Activity Tracing available on OS X and iOS) with a message saying
that the report is available in syslog. This is useful, because this message
will be shown in the crash log.

For this to work, the patch makes sure we store the full report into
error_message_buffer unconditionally, and it also strips out ANSI escape
sequences from the report (they are used when producing colored reports).

I've initially tried to log to syslog during printing, which is done on Android
right now. The advantage is that if we crash during error reporting or the
produced error does not go through ScopedInErrorReport, we would still get a
(partial) message in the syslog. However, that solution is very problematic on
OS X. One issue is that the logging routine uses GCD, which may spawn a new
thread on its behalf. In many cases, the reporting logic locks threadRegistry,
which leads to deadlocks.

Reviewed at http://reviews.llvm.org/D13452

llvm-svn: 251447
2015-10-27 20:13:01 +00:00
Anna Zaks 55f195f5ae [asan] Sort headers.
llvm-svn: 251446
2015-10-27 20:12:55 +00:00
Anna Zaks ab1aa08191 [asan] On OS X, tag mapped regions with VM_MEMORY_ANALYSIS_TOOL tag
This will tag all mmapped memory sanitizers use with "Performance tool data"
when viewed in vmmap. (Even though sanitizers are not performance tools, it's
the best available match and better than having the unidentified objects.)

http://reviews.llvm.org/D13609

llvm-svn: 251445
2015-10-27 20:12:53 +00:00
Daniel Sanders 171d6fa35d Attempt to fix asan's ptrace.cc on the clang-cmake-mips builder after r251331.
llvm-svn: 251379
2015-10-27 01:35:57 +00:00
Evgeniy Stepanov 12ffb42893 [msan] Yet another attempt to fix process_vm_readv test.
llvm-svn: 251372
2015-10-27 00:11:28 +00:00
Evgeniy Stepanov f0344626d2 [asan] Mark 5 tests unsupported on Android.
llvm-svn: 251362
2015-10-26 22:19:50 +00:00
Evgeniy Stepanov fb38728241 [asan] Fix throw-call-test to properly XFAIL on android/aarch64.
The test is sensitive to stack layout changes. Tweak it a bit to
expose the bug on aarch64 as well as on arm.

llvm-svn: 251361
2015-10-26 22:19:47 +00:00
Evgeniy Stepanov 798d4f0329 [asan] Switch back to BFD linker in asan/android tests.
We've switched to Gold earlier because of a minor misconfiguration
of the BFD linker in Android NDK. It turns out, Gold has much bigger
problems:

https://sourceware.org/bugzilla/show_bug.cgi?id=19163
(a bug is actually in the android runtime loader, but it means that
gold does not work with android L and even M).

Switching back to BFD and adding a workaround by explicitly linking
libm to all tests.

llvm-svn: 251360
2015-10-26 22:19:46 +00:00
Evgeniy Stepanov 9944209a0a [asan] Don't use asanwrapper in 64-bit android tests.
Asanwrapper is required on older android versions to work around undesired
linker behavior. It is not required on L and newer, and does not fully
support multiarch devices.

llvm-svn: 251359
2015-10-26 22:19:44 +00:00
Alexey Samsonov c6de580afe asan_symbolize.py: Call llvm-symbolizer with --functions=linkage instead of --functions=short.
llvm-svn: 251356
2015-10-26 21:48:49 +00:00
Evgeniy Stepanov 1a1973b846 [msan] Fix process_vm_readv test.
The check for the glibc version was not working as expected (dlsym
was finding the interceptor instead of the libc implementation).

llvm-svn: 251345
2015-10-26 20:55:35 +00:00
Adhemerval Zanella 6153ecc4fd [compiler-rt] Fix ptrace interceptor for aarch64
This patch fixes the ptrace interceptor for aarch64. The PTRACE_GETREGSET
ptrace syscall with with invalid memory might zero the iovec::iov_base
field and then masking the subsequent check after the syscall (since it
will be 0 and it will not trigger an invalid access). The fix is to copy
the value on a local variable and use its value on the checks.

The patch also adds more coverage on the Linux/ptrace.cc testcase by addding
check for PTRACE_GETREGSET for both general and floating registers (aarch64
definitions added only).

llvm-svn: 251331
2015-10-26 18:55:04 +00:00
Adhemerval Zanella 871d324799 [compiler-rt] Enable ptrace sanitizer for arm
This patch enables the ptrace syscall interceptors for arm and adds support
for both PTRACE_GETVFPREGS and PTRACE_SETVFPREGS used to get the VFP register
from ARM.

The ptrace tests is also updated with arm and PTRACE_GETVFPREGS tests.

llvm-svn: 251321
2015-10-26 18:15:14 +00:00
Hal Finkel 9f42bf047c Fixup test/ubsan/TestCases/Misc/coverage-levels.cc, LLVM is smarter
Fixing up this test case because LLVM is smarter now, and can better analyze:

  if ((argc << shift) == 16)

in this test case.

llvm-svn: 251147
2015-10-23 20:37:51 +00:00
Evgeniy Stepanov 1e9aadba17 [msan] Re-submit test for process_vm_readv.
Includes a workaround for glibc < 2.15, which does not provide the
function under test.

llvm-svn: 251079
2015-10-23 00:00:22 +00:00
Evgeniy Stepanov 7b04acd28d [msan] Temporarily remove a failing test to fix the bot.
The test requires a newer glibc version that the one on the bot.

llvm-svn: 251077
2015-10-22 23:40:06 +00:00
Kostya Serebryany e3d25c3873 [sanitizer-coverage] introduce __sanitizer_get_total_unique_caller_callee_pairs
llvm-svn: 251071
2015-10-22 22:06:41 +00:00
Evgeniy Stepanov 0d933e0b27 [msan] Intercept process_vm_readv/writev.
llvm-svn: 251059
2015-10-22 20:35:42 +00:00
Yury Gribov 8da1408277 [asan] Get rid of UB in string tests. Patch by Max Ostapenko.
Differential revision: http://reviews.llvm.org/D13895

llvm-svn: 250998
2015-10-22 08:10:56 +00:00
Evgeniy Stepanov 86713d90c7 [msan] Build unit test shared library code with -fPIC.
llvm-svn: 250957
2015-10-21 22:13:36 +00:00
Adhemerval Zanella b0d5dd0199 [lsan] [aarch64] Add support for AArch64
This patch add support for leak sanitizer for aarch64.  Similar to
MIPS it uses a SizeClassAllocator32 due VMA constraints (aarch64
currently supports 39 and 42-bit VMA).

It also fixes the android build issue.

llvm-svn: 250898
2015-10-21 13:08:06 +00:00
Ivan Krasin cffe8caed3 Disabling speculative loads under asan.
Summary:
While instrumenting std::string with asan I discovered that speculative load might load data from poisoned region. Disabling all speculative loads for asan-annotated functions.

The test follows the std::string implementation.

Corresponding CL in llvm: http://reviews.llvm.org/D13264
Patch by Mike Aizatsky, the review page for the CL is http://reviews.llvm.org/D13265

Reviewers: aizatsky

Subscribers: kcc, llvm-commits

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

llvm-svn: 250837
2015-10-20 17:34:47 +00:00
Angel Garcia Gomez ea61047c6f Apply modernize-use-default to compiler-rt.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: klimek, bkramer

Subscribers: alexfh, cfe-commits

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

llvm-svn: 250823
2015-10-20 12:53:50 +00:00
Yury Gribov 34f4561220 [ubsan] Fix looksLikeFloatCastOverflowDataV1 heuristic to work if one of the types is unknown.
Differential revision: http://reviews.llvm.org/D13775

llvm-svn: 250806
2015-10-20 08:40:52 +00:00
Evgeniy Stepanov 0b98b27677 [msan] Intercept mincore.
llvm-svn: 250761
2015-10-19 23:39:11 +00:00
Evgeniy Stepanov cc25301092 [msan] Intercept pthread_getcancel*.
llvm-svn: 250752
2015-10-19 23:00:13 +00:00
Xinliang David Li d7134ead18 [PGO] Eliminate prof data register calls on FreeBSD platform
This is a follow up patch of r250199 after verifying the start/stop
section symbols work as spected on FreeBSD.

llvm-svn: 250680
2015-10-19 04:17:19 +00:00
Xinliang David Li 4da5de9c34 Use struct type instead of raw array for raw profile header (NFC)
This patch introduces a well defined header struct
to represent raw profile header instead of using raw array.
Previously the raw array is used in two different files and
is very error prone when header structure is re-organized.
This is a small cleanup with NFC.

llvm-svn: 250561
2015-10-16 22:21:56 +00:00
Saleem Abdulrasool b5bba5c256 builtins: Expand out floating point exponents for MSVC
MSVC 2013 doesnt support C99 fully, including the hexidecimal floating point
representation.  Use the expanded value to permit building with it.

Patch by Tee Hao Wei!

llvm-svn: 250365
2015-10-15 04:26:19 +00:00
Saleem Abdulrasool 9ca87a63ad builtins: use C implementation on MSVC
The assembly implementations use GNU syntax which MSVC doesn't handle.  Rather
than duplicate the code in a second syntax, use the C implementations.

Patch by Tee Hao Wei!

llvm-svn: 250360
2015-10-15 02:47:19 +00:00
Saleem Abdulrasool 956365ef7f builtins: __builtin_clzll for x86 on MSVC
Add an implementation for __builtin_clzll on MSVC even when _BitScanForward4 is
unavailable.

Patch by Tee Hao Wei!

llvm-svn: 250359
2015-10-15 02:46:37 +00:00
Xinliang David Li f556a7e3c3 [PGO]: Eliminate calls to __llvm_profile_register_function for Linux.
On Linux, the profile runtime can use __start_SECTNAME and __stop_SECTNAME
symbols defined by the linker to locate the start and end location of
a named section (with C name). This eliminates the need for instrumented
binary to call __llvm_profile_register_function during start-up time.

llvm-svn: 250200
2015-10-13 18:40:00 +00:00
Evgeniy Stepanov c7ee62c561 [msan] Add __msan_copy_shadow interface function.
This can be used to annotate copies of memory that are not observed by MSan.

llvm-svn: 250124
2015-10-12 23:20:24 +00:00
Evgeniy Stepanov f4ebc08831 [asan] Zero initialize sem_t in sem_init.
Old version of sem_init (GLIBC_2.0) fails to initialize parts of
sem_t that are used in sem_timedwait. This is fixed in GLIBC_2.1,
but since ASan interceptors downgrade sem_* to the oldest available
version, this can introduce bugs that are only present in sanitized
build. Workaround by zero-initializing sem_t in sem_init.

llvm-svn: 250113
2015-10-12 21:32:30 +00:00
Filipe Cabecinhas 150def9787 [ubsan] Invoke test program using %run.
llvm-svn: 250063
2015-10-12 16:33:40 +00:00
Saleem Abdulrasool 565872584b Revert "builtins: enable builtins build for MSVC"
Revert once more.  This seems to fail to build on the buildbots which build with
ninja rather than MSBuild/Visual Studio.  This requires further build
infrastructure changes to deal with the assembly routines.

llvm-svn: 250001
2015-10-11 22:30:10 +00:00
Saleem Abdulrasool 76e70699d5 Revert "Revert "builtins: enable builtins build for MSVC""
Previous changes should now permit building on MSVC 2013 in addition to MSVC
2015.

llvm-svn: 250000
2015-10-11 22:00:46 +00:00
Saleem Abdulrasool e49971517a builtins: define and use ALWAYS_INLINE
Abstract out the always inline spelling similar to ASAN.  NFC.

llvm-svn: 249986
2015-10-11 17:35:42 +00:00
Saleem Abdulrasool 8b3353f20f builtins: use NORETURN macro
Now that we have the NORETURN macro, use that to mark the function as noreturn,
rather than the GNU __attribute__.

llvm-svn: 249985
2015-10-11 17:35:38 +00:00
Saleem Abdulrasool 911cfc11c4 builtins: spell inline as __inline
__inline is a vendor specific spelling for inline.  clang and gcc treat it the
same as inline, and is available in MSVC 2013 which does not implement C99
(VS2015 supports the inline keyword though).  This will allow us to build the
builtins using MSVC.

llvm-svn: 249953
2015-10-10 21:21:28 +00:00
Saleem Abdulrasool 114aae4ac7 Revert "builtins: enable builtins build for MSVC"
Seems to break on the sanitizer buildbot.  Revert until it can be fixed
properly.

llvm-svn: 249950
2015-10-10 18:52:01 +00:00
Saleem Abdulrasool 9650c4a26e builtins: silence a MSVC warning
_BitReverse64 is only available on ARM and x64.  Guard it accordingly.

llvm-svn: 249949
2015-10-10 17:57:37 +00:00
Saleem Abdulrasool fbd8bb6fee builtins: enable builtins build for MSVC
Patch by Tee Hao Wei!

llvm-svn: 249948
2015-10-10 17:57:33 +00:00
Chris Bieneman 6ed46bd380 [CMake] [macho_embedded] [builtins] Need to also drop the bswap builtins.
llvm-svn: 249914
2015-10-09 22:46:19 +00:00
Chris Bieneman 626f6a057c [CMake] Adding support for generating libclang_rt.eprintf.a
This library provides eprintf for i386 on OS X versions later than 10.4.

llvm-svn: 249913
2015-10-09 22:40:50 +00:00
Chris Bieneman 0ed9bc1995 [CMake] hand tuning the macho_embedded export lists to match the current Xcode distribution.
llvm-svn: 249912
2015-10-09 22:40:47 +00:00
Chris Bieneman b9cca18f11 [CMake] Hand tuning the exclude lists for libclang_rt.10.4.a
llvm-svn: 249888
2015-10-09 19:53:54 +00:00
Chris Bieneman 2c23a80bbf [CMake] [Darwin] [builtins] Need to special case the naming of the OS X cc_kext builtin library.
llvm-svn: 249870
2015-10-09 18:38:34 +00:00
Chris Bieneman 4ebd15726f [CMake] [darwin] [builitins] Don't build x86_64h into the 10.4 builtins library
There is no haswell support in 10.4, so we don't need a 10.4 builtin library.

llvm-svn: 249868
2015-10-09 18:32:34 +00:00
Chris Bieneman 3a1ad39702 [CMake] [Darwin] [Builtins] Fixing a typo that was keeping the OS X 10.4 builtins library from being built properly.
llvm-svn: 249844
2015-10-09 16:47:43 +00:00
Reid Kleckner 8da160173c Remove the XFAIL for the C++ EH test
It works on Windows now.

llvm-svn: 249799
2015-10-09 01:33:15 +00:00
Evgeniy Stepanov 6870dc7311 Fix msan tests build.
CMake build rules listed -I flags for two different libc++ header
locations which broke when libc++ headers started using include_next.

Also change -I to -isystem to avoid compiler warning about
include_next.

llvm-svn: 249759
2015-10-08 22:21:36 +00:00
Evgeniy Stepanov b688a47963 New MSan mapping layout (compiler-rt part).
This is an implementation of
https://github.com/google/sanitizers/issues/579

It has a number of advantages over the current mapping:
* Works for non-PIE executables.
* Does not require ASLR; as a consequence, debugging MSan programs in
  gdb no longer requires "set disable-randomization off".
* Supports linux kernels >=4.1.2.
* The code is marginally faster and smaller.

This is an ABI break. We never really promised ABI stability, but
this patch includes a courtesy escape hatch: a compile-time macro
that reverts back to the old mapping layout.

llvm-svn: 249754
2015-10-08 21:35:34 +00:00
Evgeniy Stepanov 437615639f Revert "[lsan] [aarch64] Add support for AArch64"
This reverts commit ea02fa45225c35613bfecab383fb526e24b74497 (r249337).

Reason: broken "ninja AsanUnitTests" on Android/AArch64.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/20675/steps/build%20compiler-rt%20android%2Faarch64/logs/stdio

llvm-svn: 249730
2015-10-08 20:08:30 +00:00
Alexey Samsonov d9cc7f884f Provide missing Internal{Alloc, Free} declarations for libbacktrace symbolizer.
Summary:
Since r223145 we don't include sanitizer_allocator_internal.h into
sanitizer_symbolizer.h, so we can have undefined reference to
Internal{Alloc, Free} stuff into sanitizer_symbolizer_libbacktrace.cc under
SANITIZER_CP_DEMANGLE macro.

This patch simply includes appropriate header into
sanitizer_symbolizer_libbacktrace.h to resolve the issue.

Patch by Maxim Ostapenko!

Reviewers: kcc, eugenis, samsonov

Subscribers: llvm-commits, ygribov

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

llvm-svn: 249633
2015-10-07 23:13:28 +00:00
Oliver Stannard 28d2edad5b Add ARM RTABI aliases for half-precision conversions
The ARM RTABI defines these functions as __aeabi_h2f, __aeabi_f2h and
__aeabi_d2h, so we need aliases for them.

llvm-svn: 249559
2015-10-07 16:15:22 +00:00
Saleem Abdulrasool e597ace1fe builtins: fix build
__GNUC__ indicates the GNU compiler, not __GNU__.  This got through due to
building with clang rather than gcc.

llvm-svn: 249516
2015-10-07 03:30:02 +00:00
Saleem Abdulrasool 396e794459 builtins: implement instrinics for cl
cl does not support the same intrinsics as clang.  Provide implementations for
the intrinsics using MSVC builtins.

Patch by Tee Hao Wei!

llvm-svn: 249515
2015-10-07 02:58:11 +00:00
Saleem Abdulrasool b0b7c8a8dd builtins: emulate _Complex for cl
cl does not support C99 completely as of VS2015.  Emulate _Complex to allow
building with MSVC.

Patch by Tee Hao Wei!

llvm-svn: 249514
2015-10-07 02:58:07 +00:00
Saleem Abdulrasool 71c47e5a86 builtins: use MSVC intrinsics with cl
Use MSVCRT functions for floating-point builtins unavailable on MSVC.

Patch by Tee Hao Wei!

llvm-svn: 249513
2015-10-07 02:58:02 +00:00
Renato Golin 814e5caebc [LSAN] Mark death callback as unstable while we investigate the cause in AArch64
llvm-svn: 249398
2015-10-06 13:29:44 +00:00
Vasileios Kalintiris 0943a95f46 [builtins] Enable building of the builtins library for MIPS targets.
Reviewers: howard.hinnant, samsonov

Subscribers: samsonov, dsanders, llvm-commits

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

llvm-svn: 249382
2015-10-06 09:02:38 +00:00
Saleem Abdulrasool d2eb26c7f0 builtins: fix build
Unfortunately, int_utils.h needs to depend on int_lib for the common macro
definitions.  However, currently, int_utils.h is included by int_lib.h.  Reorder
the inclusion to work around this.

llvm-svn: 249376
2015-10-06 04:33:08 +00:00
Saleem Abdulrasool e6f9652a22 builtins: Use MSVC-equivalents of attributes
This allows us to build the builtins using MSVC.  NFC.

Patch by Tee Hao Wei!

llvm-svn: 249375
2015-10-06 04:33:05 +00:00
Saleem Abdulrasool 4c81f0a1be builtins: tweak constant spelling
Use 4294967296.f instead of 0x1p32f to fix MSVC.  NFC.

Patch by Tee Hao Wei!

llvm-svn: 249374
2015-10-06 04:33:02 +00:00
Saleem Abdulrasool 89a92b9fb2 builtins: tweak Windows build
Include Windows.h instead of winbase.h and windef.h

Patch by Tee Hao Wei!

llvm-svn: 249373
2015-10-06 04:32:59 +00:00
Keno Fischer e16edb554f [compiler-rt] Properly detect lack of available system libraries for arch in clang_darwin.mk
Summary: This is the Makefile analog of r247833, except that the test also had to be changed such that clang actually attempts to link the program as opposed to just building it. Because of that change, I also switched the order to checking for ld/clang architecture support, because now lack of ld support would make the clang check fail. This fixes PR24776.

Reviewers: beanz

Subscribers: llvm-commits

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

llvm-svn: 249358
2015-10-05 22:24:12 +00:00
Adhemerval Zanella 5ea8dcb8cf [lsan] [aarch64] Add support for AArch64
This patch add support for leak sanitizer for aarch64.  Similar to
MIPS it uses a SizeClassAllocator32 due VMA constraints (aarch64
currently supports 39 and 42-bit VMA).

llvm-svn: 249337
2015-10-05 19:16:09 +00:00
Daniel Sanders bb9c116165 [asan][mips] Fix ABI incompatibility crash in pthread_create() following r248325.
Like i386, Mips needs a versioned interceptor but must select GLIBC_2.2.

llvm-svn: 249307
2015-10-05 12:43:47 +00:00
Chris Bieneman f9d71a5439 [CMake] [darwin] Removing a line of debug code that I accidentally committed.
llvm-svn: 249278
2015-10-04 15:48:16 +00:00
Chris Bieneman be8b60b602 [CMake] [darwin] [builtins] Add INSTALL_DIR to darwin_lipo_libs
The darwin and macho_embedded libraries get installed to different locations, so we need to feed through an INSTALL_PATH.

llvm-svn: 249199
2015-10-02 22:14:25 +00:00
Evgeniy Stepanov 06e338b403 [asan] Disable pthread_create_version test on mips.
llvm-svn: 249191
2015-10-02 21:23:53 +00:00
Chris Bieneman b22351cb18 [CMake] Workaround for the lipo output directory not being created.
This should resolve an issue reported by mclow.

llvm-svn: 249158
2015-10-02 17:37:40 +00:00
Chris Bieneman f0672f1187 [CMake] [builtins] [macho_embedded] Separate out the 64-bit thumb builtins so they don't get included on 'm' architectures. NFC.
This should help make the compiler-rt build less noisy.

llvm-svn: 249084
2015-10-01 22:01:06 +00:00
Chris Bieneman f9e0fe77c7 [CMake] [builtins] [macho_embedded] Don't pass -mfloat-abi=hard flag to x86 because the compiler ignores it and complains.
llvm-svn: 249076
2015-10-01 21:21:19 +00:00
Chris Bieneman 55745688c6 [CMake] [builtins] [OS X] Adding all builtins that generate empty object files for OS X to the exclude lists.
This should help make the compiler-rt build less noisy.

llvm-svn: 249070
2015-10-01 21:04:17 +00:00
Chris Bieneman d943670a82 [CMake] [builtins] [iOS Sim] Adding all builtins that generate empty object files for the iOS simulator to the exclude lists.
This should help make the compiler-rt build less noisy.

llvm-svn: 249068
2015-10-01 21:03:00 +00:00
Chris Bieneman f14b3f10a8 [CMake] [iOS] [builtins] Adding all builtins that generate empty object files for iOS to the exclude lists.
This should help make the compiler-rt build less noisy.

llvm-svn: 249057
2015-10-01 19:26:29 +00:00
Chris Bieneman adfe26fdbd [CMake] Only build the simulator builtins if you're also building the device builtins.
This matters because simulator builtins get lipo'd together with the device builtins into a single static archive per-platform.

llvm-svn: 249056
2015-10-01 19:26:26 +00:00
Chris Bieneman 291723353a [CMake] Only add an OS to the supported OS lists if there are supported architectures for that OS.
llvm-svn: 249054
2015-10-01 18:58:59 +00:00
Evgeniy Stepanov 74697714c2 [asan] Tweak gen_dynamic_list.py to work with both Py2 and Py3.
llvm-svn: 249051
2015-10-01 18:27:28 +00:00
Evgeniy Stepanov 8adbded6a4 [asan] Tune down SizeClassAllocator tests.
This should make the Android/x86 bot (running on a Nexus Player) less
flaky.

llvm-svn: 249044
2015-10-01 17:59:08 +00:00
Vedant Kumar f7ed23f744 [compiler-rt] Fix build (again) by wrapping lines to 80 chars (NFC)
llvm-svn: 248979
2015-10-01 02:15:40 +00:00
Vedant Kumar f997bd88d7 [compiler-rt] Fix build by wrapping lines to 80 chars (NFC)
llvm-svn: 248973
2015-10-01 00:48:07 +00:00
Vedant Kumar 59ba7b8cd1 [compiler-rt] Apply modernize-use-nullptr fixes in sanitizers
- Trim spaces.
- Use nullptr in place of 0 for pointer variables.
- Use '!p' in place of 'p == 0' for null pointer checks.
- Add blank lines to separate function definitions.
- Add 'extern "C"' or 'namespace foo' comments after the appropriate
  closing brackets

This is a continuation of work from 409b7b82. The focus here is on the
various sanitizers (not sanitizer_common, as before).

Patch by Eugene Zelenko!

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

llvm-svn: 248966
2015-10-01 00:22:21 +00:00
Vedant Kumar 552c0111f1 [sanitizer_common] Apply modernize-use-nullptr, other minor fixes
- Trim spaces.
- Use nullptr in place of 0 for pointer variables.
- Use '!p' in place of 'p == 0' for null pointer checks.

Patch by Eugene Zelenko!

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

llvm-svn: 248964
2015-09-30 23:52:54 +00:00
Evgeniy Stepanov 25c58d124b [asan] Fix asan_symbolize.py handling of non-existing paths
llvm-svn: 248962
2015-09-30 23:17:39 +00:00
Ivan Krasin 97746d75bb CFI: add a test from base-to-derived cast from the base destructor.
Summary: This adds an interesting bad cast case, originally found in https://crbug.com/537398.

Reviewers: kcc

Subscribers: pcc

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

llvm-svn: 248958
2015-09-30 23:08:55 +00:00
Chris Bieneman b1ff6e4260 [CMake] [Darwin] Add and populate PROFILE_SUPPORTED_OS to enable building libclang_rt.profile for iOS.
llvm-svn: 248948
2015-09-30 21:23:22 +00:00
Chris Bieneman 7bfe1ee428 [CMake] [Darwin] [macho_embedded] Specify the version min explicitly.
We need to set the OS X deployment target on the macho_embedded libraries to match the outputs from the autoconf build system.

llvm-svn: 248944
2015-09-30 21:09:23 +00:00
Chris Bieneman af01508cc3 [CMake] [Darwin] [builtins] Add support for building libclang_rt.10.4.a
This builtin library is used when setting the OS X deployment target to 10.4, which we still support.

llvm-svn: 248940
2015-09-30 20:26:14 +00:00
Chris Bieneman d823302483 [CMake] [Darwin] [builtins] Change condition for skipping cc_kext to be setting based.
This is needed because we need to skip cc_kext generation for more than just the simulator builds.

llvm-svn: 248939
2015-09-30 20:25:10 +00:00
Chris Bieneman d208e41030 [CMake] [macho_embedded] We need to set some extra flags when building the macho_embedded builtins.
If we don't specify the arm target the float ABI compiler flags get ignored.

llvm-svn: 248853
2015-09-29 23:21:09 +00:00
Chris Bieneman d868fef16c [CMake] [Darwin] [builtins] Make CMake re-generate if the builtin filter lists change.
We need to make sure that if you change the builtin filter lists CMake re-generates its configurations so it includes the right builtins in the generated libraries.

llvm-svn: 248852
2015-09-29 23:21:07 +00:00
Chris Bieneman 6e18e1e39e [CMake] [Darwin] Support building the macho_embedded builtin libraries.
Summary: This ports functionality from the clang_macho_embedded.mk platform makefile over to CMake.

Reviewers: bogner, samsonov, bob.wilson

Subscribers: llvm-commits

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

llvm-svn: 248850
2015-09-29 23:13:45 +00:00
Evgeniy Stepanov 01e4c87a5a [msan] Disable allocator_mapping test on mips64 and aarch64.
llvm-svn: 248835
2015-09-29 22:24:57 +00:00
Alexey Samsonov 4133c18b1c [CFI] Make CFI tests require UBSan (for diagnostic mode).
CFI itself, on the other hand, doesn't require anything, including
sanitizer_common.

llvm-svn: 248830
2015-09-29 21:43:37 +00:00
Evgeniy Stepanov 7aba3960c7 [msan] Early allocator initialization.
Map MSan heap space early (in __msan_init) so that user code can not
accidentally (i.e. w/o MAP_FIXED) create a conflicting mapping.

llvm-svn: 248829
2015-09-29 21:28:54 +00:00
Renato Golin 9be32f6317 Add armhf as unstable runtime temporarily
llvm-svn: 248819
2015-09-29 18:35:55 +00:00
Kostya Serebryany 0c3a5767d9 [sanitizer] Fix Clang-tidy modernize-use-nullptr warnings in lib/sanitizer_common headers, unify closing inclusion guards. Patch by Eugene Zelenko
llvm-svn: 248816
2015-09-29 18:23:36 +00:00
Chris Bieneman 5def2a8a44 [CMake] [Darwin] [builtins] Apply OS and OS-arch filters to cc_kext builtin libraries.
We don't want to filter out the builtins that are present in libSystem like we do for the normal builtins because kexts can't link libSystem, but we should filter out all the builtins that are generally not supported on the OS and architecture.

llvm-svn: 248756
2015-09-28 23:09:46 +00:00
Chris Bieneman 88d8534e87 [CMake] Accidentally committed code that was using a variable only populated in some earlier code. NFC.
llvm-svn: 248752
2015-09-28 22:20:25 +00:00
Chris Bieneman 1341472f92 [CMake] [Darwin] [builtins] Fix building builtins for Darwin simulator platforms.
For Darwin simulator platforms we shouldn't build the cc_kext builtins at all because they aren't applicable, and we should includ the simulator builtins as slices inside the main platform builtin library.

llvm-svn: 248751
2015-09-28 22:18:31 +00:00
Chris Bieneman 4b16003590 [CMake] [Darwin] [builtins] Exclude aeabi builtins from iOS arm32 architectures since we don't support aeabi on iOS.
llvm-svn: 248744
2015-09-28 21:15:46 +00:00
Chris Bieneman 8aba4b0589 [CMake] [Darwin] Make darwin_filter_builtin_sources support both whitelist and blacklist filtering.
llvm-svn: 248720
2015-09-28 17:38:44 +00:00
Saleem Abdulrasool 0165015f6c builtins: silence GCC warning
If the builtins are built with libgcc as the unwind provider on ARM, the exposed
_Unwind_SetIP is a macro.  This results in the following warning due to
expansion of the argument:

warning: suggest parentheses around arithmetic in operand of ‘|’ [-Wparentheses]

Add a no-op set of parenthesis around the argument that will prevent this
warning.

llvm-svn: 248686
2015-09-27 17:16:46 +00:00
Saleem Abdulrasool f88e4fabb5 build: separate flags
This somehow worked with the build on Linux, but seems to fail on the buildbots.
Split the flags apart here as otherwise the two flags are treated as one, and
cause a compilation failure.

llvm-svn: 248654
2015-09-26 04:40:45 +00:00
Saleem Abdulrasool 29e12a1128 sanitizer: fix -pedantic warnings
Silence a few "warning: extra ';'" warnings from GCC.

llvm-svn: 248653
2015-09-26 04:40:42 +00:00
Saleem Abdulrasool 96c5023e53 build: create two versions of ARM builtins
This adds a new name for ARM32 (armhf).  We now force that the default build for
ARM32 (arm) to be soft-float ABI.  This has a corresponding clang change to look
for these names based on the floating point ABI.  The functions are built
identically (the functions are marked as AAPCS, so the calling convention does
not change, as per the RTABI specification), however, the object file contains
attributes indicating the build configuration which the linker will ensure are
not mix and matched.  We now built the appropriate named archive so that we can
link properly.

llvm-svn: 248648
2015-09-26 03:26:01 +00:00
Chris Bieneman bb62ec2cd6 [CMake] [darwin] [builtins] Make darwin_lipo_libs take OUTPUT_DIR as an option. NFC.
This refactoring will allow me to reuse this function when calling lipo with outputs in different directories.

llvm-svn: 248639
2015-09-25 23:55:53 +00:00
Chris Bieneman cc8c7773c5 [CMake] [darwin] Refactor darwin_read_exclude_file to be reusable. NFC.
Rename darwin_read_exclude_file to more generic darwin_read_list_from_file, and make it take the file path instead of constructing it so it can be reused more freely.

llvm-svn: 248635
2015-09-25 23:29:03 +00:00
Chris Bieneman 905f9fce0a [CMake] [darwin] [builtins] Should install the lipo'd builtin libraries.
On darwin we don't install the single-architecture builtin libraries, but we do need to install the lipo'd ones.

llvm-svn: 248630
2015-09-25 22:39:19 +00:00
Chris Bieneman 75c7c9ce8b [CMake] [darwin] [builtins] Should be reading the OS variable that is passed in, not the bleed through from the function above. NFC.
llvm-svn: 248629
2015-09-25 22:31:17 +00:00
Chris Bieneman 7146f7bcf9 [CMake] [darwin] [cc_kext] In addition to builtin sources the cc_kext builtins include some functions from clang_rt.profile.
llvm-svn: 248548
2015-09-24 22:29:58 +00:00
Chris Bieneman 590a48d4de [CMake] [darwin] [builtins] Refactoring darwin_find_excluded_builtins_list to parse arguments instead of only handling positional arguments.
OS and ARCH must be specified, but minimum version may not. Excluding the minimum version will only apply the filters for builtins not supported by the OS and OS-Arch pair.

llvm-svn: 248543
2015-09-24 21:51:09 +00:00
Chris Bieneman 5fbaeb9e5c [CMake] [darwin] [builtins] Refactoring code to filter builtin lists out into a function. NFC.
llvm-svn: 248542
2015-09-24 21:40:06 +00:00
Chris Bieneman 4acaa8fd9d [autoconf] Fixing a bug I introduced r248441
llvm-svn: 248529
2015-09-24 19:35:36 +00:00
Chris Bieneman 9b788a452b [CMake] [darwin] [builtins] Match clang_darwin.mk's compiler flags when building builtin libraries
On Darwin we have a very restrictive set of flags used when building the builtins. This change makes CMake match autoconf.

llvm-svn: 248523
2015-09-24 18:26:34 +00:00
Dmitry Vyukov 2fe0efcc69 tsan: add test for issue #602
llvm-svn: 248522
2015-09-24 17:38:56 +00:00
Chris Bieneman d983ae0a0e [CMake] pass -Wno-pedantic to cc_kext builtins build
We don't pass -pedantic to the builtin builds in the makefiles, so we shouldn't do it here. This is a temporary fix for the broken bot:

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_build/7526/warnings8Result/new/

A more correct solution is in the works.

llvm-svn: 248515
2015-09-24 16:47:26 +00:00
Vasileios Kalintiris 22db068008 Be consistent in the way we define 32/64-bit arches in ALL_*_SUPPORTED_ARCH variables. NFC.
Reviewers: samsonov

Subscribers: llvm-commits

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

llvm-svn: 248514
2015-09-24 16:45:58 +00:00
Chris Bieneman 01ebf004ff [CMake] [Darwin] Bug 21562 - Add a CMake equivalent for make/platform/clang_darwin.mk in compiler_rt
Summary: First pass at adding cc_kext_* builtin libraries. I need to cleanup and refactor the builtin filtering so that I can use it to filter the builtin symbols list, but this is the first step in the right direction.

Reviewers: bob.wilson, bogner, samsonov

Subscribers: llvm-commits

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

llvm-svn: 248443
2015-09-23 23:05:32 +00:00
Chris Bieneman eb71c99684 [darwin] [builtins] Stop generating cc_kext_ios5 and move iOS architectures out of cc_kext into cc_kext_ios
Summary:
Xcode 7 doesn't support targeting iOS5 and earlier. Instead of just dropping cc_kext_ios5, I've repurposed it to cc_kext_ios, and I'm pulling the iOS architectures out of cc_kext. Putting OS X and iOS slices inside the same archive was just odd.

There is a cooresponding clang change coming too.

Reviewers: bogner, bob.wilson

Subscribers: llvm-commits

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

llvm-svn: 248441
2015-09-23 22:52:26 +00:00
Chris Bieneman 2a6c13274c [CMake] [builtins] Only include the atomic builtins if(APPLE).
There are lingering issues building the atomic builtins with various versions of gcc. To unblock people we can only include them on Apple platforms where they are more tested.

llvm-svn: 248386
2015-09-23 15:28:44 +00:00
Chris Bieneman 9c46be2d2f Code cleanup based on post-commit review from Aaron Ballman.
llvm-svn: 248385
2015-09-23 15:28:35 +00:00
Chris Bieneman 0d427986f5 [CMake] [Darwin] Bug 21562 - Add a CMake equivalent for make/platform/clang_darwin.mk in compiler_rt
Summary:
Building the builtins on Darwin platforms is a bit complicated. This is a first-pass implementation of the functionality from clang_darwin.mk into CMake.

When building the builtins on Darwin we have layers of blacklists that we apply based on platform, architecture, and minimum supported OS version.

Reviewers: bogner, filcab, bob.wilson, samsonov

Subscribers: llvm-commits

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

llvm-svn: 248383
2015-09-23 15:18:17 +00:00
Chris Bieneman be61720c4e [builtins] Fixing broken bot building on linux with -Werror
Returning a void expression is bad.

llvm-svn: 248346
2015-09-22 23:35:24 +00:00
Evgeniy Stepanov a7ecbe5685 [asan] Add missing -pthread in tests.
llvm-svn: 248332
2015-09-22 22:24:46 +00:00
Chris Bieneman 0a9466c11e [builtins] One more stab at fixing the bots.
llvm-svn: 248330
2015-09-22 22:19:21 +00:00
Chris Bieneman 7908b12967 [builtins] Fixing atomic builtins to be compiled out if stdatomic.h isn't available.
This should fix the bots broken by r248322.

Reviewed by bogner over my shoulder.

llvm-svn: 248328
2015-09-22 21:50:43 +00:00
Evgeniy Stepanov 9147de0ddf [asan] Versioned interceptor for pthread_create.
This fixes a crash in pthread_create on linux/i386 due to abi
incompatibility between intercepted and non-intercepted functions.

See the test case for more details.

llvm-svn: 248325
2015-09-22 21:34:44 +00:00
Chris Bieneman 54445f92a9 [CMake] Add atomic builtins to GENERIC_SOURCES list.
Reviewers: bogner, samsonov

Subscribers: llvm-commits

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

llvm-svn: 248322
2015-09-22 21:18:19 +00:00
Renato Golin 7716df5b7d Disable final MSAN test in AArch64 to get the bots green
llvm-svn: 248014
2015-09-18 18:02:55 +00:00
Renato Golin 4610486e88 Disable one MSAN test in AArch64 until we have a proper fix
llvm-svn: 248008
2015-09-18 17:22:48 +00:00
Adhemerval Zanella dab7043d89 [compiler-rt] [sanitizer] Clean buildbot failures for aarch64
Currently aarch64 lacks instrumentation support for variadic arguments
for MSan.  This patch sets the UBSan tests that uses it as to require
stable-runtime and sets aarch64/ubsan as an unstable one.

llvm-svn: 247996
2015-09-18 15:48:32 +00:00
Evgeniy Stepanov 6e663a1e32 Revert "ubsan: Implement memory permission validation for vtables."
This reverts r247484 and two follow-up commits.
Breaks ppc and x86_64 sanitizer bots.

llvm-svn: 247921
2015-09-17 19:15:54 +00:00
Reid Kleckner 3e9d733e68 [Windows] xfail a test that uses C++ EH
llvm-svn: 247845
2015-09-16 20:32:22 +00:00
Evgeniy Stepanov 10c9ea51a0 Fix compilation warning in compiler-rt.
error: width of bit-field 'allocated' (8 bits) exceeds the width of
its type; value will be truncated to 1 bit [-Werror,-Wbitfield-width]

llvm-svn: 247840
2015-09-16 19:54:36 +00:00
Chris Bieneman 672311b368 [CMake] Make the sample program in darwin_test_archs have a symbol it needs to link.
This resolves an issue building compiler-rt using Xcode 7 that was reported on llvm-dev:

http://lists.llvm.org/pipermail/llvm-dev/2015-September/090245.html

llvm-svn: 247833
2015-09-16 18:29:52 +00:00
Adhemerval Zanella 19074450ee [MSan] Enable MSAN for aarch64
This patch enabled msan for aarch64 with 39-bit VMA and 42-bit VMA.
As defined by lib/msan/msan.h the memory layout used is for 39-bit is:

   00 0000 0000 - 40 0000 0000:  invalid
   40 0000 0000 - 43 0000 0000:  shadow
   43 0000 0000 - 46 0000 0000:  origin
   46 0000 0000 - 55 0000 0000:  invalid
   55 0000 0000 - 56 0000 0000:  app (low)
   56 0000 0000 - 70 0000 0000:  invalid
   70 0000 0000 - 80 0000 0000:  app (high)

And for 42-bit VMA:

   000 0000 0000 - 100 0000 0000:  invalid
   100 0000 0000 - 11b 0000 0000:  shadow
   11b 0000 0000 - 120 0000 0000:  invalid
   120 0000 0000 - 13b 0000 0000:  origin
   13b 0000 0000 - 2aa 0000 0000:  invalid
   2aa 0000 0000 - 2ab 0000 0000:  app (low)
   2ab 0000 0000 - 3f0 0000 0000:  invalid
   3f0 0000 0000 - 400 0000 0000:  app (high)

Most of tests are passing with exception of:

   * Linux/mallinfo.cc
   * chained_origin_limits.cc
   * dlerror.cc
   * param_tls_limit.cc
   * signal_stress_test.cc
   * nonnull-arg.cpp

The 'Linux/mallinfo.cc' is due the fact AArch64 returns the sret in 'x8'
instead of default first argument 'x1'.  So a function prototype that
aims  to mimic (by using first argument as the return of function) won't
work. For GCC one can make a register alias (register var asm ("r8")), but
for clang it detects is an unused variable and generate wrong code.

The 'chained_origin_limits' is probably due a wrong code generation,
since it fails only when origin memory is used
(-fsanitize-memory-track-origins=2) and only in the returned code
(return buf[50]).

The 'signal_streess_test' and 'nonnull-arg' are due currently missing variadic
argument handling in memory sanitizer code instrumentation on LLVM side.

Both 'dlerror' and 'param_tls_test' are unknown failures that require
further investigation.

All the failures are XFAIL for aarch64 for now.

llvm-svn: 247809
2015-09-16 15:12:25 +00:00
Naomi Musgrave 36597fa128 Explicit reference to bug highlighted by
test/msan/dtor-trivial.cpp. Runtime testing for poisoning
vtable pointer in dtor.

Summary: Runtime testing for vtable ptr poisoning in dtor.

Reviewers: eugenis, kcc

Subscribers: llvm-commits

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

Clean test case & comments.

Update tests for vptr poisoning order.

Simplify test to rely upon globals.

Assertions verify that vtable still accessible from dtors.

Testing linear inheritance and multiple inheritance for vtable poisoning.

Macros for testing expected failing functions.

Rename macros.

Removed xfail, modified FileCheck commands, to expect test to crash.

llvm-svn: 247763
2015-09-16 00:41:28 +00:00
Alexey Samsonov f23dee5408 [ASan] Add test for .preinit_array/.init_array/.fini_array sections.
llvm-svn: 247737
2015-09-15 23:06:17 +00:00
Adhemerval Zanella 172cc32ef3 [sanitizer] Move CheckVMASize after flag initialization
llvm-svn: 247684
2015-09-15 13:22:54 +00:00
Alexey Samsonov 1b76da6a6c Support inline functions symbolization in Addr2Line symbolizer.
Patch by Maxim Ostapenko!

Summary:
Right now, Addr2Line symbolizer in asan_symbolize.py doesn't support inline functions symbolization. This might be a useful feature for using ASan on embedded systems.

Test results:

$ cat test.c

static inline void FooBarBaz() {
  __sanitizer_print_stack_trace();
}

int main() {
  FooBarBaz();
  return 0;
}

$ clang  test.c -fsanitize=address -g -O2 -o test.x && ./test.x &> /tmp/test.log
$ ./projects/compiler-rt/lib/asan/scripts/asan_symbolize.py  -l /tmp/test.log
    #0 0x42095e in __sanitizer_print_stack_trace _asan_rtl_
    #1 0x4cec07 in FooBarBaz /home/max/build/llvm/asan/test.c:4
    #2 0x4cec07 in main /home/max/build/llvm/asan/test.c:8
    #3 0x7f89f0891ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287

Reviewers: glider, samsonov

Subscribers: jevinskie, llvm-commits, ygribov

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

llvm-svn: 247642
2015-09-14 23:56:42 +00:00