summaryrefslogtreecommitdiffstats
path: root/compiler-rt
Commit message (Collapse)AuthorAgeFilesLines
...
* [CMake] Fix broken uses of `try_compile_only()` and improve the function.Dan Liew2019-03-153-4/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: There were existing calls to `try_compile_only()` with arguments not prefixed by `SOURCE` or `FLAGS`. These were silently being ignored. It looks like the `SOURCE` and `FLAGS` arguments were first introduced in r278454. One implication of this is that for a builtins only build for Darwin (see `darwin_test_archs()`) it would mean we weren't actually passing `-arch <arch>` to the compiler). This would result in compiler-rt claiming all supplied architectures could be targetted provided the compiler could build for Clang's default architecture. This patch fixes this in several ways. * Fixes all incorrect calls to `try_compile_only()`. * Adds code to `try_compile_only()` to check for unhandled arguments and raises a fatal error if this occurs. This should stop any incorrect calls in the future. * Improve the documentation on `try_compile_only()` which seemed completely wrong. rdar://problem/48928526 Reviewers: beanz, fjricci, dsanders, kubamracek, yln, dcoughlin Subscribers: mgorny, jdoerfert, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D59429 llvm-svn: 356295
* [TSan][libdispatch] Enable linking and running of tests on LinuxJulian Lettner2019-03-155-5/+26
| | | | | | | | | | | | | | | | | | | | | When COMPILER_RT_INTERCEPT_LIBDISPATCH is ON the TSan runtime library now has a dependency on the blocks runtime and libdispatch. Make sure we set all the required linking options. Also add cmake options for specifying additional library paths to instruct the linker where to search for libdispatch and the blocks runtime. This allows us to build TSan runtime with libdispatch support without installing those libraries into default linker library paths. `CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY` is necessary to avoid aborting the build due to failing the link step in CMake's check_c_compiler test. Reviewed By: dvyukov, kubamracek Differential Revision: https://reviews.llvm.org/D59334 llvm-svn: 356281
* [msan] Fix BMI2 detection in msan tests, take 2.Jonas Hahnfeld2019-03-151-1/+1
| | | | | | | It's not enough if only one bit is present, we need to check that both are set. This finally fixes the test failures for me. llvm-svn: 356242
* [NFC][TSan] Move libdispatch tests into their own subfolderJulian Lettner2019-03-1414-31/+18
| | | | | | | | | | | | | | | | | Remove 'gcd' file prefix. GCD stands for Grand Central Dispatch, which is another name for libdispatch. https://apple.github.io/swift-corelibs-libdispatch/ Remove `REQUIRE: dispatch` from tests. Also rename lit feature 'dispatch' -> 'libdispatch' to be more explicit what this is about. Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D59341 llvm-svn: 356202
* [TSan][libdispatch] Remove dependency on system headersJulian Lettner2019-03-142-15/+75
| | | | | | | | | | | | | | | | | | | | | | | Including <dispatch/dispatch.h> and <Blocks.h> transitively pulls in other system headers. Let's try to avoid that. Blocks.h: compiler-rt already includes a blocks runtime. Just use the header file that comes with it. dispatch.h: Declare the bare minimum required for our implementation, i.e., everything needed to define the interceptors, but not the interceptors themselves. See tsan_dispatch_defs.h. I spotted a few other places in compile-rt, where we declare libdispatch types. Maybe this file can be moved to sanitizer_common if we deem it useful enough. tsan_libdispatch.cc now compiles on Linux/Clang (requires support for -fblocks). Linking still requires some manual configuration. Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D59145 llvm-svn: 356201
* [HWASan] Use less Printf() calls in register dump.Mitch Phillips2019-03-141-16/+22
| | | | | | | | | | | | | | | | | | | | Summary: Explicitly print 4 registers/line in each iteration during register dump. Reduces logcat spam as we get a single logcat message per call to Printf(), even if the output isn't newline-terminated. This brings the output format in logcat closer to that of the normal textual dump. Reviewers: eugenis, pcc Reviewed By: pcc Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D59320 llvm-svn: 356166
* AddressSanitizer: 64-bit SPARC/Linux portVitaly Buka2019-03-123-1/+118
| | | | | | | | | | | | | | | | | | | Summary: This patch contains the bits required to make the AddressSanitizer work on SPARC64/Linux (SPARC-T4 and later). Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka, krytarowski Reviewed By: #sanitizers, vitalybuka Subscribers: brad, vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58434 llvm-svn: 355980
* AddressSanitizer: fix for SPARC with GCCVitaly Buka2019-03-121-0/+4
| | | | | | | | | | | | | | | | | | | Summary: This patch contains a fixlet for the AddressSanitizer on the SPARC with GCC, which would otherwise generate a problematic call to the intercepted memcpy routine. It was tested with GCC on SPARC/Solaris and SPARC/Linux. Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka Reviewed By: #sanitizers, vitalybuka Subscribers: vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58433 llvm-svn: 355979
* SanitizerCommon: 64-bit SPARC/Linux portVitaly Buka2019-03-123-0/+20
| | | | | | | | | | | | | | | | | | | Summary: This patch contains the bits required to make the common 32-bit allocator work on SPARC64/Linux. Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka Reviewed By: #sanitizers, vitalybuka Subscribers: krytarowski, vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58432 llvm-svn: 355978
* SanitizerCommon: fixes for unwinding & backtrace on SPARCVitaly Buka2019-03-125-35/+75
| | | | | | | | | | | | | | | | | | | Summary: This patch contains various fixes for the unwinding and backtrace machinery on the SPARC, which doesn't work correctly in various cases. It was tested with GCC on SPARC/Solaris and SPARC/Linux. Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka Reviewed By: #sanitizers, vitalybuka Subscribers: jrtc27, delcypher, vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58431 llvm-svn: 355965
* [scudo][standalone] Implement checksumming functionsKostya Kortchinsky2019-03-126-0/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This CL implements the checksumming functions. This departs from the current Scudo code in one aspect: the software version is no longer CRC32 but a BSD checksum. This is because the software CRC32 was too impactful in terms of performances, the BSD checksum has no array lookup which is better (and saves 1KB of data). As with the current version, we only flip the CRC compiler flag for a single compilation unit by default, to allow for a library compiled with HW CRC32 to work on a system without HW CRC32. There is some platform & hardware specific code in those files, but since departs from a mere platform split, it felt right to me to have it that way. Reviewers: morehouse, eugenis, vitalybuka, hctim, mcgrathr Reviewed By: morehouse Subscribers: mgorny, delcypher, jfb, jdoerfert, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D59116 llvm-svn: 355923
* [msan] Fix BMI2 detection in msan tests.Evgeniy Stepanov2019-03-121-1/+1
| | | | llvm-svn: 355885
* Remove ASan asm instrumentation.Evgeniy Stepanov2019-03-113-311/+0
| | | | | | | | | | | | | | Summary: It is incomplete and has no users AFAIK. Reviewers: pcc, vitalybuka Subscribers: srhines, kubamracek, mgorny, krytarowski, eraman, hiraditya, jdoerfert, #sanitizers, llvm-commits, thakis Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D59154 llvm-svn: 355870
* Remove esan.Nico Weber2019-03-1149-4224/+1
| | | | | | | | | | | It hasn't seen active development in years, and it hasn't reached a state where it was useful. Remove the code until someone is interested in working on it again. Differential Revision: https://reviews.llvm.org/D59133 llvm-svn: 355862
* [HWASan] Remove address significance from tag_mismatch.Mitch Phillips2019-03-111-6/+0
| | | | | | Actually fix the issue referenced in rL355840. llvm-svn: 355844
* [HWASan] Fixed minor AArch64/GCC build error.Mitch Phillips2019-03-111-0/+4
| | | | | | | Fixed buildbot clang-cmake-aarch64-lld by ensuring clang-only features are guarded by clang-only #defines. llvm-svn: 355840
* [HWASan] Save + print registers when tag mismatch occurs in AArch64.Mitch Phillips2019-03-087-8/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change change the instrumentation to allow users to view the registers at the point at which tag mismatch occured. Most of the heavy lifting is done in the runtime library, where we save the registers to the stack and emit unwind information. This allows us to reduce the overhead, as very little additional work needs to be done in each __hwasan_check instance. In this implementation, the fast path of __hwasan_check is unmodified. There are an additional 4 instructions (16B) emitted in the slow path in every __hwasan_check instance. This may increase binary size somewhat, but as most of the work is done in the runtime library, it's manageable. The failure trace now contains a list of registers at the point of which the failure occured, in a format similar to that of Android's tombstones. It currently has the following format: Registers where the failure occurred (pc 0x0055555561b4): x0 0000000000000014 x1 0000007ffffff6c0 x2 1100007ffffff6d0 x3 12000056ffffe025 x4 0000007fff800000 x5 0000000000000014 x6 0000007fff800000 x7 0000000000000001 x8 12000056ffffe020 x9 0200007700000000 x10 0200007700000000 x11 0000000000000000 x12 0000007fffffdde0 x13 0000000000000000 x14 02b65b01f7a97490 x15 0000000000000000 x16 0000007fb77376b8 x17 0000000000000012 x18 0000007fb7ed6000 x19 0000005555556078 x20 0000007ffffff768 x21 0000007ffffff778 x22 0000000000000001 x23 0000000000000000 x24 0000000000000000 x25 0000000000000000 x26 0000000000000000 x27 0000000000000000 x28 0000000000000000 x29 0000007ffffff6f0 x30 00000055555561b4 ... and prints after the dump of memory tags around the buggy address. Every register is saved exactly as it was at the point where the tag mismatch occurs, with the exception of x16/x17. These registers are used in the tag mismatch calculation as scratch registers during __hwasan_check, and cannot be saved without affecting the fast path. As these registers are designated as scratch registers for linking, there should be no important information in them that could aid in debugging. Reviewers: pcc, eugenis Reviewed By: pcc, eugenis Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, hiraditya, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58857 llvm-svn: 355738
* [msan] Properly guard tests added by r355348; NFCHubert Tong2019-03-081-4/+2
| | | | | | | r355348 uses builtins without proper guards, breaking the test on various platforms. llvm-svn: 355718
* [TSan] Initialize libdispatch interceptors if necessaryJulian Lettner2019-03-082-0/+46
| | | | | | | | | | | | On Linux (and other non-Darwin platforms) we need to initialize interceptors. Since tsan_libdispatch.cc is compiled optionally, add a weak default implementation of `InitializeLibdispatchInterceptors`. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D59113 llvm-svn: 355717
* Reland compiler-rt support for order file instrumentation.Manman Ren2019-03-0810-0/+172
| | | | | | | | | | | | | | r355343 was landed and was reverted in r355363 due to build breakage. This patch adds Linux/Windows support on top of r355343. In this patch, Darwin should be working with testing case. Linux should be working, I will enable the testing case in a follwup diff. Windows/Other should be building. Correct implementation for Other platforms will be added. Thanks David for reviewing the original diff, helping me with issues on Linux, and giving suggestions for adding support for Other platforms. llvm-svn: 355701
* [sanitizer] Update global_symbols.txtClement Courbet2019-03-081-0/+1
| | | | | | Add `bcmp` after r355672. llvm-svn: 355692
* [scudo][standalone] Adding a stats classKostya Kortchinsky2019-03-074-0/+152
| | | | | | | | | | | | | | | | | | | | Summary: This adds simple local & global stats classes to be used by the Primary and Secondary, and associated test. Note that we don't need the strict atomicity of the addition & subtraction (as is in sanitizer_common) so we just use load & store. Reviewers: morehouse, vitalybuka, eugenis, flowerhack, dmmoore415 Reviewed By: morehouse, vitalybuka Subscribers: mgorny, delcypher, jfb, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D59031 llvm-svn: 355643
* [TSan] Temporarily disable test which fails on build botJulian Lettner2019-03-071-0/+3
| | | | llvm-svn: 355642
* [TSan] Temporarily disable test which fails on build botJulian Lettner2019-03-071-0/+3
| | | | llvm-svn: 355633
* Delete x86_64 ShadowCallStack supportVlad Tsyrklevich2019-03-077-31/+8
| | | | | | | | | | | | | | | | | | | | | Summary: ShadowCallStack on x86_64 suffered from the same racy security issues as Return Flow Guard and had performance overhead as high as 13% depending on the benchmark. x86_64 ShadowCallStack was always an experimental feature and never shipped a runtime required to support it, as such there are no expected downstream users. Reviewers: pcc Reviewed By: pcc Subscribers: mgorny, javed.absar, hiraditya, jdoerfert, cfe-commits, #sanitizers, llvm-commits Tags: #clang, #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D59034 llvm-svn: 355624
* [NFC][TSan] Remove unnecessary #includeJulian Lettner2019-03-071-1/+0
| | | | llvm-svn: 355620
* [TSan][Linux] Fix libdispatch interception macros compilation errorsJulian Lettner2019-03-071-10/+16
| | | | | | | | | | | | | | | | | | | Most libdispatch functions come in two variants: callbacks can be specified via blocks or function pointers. Some of our interceptors for the block variant actually forward to the function variant. However, on Linux, `DECLARE_REAL(name)` has to appear before `REAL(name)`. This patch reorders _f variant interceptors before _b variants where possible and forward declares the _f variant in the remaining cases (cyclic dependency between _f and _b interceptors). Also rename macro to DISPATCH_INTERCEPT_ASYNC_F for better consistency. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D59067 llvm-svn: 355619
* [NFC][TSan] Add libdispatch tests for non-Darwin platformsJulian Lettner2019-03-0712-0/+540
| | | | | | | | | | | | Add new sets of tests (copy instead of move existing tests) because there could be subtle differences between C/Obj-C and with/without Foundation etc. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D59047 llvm-svn: 355618
* [Sanitizer] Add 'dispatch' feature to be used in compiler-rt testsJulian Lettner2019-03-073-0/+6
| | | | | | | | Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D59037 llvm-svn: 355617
* [NFC][TSan][libdispatch] Rename tsan_block_context_t -> block_context_tJulian Lettner2019-03-061-29/+27
| | | | | | | 'tsan_' part of the struct name is redundant since we are already inside the __tsan namespace. llvm-svn: 355539
* [tsan] Support interception of libdispatch on LinuxJulian Lettner2019-03-063-7/+17
| | | | | | | | | | | | | | | | | | | | | | | This is a new attempt for bringing TSan libdispatch support to Linux. The main issue with the last patch (https://reviews.llvm.org/D53171) was that we want to avoid building a separate library. The updated plan is as follows: 1) Hide libdispatch support behind a flag: true on Darwin, false elsewhere. If flag is specified, assume that libdispatch header and -flbocks is available for building. This way we can directly include the libdispatch header and rely on blocks runtime for our implementation. 2) Optionally/weakly intercept libdispatch API functions. This patch accomplishes 1). It compiles (without the flag enabled) on Linux. Follow-up patches will provide 2) and enabling of tests on Linux. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D58935 llvm-svn: 355538
* Always compare C++ typeinfo (based on libstdc++ implementation).Martin Liska2019-03-062-3/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D58028 llvm-svn: 355488
* [scudo][standalone] Add bytemap classesKostya Kortchinsky2019-03-054-0/+178
| | | | | | | | | | | | | | | | | | | | Summary: The bytemap classes will be used by the primary32 allocator to associate classes with memory regions. It's similar to the sanitizer_common one except for the fact that the base (level1) maps are mapped instead of being static to reduce the memory footprint of an uninitialized allocator. Reviewers: vitalybuka, eugenis, morehouse, flowerhack, dmmoore415, mcgrathr Reviewed By: vitalybuka, morehouse Subscribers: mgorny, delcypher, jfb, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D58723 llvm-svn: 355416
* [sanitizers] Don't use Windows Trace Logging with Clang in MSVC mode eitherMartin Storsjo2019-03-051-1/+1
| | | | | | | | | | | | | | | The TraceLoggingProvider.h header does work with clang-cl in general these days with Win SDK 10.0.17763.0, but when compiled in 32 bit x86 mode, with the -Z7 flag, compilation fails with the following error: fatal error: error in backend: assembler label '' can not be undefined With older Win SDKs, there are other build failures (regardless of architecture or the -Z7 flag). Differential Revision: https://reviews.llvm.org/D58958 llvm-svn: 355397
* [NFC] Simplify BufferedStackTrace::UnwindImplVitaly Buka2019-03-051-17/+8
| | | | llvm-svn: 355381
* [NFC] Move isUnwinding check into ScopedUnwindingVitaly Buka2019-03-051-6/+19
| | | | llvm-svn: 355380
* [NFC] Move ScopedUnwinding from .h to .ccVitaly Buka2019-03-052-12/+14
| | | | llvm-svn: 355377
* [NFC] Reorder ifs in BufferedStackTrace::UnwindImplVitaly Buka2019-03-051-12/+16
| | | | llvm-svn: 355376
* [NFC] Return on SANITIZER_MIPS && !IsValidFrameVitaly Buka2019-03-051-6/+6
| | | | llvm-svn: 355372
* [NFC] Put bp into Unwind(.. false) for consistencyVitaly Buka2019-03-051-2/+2
| | | | | | It's not used there anyway llvm-svn: 355371
* [NFC] Move asan_inited and size reset on top of ::UnwindImplVitaly Buka2019-03-051-16/+16
| | | | llvm-svn: 355370
* Revert "[NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation"Vitaly Buka2019-03-052-19/+19
| | | | | | | | I've missed that UnwindSlow was removed from ScopedUnwinding. This reverts commit 4ce918e3942f0333ccb7d65d6265f4fc5f5324be. llvm-svn: 355369
* Revert compiler-rt diffs for order file instrumentation to get bot green!Manman Ren2019-03-0510-169/+0
| | | | | | | | This caused issues on Linux/Windows and other platforms. r355343 355350 355350 llvm-svn: 355363
* Attemp to fix windows profile-rt build breakage.Manman Ren2019-03-051-0/+1
| | | | | | Followup to D57530. llvm-svn: 355357
* [NFC][Sanitizer] Cleanup ASan's GetStackTrace implementationJulian Lettner2019-03-052-19/+19
| | | | | | | | | | | | | | | | | | | | | Cleanup ASan's __sanitizer::BufferedStackTrace::UnwindImpl (formerly GetStackTrace) implementation. Start with ASan because it is the most complex implementation. GetStackTrace implementations seem to have started out as exact copies of the original implementation in ASan, but have diverged in subtle ways. My goal is to parameterize this algorithm (via templating or callbacks) so we can share the implementation and get rid of the inversed dependency (sanitizer_common depends on concrete implementations in asan, ubsan, etc.). This should also help us to avoid those pesky linker errors caused by undefined, duplicate, and weak symbols on Windows. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D58861 llvm-svn: 355355
* Attemp to fix build brokage due to D57530.Manman Ren2019-03-043-0/+11
| | | | | | By adding implementations for __llvm_profile_begin_orderfile for non-Darwin platforms. llvm-svn: 355350
* [msan] Instrument x86 BMI intrinsics.Evgeniy Stepanov2019-03-041-1/+147
| | | | | | | | | | | | | | | | Summary: They simply shuffle bits. MSan needs to do the same with shadow bits, after making sure that the shuffle mask is fully initialized. Reviewers: pcc, vitalybuka Subscribers: hiraditya, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58858 llvm-svn: 355348
* [sanitizer] Intercept bzero.Evgeniy Stepanov2019-03-044-2/+44
| | | | | | | | | | | | | | | | Summary: Intercept bzero and enable existing __bzero interceptor in Linux. bzero is deprecated but still used occasionally. Reviewers: vitalybuka Subscribers: srhines, kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58850 llvm-svn: 355347
* Order File Instrumentation: dump the data in compiler-rtManman Ren2019-03-047-0/+157
| | | | | | | | The profile data will be dumped in a file default_xxx.profraw.order. Differential Revision: https://reviews.llvm.org/D57530 llvm-svn: 355343
* [build] Rename clang-headers to clang-resource-headersShoaib Meenai2019-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The current install-clang-headers target installs clang's resource directory headers. This is different from the install-llvm-headers target, which installs LLVM's API headers. We want to introduce the corresponding target to clang, and the natural name for that new target would be install-clang-headers. Rename the existing target to install-clang-resource-headers to free up the install-clang-headers name for the new target, following the discussion on cfe-dev [1]. I didn't find any bots on zorg referencing install-clang-headers. I'll send out another PSA to cfe-dev to accompany this rename. [1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits Tags: #clang, #sanitizers, #lldb, #openmp, #llvm Differential Revision: https://reviews.llvm.org/D58791 llvm-svn: 355340
OpenPOWER on IntegriCloud