summaryrefslogtreecommitdiff
path: root/compiler-rt/lib
AgeCommit message (Collapse)Author
2025-11-21[scudo] Small cleanup of memory tagging code part 2. (#168807)Christopher Ferris
Make the systemSupportsMemoryTagging() function return even on system that don't support memory tagging. This avoids the need to always check if memory tagging is supported before calling the function. Modify iterateOverChunks() to call useMemoryTagging<>(Options) to determine if mte is supported. This already uses the cached check of systemSupportsMemoryTagging() rather than directly calling that function. Updated the code that calls systemSupportsMemoryTagging().
2025-11-21[TSan] [Darwin] Fix off by one in TSAN init due to MemoryRangeIsAvailable ↵Andrew Haberlandt
(#169008)
2025-11-21Revert "[ubsan_minimal] Allow UBSan handler from Minimal runtime to accept ↵Vitaly Buka
arguments (#152192)" (#168812) This partially reverts #152192, keeping updated tests and some code reordering in clang/lib/CodeGen/CGExpr.cpp. compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp is exact revert (with followup #152419) We don't have a good use case for that, so revert it before we are stuck maintaining this API. 21.x does not have this patch. This reverts commit a1209d868632b8aea10450cd2323848ab0b6776a.
2025-11-20Revert "[UBSan] [compiler-rt] add preservecc variants of handlers" (#168973)Florian Mayer
Reverts llvm/llvm-project#168643
2025-11-20[UBSan] [compiler-rt] add preservecc variants of handlers (#168643)Florian Mayer
2025-11-19[ASan] Document define to disable container overflow checks at compile time. ↵Paddy McDonald
(#163468) Document a define to allow library developers to support disabling AddressSanitizer's container overflow detection in template code at compile time. The primary motivation is to reduce false positives in environments where libraries and frameworks that cannot be recompiled with sanitizers enabled are called from application code. This supports disabling checks when the runtime environment cannot be reliably controlled to use ASAN_OPTIONS. Key changes: - Use the define `__SANITIZER_DISABLE_CONTAINER_OVERFLOW__` to disable instrumentation at compile time - Implemented redefining the container overflow APIs in common_interface_defs.h to use define to provide null implementation when define is present - Update documentation in AddressSanitizer.rst to suggest and illustrate use of the define - Add details of the define in PrintContainerOverflowHint() - Add test disable_container_overflow_checks to verify new hints on the error and fill the testing gap that ASAN_OPTIONS=detect_container_overflow=0 works - Add tests demonstrating the issue around closed source libraries and instrumented apps that both modify containers This requires no compiler changes and should be supportable cross compiler toolchains. An RFC has been opened to discuss: https://discourse.llvm.org/t/rfc-add-fsanitize-address-disable-container-overflow-flag-to-addresssanitizer/88349
2025-11-19[gn] "port" 5efce7392f3f (arm 32-bit asm compiler-rt)Nico Weber
2025-11-19[asan] Implement address sanitizer on AIX: platform support (#139587)Jake Egan
Adds some general changes for supporting asan on AIX. Issue: #138916
2025-11-19[Runtimes] Default build must use its own output dirs (#168266)Michael Kruse
Post-commit fix of #164794 reported at https://github.com/llvm/llvm-project/pull/164794#issuecomment-3536253493 `LLVM_LIBRARY_OUTPUT_INTDIR` and `LLVM_RUNTIME_OUTPUT_INTDIR` is used by `AddLLVM.cmake` as output directories. Unless we are in a bootstrapping-build, It must not point to directories found by `find_package(LLVM)` which may be read-only directories. MLIR for instance sets thesese variables to its own build output directory, so should the runtimes.
2025-11-18[compiler-rt][ARM] Optimized mulsf3 and divsf3 (#168394)Simon Tatham
(Reland of #161546, fixing three build and test issues) This commit adds optimized assembly versions of single-precision float multiplication and division. Both functions are implemented in a style that can be assembled as either of Arm and Thumb2; for multiplication, a separate implementation is provided for Thumb1. Also, extensive new tests are added for multiplication and division. These implementations can be removed from the build by defining the cmake variable COMPILER_RT_ARM_OPTIMIZED_FP=OFF. Outlying parts of the functionality which are not on the fast path, such as NaN handling and underflow, are handled in helper functions written in C. These can be shared between the Arm/Thumb2 and Thumb1 implementations, and also reused by other optimized assembly functions we hope to add in future.
2025-11-17[scudo] Skip test if mlock fails. (#168448)Christopher Ferris
Some linux versions might not support the mlock call, so skip that part of the test if the mlock fails.
2025-11-17[scudo] Fix wrong return type. (#168157)Christopher Ferris
2025-11-15[X86] Remove vector length (256 vs 512) distinction of AVX10 (#167736)Mikołaj Piróg
As in title. AVX10.x doesn't distinguish between available vector lengths. -mattr=avx10.x-512 and defining of macros with _512 is kept for compatibility. Bit-positions of avx10.1/2 features in compiler-rt and X86TargetParser are synced to match those in the gcc.
2025-11-14[compiler-rt] [Darwin] Strip MTE tags from ASAN and TSAN (#166453)Andrew Haberlandt
ASAN and TSAN need to strip tags in order to compute the correct shadow addresses. rdar://163518624
2025-11-13[sanitizer-common] [Darwin] Fix overlapping dyld segment addresses (attempt ↵Andrew Haberlandt
2) (#167800) This re-lands #166005, which was reverted due to the issue described in #167797. There are 4 small changes: - Fix LoadedModule leak by calling Clear() on the modules list - Fix internal_strncpy calls that are not null-terminated - Improve test to accept the dylib being loaded from a different path than compiled `{{.*}}[[DYLIB]]` - strcmp => internal_strncmp This should not be merged until after #167797. rdar://163149325
2025-11-13[sanitizer_common] Add darwin-specific MemoryRangeIsAvailable (#167797)Andrew Haberlandt
The fixes a TOCTOU bug in the code that initializes shadow memory in ASAN: https://github.com/llvm/llvm-project/blob/4b05581bae0e3432cfa514788418fb2fc2144904/compiler-rt/lib/asan/asan_shadow_setup.cpp#L66-L91 1. During initialization, we call `FindDynamicShadowStart` to search the memory mapping for enough space to dynamically allocate shadow memory. 2. We call `MemoryRangeIsAvailable(shadow_start, kHighShadowEnd);`, which goes into `MemoryMappingLayout`. 3. We actually map the shadow with `ReserveShadowMemoryRange`. In step 2, `MemoryMappingLayout` makes various allocations using the internal allocator. This can cause the allocator to map more memory! In some cases, this can actually allocate memory that overlaps with the shadow region returned by` FindDynamicShadowStart` in step 1. This is not actually fatal, but it memory corruption; MAP_FIXED is allowed to overlap other regions, and the effect is any overlapping memory is zeroed. ------ To address this, this PR implements `MemoryRangeIsAvailable` on Darwin without any heap allocations: - Move `IntervalsAreSeparate` into sanitizer_common.h - Guard existing sanitizer_posix implementation of `MemoryRangeIsAvailable` behind !SANITIZER_APPLE - `IsAddressInMappedRegion` in sanitizer_mac becomes `MemoryRangeIsAvailable`, which also checks for overlap with the DYLD shared cache. After this fix, it should be possible to re-land #166005, which triggered this issue on the x86 iOS simulators. rdar://164208439
2025-11-13[scudo] Always zero on linux even if the memory cannot be released. (#167788)Christopher Ferris
If a caller has locked memory, then the madvise call will fail. In that case, zero the memory so that we don't return non-zeroed memory for calloc calls since we thought the memory had been released.
2025-11-13Revert "[compiler-rt][ARM] Optimized mulsf3 and divsf3" (#167906)Simon Tatham
Reverts llvm/llvm-project#161546 One of the buildbots reported a cmake error I don't understand, and which I didn't get in my own test builds: ``` CMake Error at /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/compiler-rt/cmake/Modules/CheckAssemblerFlag.cmake:23 (try_compile): COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE ``` My best guess is that the thing I did in `CheckAssemblerFlag.cmake` only works on some versions of cmake. But I don't understand the problem well enough to fix it quickly, so I'm reverting the whole patch and will reland it later.
2025-11-13[compiler-rt][ARM] Optimized mulsf3 and divsf3 (#161546)Simon Tatham
This commit adds optimized assembly versions of single-precision float multiplication and division. Both functions are implemented in a style that can be assembled as either of Arm and Thumb2; for multiplication, a separate implementation is provided for Thumb1. Also, extensive new tests are added for multiplication and division. These implementations can be removed from the build by defining the cmake variable COMPILER_RT_ARM_OPTIMIZED_FP=OFF. Outlying parts of the functionality which are not on the fast path, such as NaN handling and underflow, are handled in helper functions written in C. These can be shared between the Arm/Thumb2 and Thumb1 implementations, and also reused by other optimized assembly functions we hope to add in future.
2025-11-13Revert "[compiler-rt] [builtins] Remove unused/misnamed x86 chkstk functions"Martin Storsjö
This reverts parts of commit 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2, and adds verbose comments explaining all the variants of this function, for clarity for future readers. It turns out that those functions actually weren't misnamed or unused after all: Apparently Clang doesn't match GCC when it comes to what stack probe function is referenced on i386 mingw. GCC < 4.6 references a symbol named "___chkstk", with three leading underscores, and GCC >= 4.6 references "___chkstk_ms". Restore these functions, to allow linking object files built with GCC with compiler-rt.
2025-11-13Revert "[compiler-rt] Rename the now lone i386/chkstk2.S to i386/chkstk.S"Martin Storsjö
This reverts commit 1f9eff100ce8faea1284d68b779d844c6e019b77. This is done in preparation of reverting parts of 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2.
2025-11-13[ASan] Fix forward 141c2bAiden Grossman
When landing 141c2b I didn't realize that none of these files actually got built either locally or by premerge. I had some minor syntax mistakes that caused the build to fail. This patch fixes those issues and has been verified on a Windows machine.
2025-11-12[ASan][Windows] Add new instruction sizes (#167734)Aiden Grossman
These instructions show up when building asan in the premerge container and do not on other bots, likely due to different standard library versions.
2025-11-12Revert "[sanitizer-common] [Darwin] Fix overlapping dyld segment addresses ↵Andrew Haberlandt
(#167649) Revert #166005 due to breaking x86 iOS sims We're sometimes hitting a allocator assert when running x86 iOS sim tests. I don't believe this PR is at fault, but there's probably a memory safety / allocator issue somewhere which the allocation pattern here is exposing.
2025-11-11[compiler-rt][asan] Fix a test on Windows (#167591)Alan Zhao
Windows doesn't support `pthread_attr`, which was introduced to asan_test.cpp in #165198, so this change `#ifdef`s out the changes made in that PR. Originally reported by Chrome as https://crbug.com/459880605.
2025-11-11[Asan] Ensure minimum stack size 128KB in ThreadedStressStackReuseTest (#165198)Riyaz Ahmad
Asan test `ThreadedStressStackReuseTest ` fails on AIX due to smaller default thread stack size. Set thread stack size to a minimum of 128KB to ensure reliable test behavior across platforms (platforms with smaller default thread stack size). --------- Co-authored-by: Riyaz Ahmad <riyaz.ahmad@ibm.com>
2025-11-10Revert "[scudo] Small cleanup of memory tagging code." (#167425)Christopher Ferris
Reverts llvm/llvm-project#166860 The local static variable causes build failures.
2025-11-10[scudo] Small cleanup of memory tagging code. (#166860)Christopher Ferris
Make the systemSupportsMemoryTagging() function return even on system that don't support memory tagging. This avoids the need to always check if memory tagging is supported before calling th function. Make systemSupportsMemoryTagging() cache the getauxval return value instead of calling the function every time. Updated the code that calls systemSupportsMemoryTagging().
2025-11-07[compiler-rt] Add CMake option to enable execute-only code generation on ↵Csanád Hajdú
AArch64 (#140555) For a full toolchain supporting execute-only code generation the runtime libraries also need to be pre-compiled with it enabled. The generic `RUNTIMES_EXECUTE_ONLY_CODE` CMake option can now be used during build configuration to enable execute-only code generation in compiler-rt. The build option can only be enabled for a runtimes build of compiler-rt, because a recent version of Clang is needed to correctly compile assembly files with execute-only code support. Related RFC: https://discourse.llvm.org/t/rfc-execute-only-code-support-for-runtime-libraries-on-aarch64/86180
2025-11-06[sanitizer-common] [Darwin] Fix overlapping dyld segment addresses (#166005)Andrew Haberlandt
This fixes two problems: - dyld itself resides within the shared cache. MemoryMappingLayout incorrectly computes the slide for dyld's segments, causing them to (appear to) overlap with other modules. This can cause symbolication issues. - The MemoryMappingLayout ranges on Darwin are not disjoint due to the fact that the LINKEDIT segments overlap for each module. We now ignore these segments to ensure the mapping is disjoint. This adds a check for disjointness, and a runtime warning if this is ever violated (as that suggests issues in the sanitizer memory mapping). There is now a test to ensure that these problems do not recur. rdar://163149325
2025-11-04[sanitizer_common] Add arm64e module type (#166018)Andrew Haberlandt
This will fix some symbolication failures on arm64e machines when the symbolicator passes the (wrong) architecture string to atos.
2025-11-04[compiler-rt][x86] Don't use assert.h when building without a libc (#165384)quic-k
fixes https://github.com/llvm/llvm-project/issues/164932 Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com> Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2025-11-03[sanitizer-common] [Darwin] Provide warnings for common sandbox issues (#165907)Andrew Haberlandt
We currently do not handle errors in task_set_exc_guard_behavior. If this fails, mmap can unexpectedly crash. We also do not currently provide a clear warning if no external symbolizers are found. rdar://163798535
2025-11-03[scudo] Add config option to modify get usable size behavior (#158710)Christopher Ferris
Currently, Scudo always returns the exact size allocated when calling getUsableSize. This can be a performance issue where some programs will get the usable size and do unnecessary calls to realloc since they think there isn't enough space in the allocation. By default, usable size will still return the exact size of the allocation. Note that if the exact behavior is disabled and MTE is on, then the code will still give an exact usable size.
2025-11-03Revert "[UBSan] Improve error message when a misalignment is due to t… ↵Matthew Nagy
(#166197) …arget de…" This reverts commit 47c54d55c9fac5ea7c87881e00f96e8c12b18174.
2025-11-03[UBSan] Improve error message when a misalignment is due to target default ↵Matthew Nagy
assumed alignment
2025-10-31[TySan] Add option to outline instrumentation (#120582)gbMattN
Added a command line option to use function calls rather than inline checks for TySan instrumentation.
2025-10-30lsan: fix allocator on arm64 Android (#165656)quic-likaid
The default config is too large for arm64 Android devices, which are typically configured with 39-bit address space. This change brings it inline with sanitizer_allocator_test.cpp.
2025-10-28Revert "[nsan] More unit tests for `float128`. (#165248)" (#165391)Clement Courbet
This reverts commit 2f869c427b6c800f37147458ac03d1fa6f9ad9d3. Breaks build on some configurations
2025-10-28[TSan] Fix warning when compiling with ↵Dan Blackwell
-Wmissing-designated-field-initializers (#163401) Currently we receive a warning when initializing a ThreadEventCallbacks when compiling with this flag: ``` llvm-project/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp:252:3: warning: missing field 'start' initializer [-Wmissing-designated-field-initializers] 252 | }; | ^ ``` This patch explicitly initializes the missing fields to null, fixing the warning. rdar://162074310
2025-10-28[nsan] More unit tests for `float128`. (#165248)Clement Courbet
Now that llvm-libc has `nextafterf128`.
2025-10-26[compiler-rt] Restore unsigned value in struct, use enum only in function ↵Mikołaj Piróg
(#165048) Typed enums are c23 features and are too new to be used. This PR restores the types in the `__processor_model` struct back to `unsigned int`, removes typed enums, and uses the enum in the function as a variable that's later assigned to a struct in order to prevent errors fixed initially here: #164713 See https://github.com/llvm/llvm-project/pull/165034 for more background
2025-10-25[compiler-rt][libunwind] Allow for CET on OpenBSD (#164341)Brad Smith
2025-10-24[scudo] Secondary release to OS uses LRU to scan. (#163691)Christopher Ferris
Before this change, the code would scan the entire set of cached entries to find ones to be released. Now, it uses the LRUEntries list to iterate over the live cached entries. In addition, remove the OldestTime variable and replace it with OldestPresentEntry which will always be the oldest entry in the LRU that has Time non-zero.
2025-10-24[asan] Avoid -Wtautological-pointer-compare (#164918)Thurston Dang
https://github.com/llvm/llvm-project/pull/164906 converted a -Wpointer-bool-conversion warning into a -Wtautological-pointer-compare warning. Avoid both by using the bool cast.
2025-10-23[asan] Avoid -Wpointer-bool-conversion warning by comparing to nullptr (#164906)Thurston Dang
The current code may trigger a compiler warning: ``` address of function 'wcsnlen' will always evaluate to 'true' [-Wpointer-bool-conversion] ``` Fix this by comparing to nullptr. The same fix is applied to strnlen for future-proofing.
2025-10-23[compiler-rt][ASan] Define SANITIZER_INTERCEPT_WCSNLEN (#164845)Zack Johnson
Follow up to #162028 `SANITIZER_INTERCEPT_WCSNLEN` is not defined, so `internal_wcsnlen` is always used instead of using `REAL(wcsnlen)` if intercepted.
2025-10-23[Compiler-rt] Fix wrong assignment in compiler_rt (#164713)Mikołaj Piróg
The `INTEL_CLEARWATERFOREST` belongs to `ProcessorTypes` enum, but it was assigned to `Subtype` value, leading to cpu_specific/cpu_dispatch not recognizing CWF. The type for `Subtype` and `Type` are changed to respective enums to guard against these sort of errors in the future
2025-10-22[PAC][libunwind] Fix gcc build of libunwind and compiler-rt (#164535)Oliver Hunt
This adds guards on the ptrauth feature checks so that they are only performed if __has_feature is actually available.
2025-10-22[compiler-rt] Fix building for arm64ec (#164590)Martin Storsjö
c208a23643231d0b19c6f795895a16dfe6797340 added the directive `.att_syntax` when building for x86 architectures. However, when building for arm64ec (a Windows target, for an ABI compatible with x86_64), the defines for `__x86_64__` (and similar ones like `__amd64__`) are still defined, so we need to check for `__arm64ec__` here as well to skip it for such targets. This matches similar existing ifdefs for x86_64/aarch64 in compiler-rt builtins.