aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
AgeCommit message (Collapse)AuthorFilesLines
7 hoursFix filename in wasm build of compiler-rt (#161875)Derek Schuff1-1/+1
27 hours[FMV][AArch64] Remove last of MRS bits and rename file (#161585)Brad Smith2-6/+3
474f5d2aefb44430b89ed72774a3c1d26a0adfb1 removed the last bits reading from system registers so remove the last bits utilizing MRS and rename the file to hwcap as the code is now only decoding the hwcap flags.
42 hours[compiler-rt][asan][tests] Stabilize wchar tests on Darwin/Android (#161624)Yixuan Cao4-40/+40
### Summary Stabilize ASan wchar tests across Darwin and Android. NFC: test-only. Follow-up to PR #160493 (adds wchar interceptors/tests). ### Motivation - Darwin: The top frame often resolves to `libclang_rt.asan_*` rather than a source file, so strict checks that include file/line can fail. See Chromium issue [448631142](https://g-issues.chromium.org/issues/448631142). - Android: The “ERROR:” header can go to logcat instead of stderr, so FileCheck may not see it; stdout/stderr reordering also makes pre-crash markers racy. See Android Buildbot [186/12821](https://lab.llvm.org/buildbot/#/builders/186/builds/12821). ### Changes - Android: - Force reports to stderr via `%env_asan_opts=log_to_stderr=1`, avoiding the “ERROR:” header going to logcat. - Print the pre-crash “Good so far.” to stderr and `fflush(stderr)` to avoid stdout/stderr reordering. - Darwin: - Relax the stack-frame check to only require the function name (`wcscpy/wcsncpy/wcscat/wcsncat`) to tolerate `libclang_rt.asan_*` frames. - Common: - Reuse FileCheck var `[[ADDR]]` instead of redefining. - Make wide string literals `const wchar_t*` to silence `-Wwritable-strings`. ### Risk - NFC: test-only; no change to runtime behavior. ### References - Follow-up to PR #160493. - Chromium: [448631142](https://g-issues.chromium.org/issues/448631142) (Darwin failures). - Android Buildbot: [186/12821](https://lab.llvm.org/buildbot/#/builders/186/builds/12821). Signed-off-by: Yixuan Cao <caoyixuan2019@email.szu.edu.cn>
2 days[WebAssembly] Define llvm-internal WasmEH tags in compiler-rt (#160959)Sam Clegg3-5/+58
The `__c_longjmp` and `__cpp_exceptions` tags are used internally by llvm to implement setjmp/longjmp and C++ exception handling respectively. These symbols were previously defined weakly in each object file but were recently converted to external references in #159143. They now need to be defined somewhere in the runtime libraries. I think compiler-rt is likely the most sensible place for them.
3 days[compiler-rt][asan] Add wcscpy/wcsncpy; enable wcscat/wcsncat on Windows ↵Yixuan Cao8-4/+150
(#160493) Summary - Add ASan interceptors for wcscpy/wcsncpy on all platforms. - Enable wcscat/wcsncat on Windows (already enabled on POSIX via sanitizer_common). Motivation - Use of wchar string APIs is common on Windows; improve parity with char* string checks. Changes - Implement wcscpy/wcsncpy in asan_interceptors.cpp; check overlap and mark read/write ranges in bytes. - wcsncpy: compute write size in bytes (size * sizeof(wchar_t)) to avoid missed overflows when sizeof(wchar_t) != 1. - Use MaybeRealWcsnlen when available to bound reads. - Register Windows static thunk for wcscpy/wcsncpy/wcscat/wcsncat; rely on sanitizer_common interceptors for wcscat/wcsncat. - Tests: add wcscpy/wcsncpy/wcscat/wcsncat; flush stdout before crash; use resilient FileCheck patterns (reuse [[ADDR]], wildcard for function suffixes and paths, flexible line numbers). Testing - AArch64 Linux: new tests pass with check-asan locally. Follow-up to and based on prior work in PR #90909 (author: branh, Microsoft); builds on that work and addresses review feedback. Thanks! --------- Signed-off-by: Yixuan Cao <caoyixuan2019@email.szu.edu.cn>
4 days[sanitizer] Handle nullptr name in prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME) ↵woruyu2-1/+4
(#160824) ### Summary This PR resolves https://github.com/llvm/llvm-project/issues/160562
4 days[compiler-rt] Disable tests for unavailable builtins (#161275)Akira Hatanaka2-9/+6
The builtins `__fixunstfdi` and `__multc3` may be removed by the preprocessor depending on configuration flags. When this happens, the corresponding tests fail at link time due to missing definitions. Disable these tests when the builtins are not available. Also remove the XFAILs for aarch64 windows. As this test now became a no-op on platforms that lack CRT_HAS_128BIT or CRT_HAS_F128 (aarch64 windows lacks the latter), it no longer fails. This reapplies e9e166e54354330c474457711a8e7a7ca2efd731 and 656707086e5f6fccd2eb57f5aaf987c328c0f4f1 after fixing declarations of the builtins in the tests in b54250940c2cd70f911386b02239b50c165e5354. rdar://159705803 rdar://159705705 --------- Co-authored-by: Martin Storsjö <martin@martin.st>
4 days[compiler-rt] Fix declarations of builtins in test files (#161222)Akira Hatanaka2-13/+19
Replace `long double` and `long double _Complex` with `fp_t` and `Qcomplex` in the test files. This prepares for reapplying 656707086e5f6fccd2eb57f5aaf987c328c0f4f1 and running tests on targets where `fp_t` is not `long double`.
4 daysReapply "[compiler-rt][XRay] Make xray_interface.h C compliant" (#141728)Jan André Reuter2-14/+79
Changes to initial PR (#140068): - Mark failing test as unsupported for powerpc64le, as test failure is unrelated to PR changes. See https://github.com/llvm/llvm-project/issues/141598 --- Original description (from #140068) The XRay interface header uses no C++ specific features aside from using the std namespace and including the C++ variant of C headers. Yet, these changes prevent using `xray_interface.h` in external tools relying on C for different reasons. Make this header C compliant by using C headers, removing the std namespace from std::size_t and guard `extern "C"`. To make sure that further changes to not break the interface accidentially, port one test from C++ to C. This requires the C23 standard to officially support the attribute syntax used in this test case. Note that this only resolves this issue for `xray_interface.h`. `xray_records.h` is also not C compliant, but requires more work to port. Fixes #139902 Signed-off-by: Jan André Reuter <j.reuter@fz-juelich.de>
7 days[scudo] Use TestAllocator wrapper to ensure proper cleanup (#160800)Fabio D'Urso1-4/+4
Instead of directly instantiating scudo::Allocator, using the test TestAllocator wrapper class ensures that unmapTestOnly is called at the end of the test. This fixes the issue of QuarantineIterateOverChunks failing on Fuchsia because of a clobbered TLS pointer left by QuarantineEnabled.
7 days[NFC] [compiler-rt] fix typos (#160803)co63oc5-8/+8
fix typos
7 daysRevert "[compiler-rt] Fix some tests to work with lit internal shell." (#160949)cmtice5-20/+11
Reverts llvm/llvm-project#160728 That appeared to be causing a buildbot failure; reverting this change while I investigate. https://lab.llvm.org/buildbot/#/builders/174/builds/25130
7 days[compiler-rt] Fix some tests to work with lit internal shell. (#160728)cmtice5-11/+20
This is part of our work to migrate lit tests to use internal shell by default (performance improvements).
7 daysRevert "[compiler-rt] Disable tests for unavailable builtins (#158664)"Martin Storsjö2-7/+8
This reverts commit e9e166e54354330c474457711a8e7a7ca2efd731, and the follow-up fix 656707086e5f6fccd2eb57f5aaf987c328c0f4f1. These changes unlocked tests to run on architectures where they didn't run before, showing up as test failures like in https://lab.llvm.org/buildbot/#/builders/66/builds/19787.
7 days[ASan] Update meminstrinsics to use library memmove rather than internal ↵Dan Blackwell2-1/+4
(#160740) Currently `memcpy` and `memset` intrinsics map through to the library implementations if ASan has been inited, whereas `memmove` always calls `internal_memmove`. This patch changes `memmove` to use the library implementation if ASan has been inited.
8 days[compiler-rt] Fix test ifdefs and XFAILs (#160687)Martin Storsjö2-5/+4
This fixes the ifdefs added in e9e166e54354330c474457711a8e7a7ca2efd731; we need to include int_lib.h first before we can expect these defines to be set. Also remove the XFAILs for aarch64 windows. As this test now became a no-op on platforms that lack CRT_HAS_128BIT or CRT_HAS_F128 (aarch64 windows lacks the latter), it no longer fails.
8 days[compiler-rt] fix typos (#160799)co63oc3-5/+5
fix typos
8 days[scudo] Release to OS if a large amount of memory is deallocated. (#160621)Christopher Ferris1-0/+7
Before this change, if large amounts of memory are deallocated within a release interval, the release is put off until the release interval occurs. Unfortunately, for larger class sizes, this could mean that a lot of this memory accumulates and is never released since no more deallocations occur in that size class. To fix this, if `RegionPushedBytesDelta` grows larger than a group size, immediately do a release. This work was originally done by ChiaHungDuan.
8 days[msan] Change personality CHECK to Printf() + Die() (#160626)Thurston Dang1-1/+9
This ports https://github.com/llvm/llvm-project/pull/142821 from TSan. Although MSan doesn't segfault the way TSan did, the failure message was nonetheless cryptic. The improved error message will prepare MSan for the upcoming AppArmorpocalypse.
9 days[compiler-rt] Fix coverage-reset.cpp (#160620)Aiden Grossman1-5/+5
When relanding a previous patch I had accidentally left this patched to tee output into a file rather than run FileCheck. This patch fixes that so the test actually tests what it is supposed to.
9 days[compiler-rt] Disable tests for unavailable builtins (#158664)Akira Hatanaka2-4/+4
The builtins `__fixunstfdi` and `__multc3` may be removed by the preprocessor depending on configuration flags. When this happens, the corresponding tests fail at link time due to missing definitions. Disable these tests when the builtins are not available. rdar://159705803 rdar://159705705
10 days[scudo] Skip special quarantine blocks in iterateOverChunks (#159892)Christopher Ferris2-34/+55
If a quarantine block is allocated, it will be passed through to a user who calls iterateOverChunks. Make these special block allocations state Quarantined so they are not passed to iterateOverChunks. Remove the FIXME in the combined tests for quarantine since this fixes those tests too. Also add a specific new test that fails without this fix.
11 days[ASan][test-only] Allow Darwin test duplicate_os_log_reports to retry (#158662)Dan Blackwell1-2/+7
Currently this test is flaky. I believe that it may be because the logs have not flushed to disk before the `log show` command is run. This patch allows the test to retry reading the log twice more with a 5 second sleep inbetween.
11 days[compiler-rt] [TSan] [Darwin] Fix missing Report() arg in vm layout msg ↵Andrew Haberlandt1-1/+2
(#160171) This fixes a typo introduced in #158665.
11 days[Sanitizer] Option to fallback to stderr if unable to open logfile (#158687)Ellis Hoag4-14/+47
Add the santizier option `log_fallback_to_stderr` which will set the logpath to `stderr` if there is an error with the provided logpath. We've seen this happen when process A has write permission to the logpath, but process B does not. In this case, we'd like process B to fallback to writing to `stderr`, rather than being killed.
12 daysReapply "[compiler-rt] Remove %T from shared object substitutions (#155302)"Aiden Grossman26-164/+179
This reverts commit 05e31438ac9491cfc72c48664480796de874c860. There was quite a bit of churn with this patch, everytime related to the executable no longer being in the same directory as the shared objects. This reland ensures that all of the executables in the tests touched are in the same directory as the shared objects in the substitutions.
2025-09-19[LLVM] Simplify GPU runtimes flag handling (#159802)Joseph Huber1-3/+1
Summary: The AMDGPU hack can be removed, and we no longer need to skip 90% of the `HandleLLVMOptions` if we work around NVPTX earlier. Simplifies the interface by removing duplicated logic and keeps the GPU targets from being weirdly divergent on some flags.
2025-09-19Fix libFuzzer array alignment with empty modules (#159661)Bitshift3-0/+70
The following assertion was being triggered: ``` assert.h assertion failed at llvm-project/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp:237 in void fuzzer::TracePC::UpdateObservedPCs(): M.Size() == (size_t)(ModulePCTable[i].Stop - ModulePCTable[i].Start) ``` # The bug When built with `-fsanitize=fuzzer`, each “module” (.so file, or the binary itself) will be instrumented, and when loaded into the process will make a call to these two functions: - `__sanitizer_cov_8bit_counters_init` - `__sanitizer_cov_pcs_init` Each of these is called with start and end pointers defining an array. In libFuzzer, these functions are implemented with `HandleInline8bitCountersInit` and `HandlePCsInit`. Each of them pushes back the provided pointers into a separate array, `Modules` and `ModulePCTable` respectively. These arrays are meant to be kept in-sync; index i into Modules should refer to the same `.so` as index i into ModulePCTable. The assertion was triggering because these lists got out-of-sync. The problem is that the 8bit handler contains this line: ``` if (Start == Stop) return; ``` but the PC handler contains no such corresponding line. This meant that if a module was ever instrumented but “empty” (its 8bit counter and PC arrays were both of length 0), then its PC array would still be added but its 8bit counter array would not. # Why this issue was never seen before The circumstances to trigger this issue are unusual: - You need a compilation unit that doesn't contain any code (though it may contain global variable declarations and similar). That doesn't happen very often. - That compilation unit must be dynamically linked, not statically linked. If statically linked, it’ll be merged into a single “module” with the main binary, and the arrays will be merged as well; you won’t end up with length-0 arrays. - To notice the issue, assertions must be enabled. If disabled, libFuzzer will be buggy (it may have worse coverage), but it won't crash, and "worse coverage" is extremely unlikely to be noticed. # This change This change solves the issue by adding the same `if (Start == Stop) return;` check to `HandlePCsInit`. This prevents the arrays from getting out-of-sync. This change also adds a test that identifies the previous issue when compiled with assertions enabled, but now passes with the fix.
2025-09-18[scudo] Add missing tracing.h include to primary32 (#159668)Christopher Ferris2-0/+3
2025-09-18Fix possible underflow in ParseAndSetPath (#159389)gbMattN1-0/+3
If an empty path is passed, the internal_strlen -1 below will loop round to become uptr max. Adding this check ensures that this would be caught
2025-09-17[sanitizer-common][Darwin] Improve mach_vm_region_recurse error handling ↵Andrew Haberlandt2-7/+59
(#158670) Some sanitizers use mach_vm_region_recurse on macOS to find a sufficiently large gap to allocate shadow memory. Some sandboxes do not allow this. When we get KERN_DENIED, we suggest to the user that it may have been blocked by the sandbox. For error codes other than KERN_INVALID_ADDRESS and KERN_DENIED, we make sure to log a message and not use the address. rdar://160625998
2025-09-17[scudo] Move the trace point in releaseToOSMaybe (#159204)Christopher Ferris2-4/+12
Move the trace point until right before the mark free blocks call for the primary. This avoids adding extra calculations on a fast path.
2025-09-17[sanitizer_common][tsan][Darwin] Improve message for unsupported vm config ↵Andrew Haberlandt3-3/+38
on Apple platforms (#158665) An existing log message is triggered in InitializePlatformEarly if the address space max is not as sufficient for TSAN. Some Apple platforms expand the address space limit, but reserve much of the space TSAN needs. Therefore, we now check that the kernel has not mapped over the address space that we intend to use. IsAddressInMappedRegion is added to sanitizer_common. This introduces a new dependency on mach_vm_region_recurse during TSAN startup, so this intentionally fails softly (to avoid breaking current users who may be in a sandbox that doesn't allow this). rdar://135265279
2025-09-17[X86] Fixes for AMD znver5 enablement (#159237)Umesh Kalvakuntla1-0/+6
- cpuid bit for prefetchi is different from Intel (https://docs.amd.com/v/u/en-US/24594_3.37) - Fix cpu family model numbers
2025-09-16Reapply "[NFC] Fix CodeQL violations in compiler-rt. (#157793)" (#157913) ↵Amit Kumar Pandey5-19/+21
(#159097) Fix below buildbot failure. ``` /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:172:42: error: use of undeclared identifier 'uint' 172 | Printf("Flag: %s %u\n", Name, (uint)Val); ``` Replace uint with uint32_t cast. This reverts commit 8062b166762b51f1c3a9168e7031babde3e330a8.
2025-09-16[cmake] Add cmake file for hexagon-builtins baremetal (#151500)quic-k1-0/+26
This will be used to build hexagon-builtins for baremetal. Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com>
2025-09-15[sanitizer-common] Improve diagnostic when ASAN fails to allocate shadow ↵Andrew Haberlandt1-17/+79
(#158378) Sometimes we are unable to find a sufficiently large gap to allocate the dynamic ASAN shadow. If a gap is not found, we will now output a (consolidated) memory map to show the user what regions were unavailable and how much memory we need. rdar://159142896
2025-09-15[Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (#157364)Sirraide2-2/+2
GCC 14 also made this an error by default, so we’re following suit. Fixes #74605
2025-09-15[compiler-rt][lit] Check glibc version without external packages (#158387)Arthur Eubanks1-26/+22
Alternative to #158236 without requiring external packages
2025-09-15[compiler-rt] Remove enable_execute_stack support on arm64 Darwin (#158386)Akira Hatanaka1-0/+5
`enable_execute_stack` is not supported on arm64 Darwin because: - It calls mprotect with `PROT_WRITE | PROT_EXEC`, which is rejected on this platform. - It assumes a fixed 4K page size, which is not guaranteed. This change disables building `enable_execute_stack` on arm64 Darwin and fixes the failing test: `compiler-rt/test/builtins/Unit/enable_execute_stack_test.c`. rdar://159705691
2025-09-14[Test][ASan][Sanitizer] Make atos symbolizer test asan and simulator only ↵thetruestblue1-6/+3
(#158522) Simulator environments run only atos symbolizer rather than falling back to dladdr. Because sanitizer-common does not target simulators, move this test into asan and simulator only to make it predicatable test. Original change sha: 0f9bfe0a02ffff077a1a98065069b52744e31723 rdar://108003900
2025-09-12[compiler-rt][AArch64] Don't use x18 in __arm_sme_save (#157802)Sander de Smalen1-5/+5
The AAPCS recommends avoiding the use of x18 as it may be used for other purposes such as a shadow call stack. In this particular case it could just as well use x16 instead.
2025-09-12Revert "[compiler-rt][test] Use packaging.version.Version to compare glibc ↵David Spickett1-3/+3
versions" (#158230) Reverts llvm/llvm-project#142596 Got reports that some tests previously skipped are running again and failing.
2025-09-11[scudo] Add tracing framework (#156112)Christopher Ferris5-4/+73
Add a methodology to allow tracing. By default, this is disabled, but it can be enabled for any OS that supports it. Currently, only releaseToOSXXX functions have trace points added.
2025-09-11[compiler-rt] Fix binary-id-offset.c test to not require shell. (#157954)cmtice1-10/+12
As part of our migration for making lit internal shell be the default, this updates binary-id-offset.c to no longer require shell (at the cost of duplicating some code).
2025-09-11[TSan] Add interceptor for os_unfair_lock_lock_with_flags (#153815)Dan Blackwell2-1/+48
Also update os_unfair_lock tsan test to check this function on platforms where it is available. rdar://158294950
2025-09-11[compiler-rt][test] Use packaging.version.Version to compare glibc versions ↵David Spickett1-3/+3
(#142596) Instead of distutils.LooseVersion. distutils was depracated (https://peps.python.org/pep-0632/) and has been removed in Python 3.12 (https://docs.python.org/3/whatsnew/3.12.html) > Of note, the distutils package has been removed from the standard library. packaging's version is able to handle glibc's major.minor: https://packaging.pypa.io/en/latest/version.html#packaging.version.Version > For these modules or types, use the standards-defined Python Packaging Authority packages specified: > distutils.version — use the packaging package Relates to https://github.com/llvm/llvm-project/issues/54337
2025-09-10[compiler-rt] Update fuzzer/focus-function.test to not require shell. (#157967)cmtice1-5/+4
Replace sub-shell for-loops with python calls so this test can run in the lit internal shell. This is part of our work migrating to use the internal shell as the default for lit tests.
2025-09-10[compiler-rt] Fix sig-trap.test to work with lit internal shell. (#157966)cmtice1-1/+1
Update sig-trap.test to work with the lit internal shell, as part of our migration to make the internal shell the default for lit tests.
2025-09-10[compiler-rt] Mark some tests as unsupported on Windows. (#157972)cmtice4-0/+8
PR157951 removed 'REQUIRES: shell' from several tests, which (among other things) caused them to start running on some Windows builders -- the 'REQUIRES: shell' prevented that. Some of those tests fail on Windows. This PR marks those failing tests as UNSUPPORTED on Windows.