aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
AgeCommit message (Collapse)AuthorFilesLines
2017-08-25Merging r311674:Hans Wennborg1-1/+2
------------------------------------------------------------------------ r311674 | hans | 2017-08-24 10:00:36 -0700 (Thu, 24 Aug 2017) | 3 lines Mark allocator_oom_test.cc unsupported on arm & aarch64 (PR33972) The buildbots don't seem to like it. ------------------------------------------------------------------------ llvm-svn: 311736
2017-08-23Merging r311555:Hans Wennborg2-0/+18
------------------------------------------------------------------------ r311555 | oleg | 2017-08-23 07:26:31 -0700 (Wed, 23 Aug 2017) | 14 lines [ARM][Compiler-rt] Fix AEABI builtins to correctly pass arguments to non-AEABI functions on HF targets Summary: This is a patch for PR34167. On HF targets functions like `__{eq,lt,le,ge,gt}df2` and `__{eq,lt,le,ge,gt}sf2` expect their arguments to be passed in d/s registers, while some of the AEABI builtins pass them in r registers. Reviewers: compnerd, peter.smith, asl Reviewed By: peter.smith, asl Subscribers: peter.smith, aemerson, dberris, javed.absar, llvm-commits, asl, kristof.beyls Differential Revision: https://reviews.llvm.org/D36675 ------------------------------------------------------------------------ llvm-svn: 311606
2017-08-23Merging r311496:Hans Wennborg1-8/+8
------------------------------------------------------------------------ r311496 | hans | 2017-08-22 14:54:37 -0700 (Tue, 22 Aug 2017) | 1 line [profile] Fix warning about C++ style comment in C file ------------------------------------------------------------------------ llvm-svn: 311584
2017-08-23Merging r311495:Hans Wennborg1-1/+1
------------------------------------------------------------------------ r311495 | hans | 2017-08-22 14:54:37 -0700 (Tue, 22 Aug 2017) | 6 lines [esan] Use stack_t instead of struct sigaltstack (PR34011) The struct tag is going away in soon-to-be-released glibc 2.26 and the stack_t typedef seems to have been there forever. Patch by Bernhard Rosenkraenzer! ------------------------------------------------------------------------ llvm-svn: 311583
2017-07-19[X86][builtins] Sync getX86CpuIDAndInfoEx with llvm's Host.cpp again.Craig Topper1-29/+10
We now use __cpuidex intrinsics intead of inline asm on 32-bit Windows. We already used it on 64-bit. llvm-svn: 308420
2017-07-18Revert "Add MemoryMappedSection struct for two-level memory map iteration"Francis Ricci2-54/+9
This reverts commit c8095ce74118dee8544b0f1ffaba8f46aa10215c. Reverted due to some buildbot timeouts, perhaps due to 10.11 issues. llvm-svn: 308395
2017-07-18Revert "Only scan global sections containing data in LSan on darwin"Francis Ricci5-28/+11
This reverts commit 7e46d78d47832f03ce42adcf56417fbfd47cbaad. llvm-svn: 308394
2017-07-18Don't call exit() from atexit handlers on DarwinFrancis Ricci6-7/+33
Summary: Calling exit() from an atexit handler is undefined behavior. On Linux, it's unavoidable, since we cannot intercept exit (_exit isn't called if a user program uses return instead of exit()), and I haven't seen it cause issues regardless. However, on Darwin, I have a fairly complex internal test that hangs roughly once in every 300 runs after leak reporting finishes, which is resolved with this patch, and is presumably due to the undefined behavior (since the Die() is the only thing that happens after the end of leak reporting). In addition, this is the way TSan works as well, where an atexit handler+Die() is used on Linux, and an _exit() interceptor is used on Darwin. I'm not sure if it's intentionally structured that way in TSan, since TSan sets up the atexit handler and the _exit() interceptor on both platforms, but I have observed that on Darwin, only the _exit() interceptor is used, and on Linux the atexit handler is used. There is some additional related discussion here: https://reviews.llvm.org/D35085 Reviewers: alekseyshl, kubamracek Subscribers: eugenis, vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D35513 llvm-svn: 308353
2017-07-18[Sanitizers] ASan/MSan/LSan allocators set errno on failure.Alex Shlyapnikov12-112/+202
Summary: ASan/MSan/LSan allocators set errno on allocation failures according to malloc/calloc/etc. expected behavior. MSan allocator was refactored a bit to make its structure more similar with other allocators. Also switch Scudo allocator to the internal errno definitions. TSan allocator changes will follow. Reviewers: eugenis Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D35275 llvm-svn: 308344
2017-07-18[asan] Remove recent asan tests which expect death in allocatorVitaly Buka1-10/+0
These tests assume allocator_may_return_null=false If allocator_may_return_null=true, gtest would not be able to switch it. Tests needs to be re-implemented as lit tests. llvm-svn: 308254
2017-07-17Only scan global sections containing data in LSan on darwinFrancis Ricci5-11/+28
Summary: __DATA segments on Darwin contain a large number of separate sections, most of which cannot actually contain pointers, and contain const values or objc metadata. Only scanning sections which can contain pointers greatly improves performance. On a medium-sized (~4000 files) internal project, I saw a speedup of about 50% in standalone LSan's execution time (50% improvement in the time spent running LSan, not the total program time). Reviewers: kcc, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35432 llvm-svn: 308231
2017-07-17[sanitizers] Make sure that all complex macros uses parenthesisVitaly Buka1-55/+61
Summary: Without them expressions like this may have different values. (SANITIZER_INTERCEPT_MEMRCHR && SANITIZER_INTERCEPT_PREADV) Reviewers: alekseyshl Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D35512 llvm-svn: 308228
2017-07-17Add missing && to fix syntax.Kamil Rytarowski1-1/+1
llvm-svn: 308221
2017-07-17Add NetBSD support in platform_interceptors.hKamil Rytarowski1-41/+57
Summary: Introduce SI_NETBSD for NetBSD. Add NetBSD support for appropriate `SANITIZER_INTERCEPT_*`. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dim, kcc, alekseyshl, filcab, eugenis, vitalybuka Reviewed By: vitalybuka Subscribers: srhines, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35468 llvm-svn: 308217
2017-07-17Introduce SANITIZER_NETBSD in sanitizer_platform.hKamil Rytarowski1-2/+9
Summary: Add defines for new NetBSD: SANITIZER_NETBSD, it will be used across the codebase for sanitizers. NetBSD is a POSIX-like platform, add it to SANITIZER_POSIX. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, dim, alekseyshl, filcab, eugenis, vitalybuka Reviewed By: kcc Subscribers: kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35467 llvm-svn: 308216
2017-07-17Add MemoryMappedSection struct for two-level memory map iterationFrancis Ricci2-9/+54
Summary: This will allow sanitizer_procmaps on mac to expose section information. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35422 llvm-svn: 308210
2017-07-16[asan] Disable not working new test on WindowsVitaly Buka1-0/+2
llvm-svn: 308123
2017-07-16[msan] Add missing include for fix test on WindowsVitaly Buka1-0/+1
llvm-svn: 308122
2017-07-16[tsan] Disable test with debug runtimeVitaly Buka1-0/+2
Test expects at least -O1 compiled runtime. llvm-svn: 308121
2017-07-16[asan] Attempt to fix test in Windows after r308064Vitaly Buka1-0/+2
llvm-svn: 308120
2017-07-16[compiler-rt] Fix fix format specifies type in testVitaly Buka1-2/+2
llvm-svn: 308117
2017-07-15[compiler-rt] [CMake] Build compiler-rt with no optimizations if the flag ↵George Karpenkov1-3/+9
says so Differential Revision: https://reviews.llvm.org/D35400 llvm-svn: 308072
2017-07-14[Sanitizers] ASan and LSan allocator set errno on failure.Alex Shlyapnikov3-18/+57
Summary: Set proper errno code on alloction failures and change some implementations to satisfy their man-specified requirements: LSan: valloc and memalign ASan: pvalloc, memalign and posix_memalign Changing both allocators in one patch since LSan depends on ASan allocator in some configurations. Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D35440 llvm-svn: 308064
2017-07-14[Sanitizers] LSan allocator set errno on failure.Alex Shlyapnikov2-11/+33
Set proper errno code on alloction failures and change valloc and memalign implementations to satisfy their man-specified requirements. llvm-svn: 308063
2017-07-14[Sanitizers] Scudo allocator set errno on failure.Alex Shlyapnikov2-25/+33
Summary: Set proper errno code on alloction failure and change pvalloc and posix_memalign implementation to satisfy their man-specified requirements. Reviewers: cryptoad Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35429 llvm-svn: 308053
2017-07-14tsan: optimize sync clock memory consumptionDmitry Vyukov4-197/+512
This change implements 2 optimizations of sync clocks that reduce memory consumption: Use previously unused first level block space to store clock elements. Currently a clock for 100 threads consumes 3 512-byte blocks: 2 64-bit second level blocks to store clock elements +1 32-bit first level block to store indices to second level blocks Only 8 bytes of the first level block are actually used. With this change such clock consumes only 2 blocks. Share similar clocks differing only by a single clock entry for the current thread. When a thread does several release operations on fresh sync objects without intervening acquire operations in between (e.g. initialization of several fields in ctor), the resulting clocks differ only by a single entry for the current thread. This change reuses a single clock for such release operations. The current thread time (which is different for different clocks) is stored in dirty entries. We are experiencing issues with a large program that eats all 64M clock blocks (32GB of non-flushable memory) and crashes with dense allocator overflow. Max number of threads in the program is ~170 which is currently quite unfortunate (consume 4 blocks per clock). Currently it crashes after consuming 60+ GB of memory. The first optimization brings clock block consumption down to ~40M and allows the program to work. The second optimization further reduces block consumption to "modest" 16M blocks (~8GB of RAM) and reduces overall RAM consumption to ~30GB. Measurements on another real world C++ RPC benchmark show RSS reduction from 3.491G to 3.186G and a modest speedup of ~5%. Go parallel client/server HTTP benchmark: https://github.com/golang/benchmarks/blob/master/http/http.go shows RSS reduction from 320MB to 240MB and a few percent speedup. Reviewed in https://reviews.llvm.org/D35323 llvm-svn: 308018
2017-07-13Fix sanitizer build against latest glibcKostya Serebryany4-7/+4
Summary: libsanitizer doesn't build against latest glibc anymore, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81066 for details. One of the changes is that stack_t changed from typedef struct sigaltstack { ... } stack_t; to typedef struct { ... } stack_t; for conformance reasons. And the other change is that the glibc internal __need_res_state macro is now ignored, so when doing ``` #define __need_res_state #include <resolv.h> ``` the effect is now the same as just ``` #include <resolv.h> ``` and thus one doesn't get just the ``` struct __res_state { ... }; ``` definition, but newly also the ``` extern struct __res_state *__res_state(void) __attribute__ ((__const__)); ``` prototype. So __res_state is no longer a type, but a function. Reviewers: kcc, ygribov Reviewed By: kcc Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D35246 llvm-svn: 307969
2017-07-13[scudo] Do not grab a cache for secondary allocation & per related changesKostya Kortchinsky2-55/+79
Summary: Secondary backed allocations do not require a cache. While it's not necessary an issue when each thread has its cache, it becomes one with a shared pool of caches (Android), as a Secondary backed allocation or deallocation holds a cache that could be useful to another thread doing a Primary backed allocation. We introduce an additional PRNG and its mutex (to avoid contention with the Fallback one for Primary allocations) that will provide the `Salt` needed for Secondary backed allocations. I changed some of the code in a way that feels more readable to me (eg: using some values directly rather than going through ternary assigned variables, using directly `true`/`false` rather than `FromPrimary`). I will let reviewers decide if it actually is. An additional change is to mark `CheckForCallocOverflow` as `UNLIKELY`. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35358 llvm-svn: 307958
2017-07-13[ubsan] Teach the pointer overflow check that "p - <unsigned> <= p" ↵Vedant Kumar2-9/+21
(compiler-rt) Compiler-rt changes associated with: D34121 llvm-svn: 307956
2017-07-13For Darwin's GetTaskInfoMaxAddress, define the real structure with real ↵Kuba Mracek1-5/+26
fields to avoid confusion. NFC. llvm-svn: 307945
2017-07-13[compiler-rt][X86] Match the detection of cpu's for __cpu_model to the ↵Craig Topper1-309/+109
latest version of gcc Summary: We were missing many feature flags that newer gcc supports and we had our own set of feature flags that gcc didnt' support that were overlapping. Clang's implementation assumes gcc's features list so a mismatch here is problematic. I've also matched the cpu type/subtype lists with gcc and removed all the cpus that gcc doesn't support. I've also removed the fallback autodetection logic that was taken from Host.cpp. It was the main reason we had extra feature flags relative to gcc. I don't think gcc does this in libgcc. Once this support is in place we can consider implementing __builtin_cpu_is in clang. This could also be needed for function dispatching that Erich Keane is working on. Reviewers: echristo, asbirlea, RKSimon, erichkeane, zvi Reviewed By: asbirlea Subscribers: dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D35214 llvm-svn: 307878
2017-07-13Fix broken testXinliang David Li1-3/+0
llvm-svn: 307869
2017-07-12[asan] Avoid recompilation of the same code in the testVitaly Buka1-13/+12
llvm-svn: 307868
2017-07-12[asan] For iOS/AArch64, if the dynamic shadow doesn't fit, restrict the VM spaceKuba Mracek12-17/+93
On iOS/AArch64, the address space is very limited and has a dynamic maximum address based on the configuration of the device. We're already using a dynamic shadow, and we find a large-enough "gap" in the VM where we place the shadow memory. In some cases and some device configuration, we might not be able to find a large-enough gap: E.g. if the main executable is linked against a large number of libraries that are not part of the system, these libraries can fragment the address space, and this happens before ASan starts initializing. This patch has a solution, where we have a "backup plan" when we cannot find a large-enough gap: We will restrict the address space (via MmapFixedNoAccess) to a limit, for which the shadow limit will fit. Differential Revision: https://reviews.llvm.org/D35098 llvm-svn: 307865
2017-07-12[PGO] Add a test for 2-deep loop nestXinliang David Li1-0/+51
llvm-svn: 307864
2017-07-12Add explicit CMake targets for ASan/TSan iOS Simulator testing and update ↵Kuba Mracek2-8/+26
the instructions how to run them. llvm-svn: 307844
2017-07-12On Darwin, start building the TSan iOS dylib by default.Kuba Mracek1-0/+1
llvm-svn: 307839
2017-07-12[builtins] Better Fuchsia supportPetr Hosek2-4/+19
Add Fuchsia support to some builtings and avoid building builtins that are not and will never be used on Fuchsia. Differential Revision: https://reviews.llvm.org/D34075 llvm-svn: 307832
2017-07-12On Darwin, start building the TSan dylib for the iOS simulator.Kuba Mracek2-3/+8
llvm-svn: 307816
2017-07-12Fix the declaration of DARWIN_PREFER_PUBLIC_SDK cmake variable (move before ↵Kuba Mracek1-1/+2
the return). llvm-svn: 307815
2017-07-12[scudo] PRNG makeoverKostya Kortchinsky4-56/+55
Summary: This follows the addition of `GetRandom` with D34412. We remove our `/dev/urandom` code and use the new function. Additionally, change the PRNG for a slightly faster version. One of the issues with the old code is that we have 64 full bits of randomness per "next", using only 8 of those for the Salt and discarding the rest. So we add a cached u64 in the PRNG that can serve up to 8 u8 before having to call the "next" function again. During some integration work, I also realized that some very early processes (like `init`) do not benefit from `/dev/urandom` yet. So if there is no `getrandom` syscall as well, we have to fallback to some sort of initialization of the PRNG. Now a few words on why XoRoShiRo and not something else. I have played a while with various PRNGs on 32 & 64 bit platforms. Some results are below. LCG 32 & 64 are usually faster but produce respectively 15 & 31 bits of entropy, meaning that to get a full 64-bit, you would need to call them several times. The simple XorShift is fast, produces 32 bits but is mediocre with regard to PRNG test suites, PCG is slower overall, and XoRoShiRo is faster than XorShift128+ and produces full 64 bits. %%% root@tulip-chiphd:/data # ./randtest.arm [+] starting xs32... [?] xs32 duration: 22431833053ns [+] starting lcg32... [?] lcg32 duration: 14941402090ns [+] starting pcg32... [?] pcg32 duration: 44941973771ns [+] starting xs128p... [?] xs128p duration: 48889786981ns [+] starting lcg64... [?] lcg64 duration: 33831042391ns [+] starting xos128p... [?] xos128p duration: 44850878605ns root@tulip-chiphd:/data # ./randtest.aarch64 [+] starting xs32... [?] xs32 duration: 22425151678ns [+] starting lcg32... [?] lcg32 duration: 14954255257ns [+] starting pcg32... [?] pcg32 duration: 37346265726ns [+] starting xs128p... [?] xs128p duration: 22523807219ns [+] starting lcg64... [?] lcg64 duration: 26141304679ns [+] starting xos128p... [?] xos128p duration: 14937033215ns %%% Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: aemerson, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D35221 llvm-svn: 307798
2017-07-12tsan: remove some clock-related statsDmitry Vyukov3-12/+4
The stats are too dependent on implementation and won't be relevant in future. llvm-svn: 307786
2017-07-12tsan: refactor SyncClock codeDmitry Vyukov2-55/+54
1. Add SyncClock::ResetImpl which removes code duplication between ctor and Reset. 2. Move SyncClock::Resize to SyncClock methods, currently it's defined between ThreadClock methods. llvm-svn: 307785
2017-07-12tsan: prepare clock for future changesDmitry Vyukov6-23/+35
Pass ClockCache to ThreadClock::set and introduce ThreadCache::ResetCached. For now both are unused, but will reduce future diffs. llvm-svn: 307784
2017-07-12tsan: s/-1/kInvalidTid/Dmitry Vyukov1-1/+1
llvm-svn: 307781
2017-07-12tsan: give debug names to dense allocatorsDmitry Vyukov3-5/+13
Improves crash message on dense alloc overflow. Allows to understand what alloc overflowed. llvm-svn: 307780
2017-07-12tsan: don't create sync objects on acquire-loadDmitry Vyukov1-5/+11
Don't create sync object if it does not exist yet. For example, an atomic pointer is initialized to nullptr and then periodically acquire-loaded. llvm-svn: 307778
2017-07-12tsan: add another test for clock growthDmitry Vyukov1-0/+36
llvm-svn: 307777
2017-07-12tsan: add test for __tsan_java_findDmitry Vyukov1-0/+69
The test should have been added in 289682 "tsan: allow Java VM iterate over allocated objects" but I forgot to avn add. Author: Alexander Smundak (asmundak) Reviewed in https://reviews.llvm.org/D27720 llvm-svn: 307776
2017-07-12[tsan] Update test to r307338Vitaly Buka1-2/+2
r307338 enabled new optimization reducing number of operation in tested functions. There is no any performance regression detectable with TsanRtlTest DISABLED_BENCH.Mop* tests. llvm-svn: 307739