aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
AgeCommit message (Collapse)AuthorFilesLines
2024-06-20mmapForContinuousMode: Align Linux's impl to __APPLE__'s more. NFC. (#95702)NAKAMURA Takumi1-4/+26
2024-06-20[nsan] Fix style issueFangrui Song12-869/+841
The initial check-in of compiler-rt/lib/nsan #94322 has a lot of style issues. Fix them before the history becomes more useful. Pull Request: https://github.com/llvm/llvm-project/pull/96142
2024-06-19[CompilerRT] Add support for numerical sanitizer (#94322)Alexander Shaposhnikov23-1/+2390
This diff contains the compiler-rt changes / preparations for nsan. Test plan: 1. cd build/runtimes/runtimes-bins && ninja check-nsan 2. ninja check-all
2024-06-19Reland "[scudo] Apply filling when realloc shrinks and re-grows a block ↵Fabio D'Urso2-5/+31
in-place" (#95838) Reland of #93212, which had been reverted in commit bddd8eae17df6511aee789744ccdc158de817081.
2024-06-18fixup! [compiler-rt][AArch64][FMV] Use the hw.optional.arm.caps fast path ↵Jon Roelofs1-0/+15
(#95275) https://github.com/llvm/llvm-project/pull/95275#issuecomment-2177366693
2024-06-18[scudo] Test secondary cache options only if enabled (#95872)Caslyn Tonelli1-5/+6
Configs that use `MapAllocatorNoCache` for its secondary cache will return `false` if `setOption` is called with some [specific options](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/scudo/standalone/secondary.h#L104), and this breaks with the `SecondaryOptions` test. This change will gate testing all `setOption` expectations for cache options only if the allocator cache is enabled. This will unblock [github.com/llvm/llvm-project/pull/95595 ](https://github.com/llvm/llvm-project/pull/95595) from merging into Fuchsia.
2024-06-17Reapply "[HWASan] [compiler-rt] support non-4k pages on Android" (#95853)Florian Mayer11-30/+37
Updated MapDynamicShadow callsite in asan_win.
2024-06-17Revert "[HWASan] [compiler-rt] support non-4k pages on Android" (#95853)Florian Mayer10-35/+29
Reverts llvm/llvm-project#95069 Broke windows bot
2024-06-17[scudo] Update error handling for seondary cache entry count (#95595)Joshua Baehring2-6/+7
Initially, the scudo allocator would return an error if the user attempted to set the cache capacity (i.e. the number of possible entries in the cache) above the maximum cache capacity. Now the allocator will resort to using the maximum cache capacity in this event. An error will still be returned if the user attempts to set the number of entries to a negative value.
2024-06-17[HWASan] [compiler-rt] support non-4k pages on Android (#95069)Florian Mayer10-29/+35
2024-06-16mmapForContinuousMode: Calculate FileOffsetToBitmap from ↵NAKAMURA Takumi1-2/+1
FileOffsetToCounters. NFC.
2024-06-16ReformatNAKAMURA Takumi1-3/+4
2024-06-14[compiler-rt] Remove 'memprof_meminfoblock.h' from MEMPROF_HEADERS (NFC) ↵Youngsuk Kim1-1/+0
(#95334) Commit 8306968b592d942cc49bde2e387061e673a9fbb7 deleted file `compiler-rt/lib/memprof/memprof_meminfoblock.h`, but didn't remove it from MEMPROF_HEADERS in `compiler-rt/lib/memprof/CMakeLists.txt`. Remove unneeded leftover line in `compiler-rt/lib/memprof/CMakeLists.txt`. p.s. GH #54777 reported a llvm14 build failure due to the existence of the leftover line, but I'm unable to reproduce the build failure with llvm19 trunk.
2024-06-14Reapply: [MC/DC][Coverage] Loosen the limit of NumConds from 6 (#82448)NAKAMURA Takumi1-1/+1
By storing possible test vectors instead of combinations of conditions, the restriction is dramatically relaxed. This introduces two options to `cc1`: * `-fmcdc-max-conditions=32767` * `-fmcdc-max-test-vectors=2147483646` This change makes coverage mapping, profraw, and profdata incompatible with Clang-18. - Bitmap semantics changed. It is incompatible with previous format. - `BitmapIdx` in `Decision` points to the end of the bitmap. - Bitmap is packed per function. - `llvm-cov` can understand `profdata` generated by `llvm-profdata-18`. RFC: https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798 -- Change(s) since llvmorg-19-init-14288-g7ead2d8c7e91 - Update compiler-rt/test/profile/ContinuousSyncMode/image-with-mcdc.c
2024-06-13[compiler-rt][AArch64][FMV] Use the hw.optional.arm.caps fast path (#95275)Jon Roelofs1-2/+75
MacOS 15.0 and iOS 18.0 added a new sysctl to fetch a bitvector of all the hw.optional.arm.FEAT_*'s in one go. Using this has a perf advantage over doing multiple round-trips to the kernel and back, but since it's not present in older oses, we still need the slow fallback.
2024-06-13[HWASan] comment why hwasan_symbolize_stack_uas is arm64 onlyFlorian Mayer1-1/+2
2024-06-13Reland '[hwasan] Add fixed_shadow_base flag (#73980)' (#95445)Thurston Dang3-2/+90
This was reverted in https://github.com/llvm/llvm-project/pull/95435 because it broke Android static hwasan binaries. This reland limits the change to !SANITIZER_ANDROID. Original commit message: When set to non-zero, the HWASan runtime will map the shadow base at the specified constant address. This is particularly useful in conjunction with the existing compiler option 'hwasan-mapping-offset', which bakes a hardcoded constant address into the instrumentation. --------- Co-authored-by: Vitaly Buka <vitalybuka@gmail.com>
2024-06-13[HWASan] disable hwasan_symbolize_stack_uas on x86Florian Mayer1-1/+2
2024-06-13[llvm-project] Fix typo "seperate" (#95373)Jay Foad2-2/+2
2024-06-13[DFSan] Fix sscanf checking that ordinary characters match. (#95333)Andrew Browne2-240/+393
Fixes: #94769
2024-06-13Revert "[hwasan] Add fixed_shadow_base flag" (#95435)Florian Mayer3-89/+2
Reverts llvm/llvm-project#73980 This broke static hwasan binaries in Android, for some reason the fixed_shadow_base branch gets taken
2024-06-13[compiler-rt][builtins] Add opt-in pthread_mutex_t locks to libatomic (#95326)Logikable2-2/+20
When an uninstrumented libatomic is used with a TSan instrumented memcpy, TSan may report a data race in circumstances where writes are arguably safe. This occurs because __atomic_compare_exchange won't be instrumented in an uninstrumented libatomic, so TSan doesn't know that the subsequent memcpy is race-free. On the other hand, pthread_mutex_(un)lock will be intercepted by TSan, meaning an uninstrumented libatomic will not report this false-positive. pthread_mutexes also may try a number of different strategies to acquire the lock, which may bound the amount of time a thread has to wait for a lock during contention. While pthread_mutex_lock has a larger overhead (due to the function call and some dispatching), a dispatch to libatomic already predicates a lack of performance guarantees.
2024-06-13[HWASan] add test for hwasan_symbolize of stack uas (#95186)Florian Mayer1-0/+22
2024-06-13Revert "[asan] Make frame number checks more flexable (#94307)"Hans Wennborg11-34/+34
It broke tests on Mac, see comment on the PR. > Use more flexable regex ([0-9]+) for frame number checks. Since the > frame numbers might change if some functions are not inlined. > > Similar to > * > https://github.com/llvm/llvm-project/commit/0360f3218a13666123849f6699216bdbebe64833 > * > https://github.com/llvm/llvm-project/commit/404bc5ca2ae5fffa45d5240dcf52b7f134988867 This reverts commit 98174fb6ec9784d9eb7be313ee1317ca6e703d90 and the follow-up commit 86d8aec97fd9e009e9b360ffeee744d3acce730d.
2024-06-13[FMV][compiler-rt] Fix cpu features initialization. (#95149)Alexandros Lamprineas7-105/+68
To detect features we either use HWCAPs or directly extract system register bitfields and compare with a value. In many cases equality comparisons give wrong results for example FEAT_SVE is not set if SVE2 is available (see the issue #93651). I am also making the access to __aarch64_cpu_features atomic. The corresponding PR for the ACLE specification is https://github.com/ARM-software/acle/pull/322.
2024-06-13[GWP-ASan] Various test fixes. (#94938)Mitch Phillips5-23/+5
When running some tests with --gtest_repeat=100 --gtest_shuffle, I encountered some problems because the allocator wasn't torn down completely, and the singleton pointer ended up pointing to a use-after-scope'd object. This patch has a couple of fixes and niceties: 1. Removing the once-init stuff from tests, now that it's implicitly done in GuardedPoolAllocator::installAtFork() anyway. 2. Calling uninitTestOnly() in the late_init test. 3. Resetting the HasReportedBadPoolAccess when the signal handlers are installed (allowing for --gtest_repeat w/ recoverable mode). 4. Adding a check and resetting the singleton pointer in uninitTestOnly().
2024-06-12[asan] Attempt to fix tests broken by #94307. (#95340)dyung3-3/+3
2024-06-12[asan] Make frame number checks more flexable (#94307)Hau Hsu11-34/+34
Use more flexable regex ([0-9]+) for frame number checks. Since the frame numbers might change if some functions are not inlined. Similar to * https://github.com/llvm/llvm-project/commit/0360f3218a13666123849f6699216bdbebe64833 * https://github.com/llvm/llvm-project/commit/404bc5ca2ae5fffa45d5240dcf52b7f134988867
2024-06-12[AArch64][compiler-rt] Disable SME ABI routines if function multiversioning ↵Kerry McLaughlin1-6/+17
is not supported (#94973) This prevents build failures when building with `DISABLE_AARCH64_FMV`, see https://github.com/llvm/llvm-project/pull/92921.
2024-06-11[ORC][MachO] Register objc protolist, protorefs, nlclslist metadata sections ↵Ben Langmuir6-0/+608
(#95144) Add missing __DATA sections that the objc runtime expects to register. This fixes running objc code that makes use of `@protocol` references and `__attribute__((objc_nonlazy_class))` classes. rdar://129368761
2024-06-11[scudo] Fix the calculation of PushedBytesDelta (#95177)ChiaHungDuan1-1/+1
BytesInBG is always greater or equal to BG->BytesInBGAtLastCheckpoint. Note that the bug led to unnecessary attempts of page releasing and doesn't have critical impact on the correctness.
2024-06-10Revert "[scudo] Apply filling when realloc shrinks and re-grows a block ↵Fabio D'Urso2-32/+5
in-place (#93212)" This reverts commit 760d880ea602117aa2e6bba4cf31069f09225b4b. It broke https://lab.llvm.org/buildbot/#/builders/169/builds/32309
2024-06-10[scudo] Apply filling when realloc shrinks and re-grows a block in-place ↵Fabio D'Urso2-5/+32
(#93212)
2024-06-08[compiler-rt] Replace deprecated aligned_storage with aligned byte array ↵Marc Auberer11-71/+50
(#94171) `std::aligned_storage` is deprecated with C++23, see [here](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1413r3.pdf). This replaces the usages of `std::aligned_storage` within compiler-rt with an aligned `std::byte` array. I will provide patches for other subcomponents as well.
2024-06-07[dfsan] Fix release_shadow_space.c (#94770)Thurston Dang1-4/+10
DFSan's sscanf is incorrect (https://github.com/llvm/llvm-project/issues/94769), which results in erroneous matches when scraping RSS from /proc/maps. This patch works around the issue by using strstr as a secondary check. It also adds a loose validity check for the initial RSS measurement, to guard against regressions in get_rss_kb(). Fixes https://github.com/llvm/llvm-project/issues/91287
2024-06-07Check if LLD is built when checking if lto_supported (#92752)Jan Voung1-1/+8
Otherwise, older copies of LLD may not understand the latest bitcode versions (for example, if we increase `ModuleSummaryIndex::BitCodeSummaryVersion`) Related to https://github.com/llvm/llvm-project/pull/90692#issuecomment-2113250317
2024-06-06[dfsan] Add test case for sscanf (#94700)Thurston Dang1-0/+19
This test case shows a limitation of DFSan's sscanf implementation (introduced in https://reviews.llvm.org/D153775): it simply ignores ordinary characters in the format string, instead of actually comparing them against the input. This may change the semantics of instrumented programs. Importantly, this also means that DFSan's release_shadow_space.c test, which relies on sscanf to scrape the RSS from /proc/maps output, will incorrectly match lines that don't contain RSS information. As a result, it adding together numbers from irrelevant output (e.g., base addresses), resulting in test flakiness (https://github.com/llvm/llvm-project/issues/91287).
2024-06-07[compiler-rt] Map internal_sigaction to __sys_sigaction on FreeBSD (#84441)Alexander Richardson1-2/+14
This function is called during very early startup and which can result in a crash on FreeBSD. The sigaction() function in libc is indirected via a table so that it can be interposed by the threading library rather than calling the syscall directly. In the crash I was observing this table had not yet been relocated, so we ended up jumping to an invalid address. To avoid this problem we can call __sys_sigaction, which calls the syscall directly and in FreeBSD 15 is part of libsys rather than libc, so does not depend on libc being fully initialized.
2024-06-06[sanitizer_common] Change allocator base in test case for compatibili… ↵Thurston Dang1-2/+7
(#93234) …ty with high-entropy ASLR With high-entropy ASLR (e.g., 32-bits == 16TB), the allocator base of 0x700000000000 (112TB) may collide with the placement of the libraries (e.g., on Linux, the mmap base could be 128TB - 16TB == 112TB). This results in a segfault in the test case. This patch moves the allocator base below the PIE program segment, inspired by fb77ca05ffb4f8e666878f2f6718a9fb4d686839. As per that patch: 1) we are leaving the old behavior for Apple 2) since ASLR cannot be set above 32-bits for x86-64 Linux, we expect this new layout to be durable. Note that this is only changing a test case, not the behavior of sanitizers. Sanitizers have their own settings for initializing the allocator base. Reproducer: 1. ninja check-sanitizer # Just to build the test binary needed below; no need to actually run the tests here 2. sudo sysctl vm.mmap_rnd_bits=32 # Increase ASLR entropy 3. for f in `seq 1 10000`; do echo $f; GTEST_FILTER=*SizeClassAllocator64Dense ./projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-x86_64-Test > /tmp/x; if [ $? -ne 0 ]; then cat /tmp/x; fi; done
2024-06-06[sanitizer] Make CHECKs in bitvector more precise (NFC) (#94630)Nikita Popov1-4/+4
These CHECKs are all checking indices, which must be strictly smaller than the size (otherwise they would go out of bounds).
2024-06-05Revert "[compiler-rt][builtins] Switch libatomic locks to pthread_mutex_t ↵Martin Storsjö1-18/+13
(#94374)" This reverts commit b62b7a42bbee4a3bbf9094808f460fdc9c119bd7 and a5729b71d844c1444f7d348dc2d4ea5b98de5ec5. This commit broke compilation for systems that lack pthreads.
2024-06-05[AArch64][compiler-rt] Add a function returning the current vector length ↵Kerry McLaughlin4-70/+135
(#92921) __arm_get_current_vg emits a cntd instruction if in streaming mode or SVE is available at runtime, otherwise it will return 0.
2024-06-04[atomics] Initialize pthread_mutex_t and avoid false sharingFangrui Song1-4/+16
PTHREAD_MUTEX_INITIALIZER is zeroes for glibc and musl, but it improves conformance and might work with more libc implementations. Follow-up to #94374 Pull Request: https://github.com/llvm/llvm-project/pull/94387
2024-06-04[compiler-rt][builtins] Switch libatomic locks to pthread_mutex_t (#94374)Logikable1-12/+5
When an uninstrumented libatomic is used with a TSan instrumented memcpy, TSan may report a data race in circumstances where writes are arguably safe. This occurs because __atomic_compare_exchange won't be instrumented in an uninstrumented libatomic, so TSan doesn't know that the subsequent memcpy is race-free. On the other hand, pthread_mutex_(un)lock will be intercepted by TSan, meaning an uninstrumented libatomic will not report this false-positive. pthread_mutexes also may try a number of different strategies to acquire the lock, which may bound the amount of time a thread has to wait for a lock during contention. While pthread_mutex_lock has a larger overhead (due to the function call and some dispatching), a dispatch to libatomic already predicates a lack of performance guarantees.
2024-06-04[compiler-rt] Revise IDE folder structure (#89753)Michael Kruse42-73/+45
Update the folder titles for targets in the monorepository that have not seen taken care of for some time. These are the folders that targets are organized in Visual Studio and XCode (`set_property(TARGET <target> PROPERTY FOLDER "<title>")`) when using the respective CMake's IDE generator. * Ensure that every target is in a folder * Use a folder hierarchy with each LLVM subproject as a top-level folder * Use consistent folder names between subprojects * When using target-creating functions from AddLLVM.cmake, automatically deduce the folder. This reduces the number of `set_property`/`set_target_property`, but are still necessary when `add_custom_target`, `add_executable`, `add_library`, etc. are used. A LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root CMakeLists.txt.
2024-05-31[msan] Change #ifdef SANITIZER_PPC to #if (#94009)Thurston Dang1-1/+1
https://github.com/llvm/llvm-project/commit/0e96eebc7f681a7ce41f35909e609c7c61a11455 accidentally turned the prior patch (https://github.com/llvm/llvm-project/commit/57a507930b50c445140feb68bffe1c21af53319e) into a no-op because this macro is always defined (as either 1 or 0). This patch changes it to correctly use #if.
2024-05-31Reapply "[Support] Remove terminfo dependency (#92865)" (#93889)Aaron Siddhartha Mondal3-21/+0
This reverts commit fe82a3da36196157c0caa1ef2505186782f750d1. This broke LLDB on MacOS due to a missing symbol during linking. The fix has been applied in c6c08eee37bada190bd1aa4593c88a5e2c8cdaac. Original commit message: The terminfo dependency introduces a significant nonhermeticity into the build. It doesn't respect `--no-undefined-version` meaning that it's not a dependency that can be built with Clang 17+. This forces maintainers of source-based distributions to implement patches or ignore linker errors. Remove it to reduce the closure size and improve portability of LLVM-based tools. Users can still use command line arguments to toggle color support expliticly. Fixes #75490 Closes #53294 #23355
2024-05-30[compiler-rt] [test] Work around MS CRT stdio format quirks on mingw too ↵Martin Storsjö2-4/+4
(#93787) So far, these tests have been disabled in mingw build configurations (built as asan-dynamic), but these were enabled in 246234ac70faa1e3281a2bb83dfc4dd206a7d59c, exposing the issue. (That commit is currently reverted, but will probably be relanded in some form soon.)
2024-05-30Revert "[asan][windows] Eliminate the static asan runtime on windows (#93770)"Charlie Barto53-1266/+1044
This reverts commit 8fa66c6ca7272268747835a0e86805307b62399c.
2024-05-30[asan][windows] Eliminate the static asan runtime on windows (#93770)Charlie Barto53-1044/+1266
Re-Apply: 246234ac70faa1e3281a2bb83dfc4dd206a7d59c Originally #81677 The static asan runtime on windows had various buggy hacks to ensure loaded dlls got the executable's copy of asan, these never worked all that well, so we have eliminated the static runtime altogether and made the dynamic runtime work for applications linking any flavor of the CRT. Among other things this allows non-asan-instrumented applications to load asan-instrumented dlls that link against the static CRT. Co-authored-by: Amy Wishnousky <amyw@microsoft.com>