20071 Commits

Author SHA1 Message Date
Christopher Ferris
6b3556a6ea
[scudo] Add Last entry to ReleaseToOS enum. (#188645)
This allows static asserts to be set in tracing code that might use the
ReleaseToOS values as indexes.

This would have caused a compile failure instead of a runtime crash when
I added the use of a new ReleaseToOS value.
2026-03-26 12:32:56 -07:00
Joseph Huber
ffd6a13b5f
[compiler-rt] Rework profile data handling for GPU targets (#187136)
Summary:
Currently, the GPU iterates through all of the present symbols and
copies them by prefix. This is inefficient as it requires a lot of small
high-latency data transfers rather than a few large ones. Additionally,
we force every single profiling symbol to have protected visibility.
This means potentially hundreds of unnecessary symbols in the symbol
table.

This PR changes the interface to move towards the start / stop section
handling. AMDGPU supports this natively as an ELF target, so we need
little changes. Instead of overriding visibility, we use a single table
to define the bounds that we can obtain with one contiguous load.

Using a table interface should also work for the in-progress HIP
implementation for this, as it wraps the start / stop sections into
standard void pointers which will be inside of an already mapped region
of memory, so they should be accessible from the HIP API.

NVPTX is more difficult as it is an ELF platform without this support. I
have hooked up the 'Other' handling to work around this, but even then
it's a bit of a stretch. I could remove this support here, but I wanted
to demonstrate that we can share the ABI. However, NVPTX will only work
if we force LTO and change the backend to emit variables in the same

TL;DR, we now do this:
```c
struct { start1, stop1, start2, stop2, start3, stop3, version; } device;
struct host = DtoH(lookup("device"));
counters = DtoH(host.stop - host.start)
version = DtoH(host.version);
```
2026-03-26 10:17:43 -05:00
Dan Blackwell
bbccfa5654
[ASan] Make __SANITIZER_DISABLE_CONTAINER_OVERFLOW__ bypass definitions return values (#188237)
Currently all of these functions are empty bodies; this means that when
including this header and compiling with
__SANITIZER_DISABLE_CONTAINER_OVERFLOW__ defined, warnings are emitted
about the missing return values for those functions that do return
values.

This patch returns success values for all those check functions with
non-void return types. Note: these were originally added in
https://github.com/llvm/llvm-project/pull/163468.
2026-03-26 13:31:27 +00:00
Simon Tatham
80831832e0
[compiler-rt][ARM] Double-precision FP support functions (#179920)
This commit adds C helper functions `dnan2`, `dnorm2` and `dunder` for
handling the less critical edge cases of double-precision arithmetic,
similar to `fnan2`, `fnorm2` and `funder` that were added in commit
f7e652127772e93.

It also adds a header file that defines some register aliases for
handling double-precision numbers in AArch32 software floating point in
an endianness-independent way, by providing aliases `xh` and `xl` for
the high and low words of the first double-precision function argument,
regardless of which of them is in r0 and which in r1, and similarly `yh`
and `yl` for the second argument in r2/r3.
2026-03-26 09:10:15 +00:00
Jake Egan
25904ac915
[sanitizer_common] Implement address sanitizer on AIX: stack unwinding (#138188)
Implement unwind.h-based stack unwinding routines on AIX.

Issue: https://github.com/llvm/llvm-project/issues/138916
2026-03-26 02:13:47 -04:00
Christopher Ferris
a3260f6582
[scudo] Remove some android wrapper checking. (#188339)
Tests for Android specific behavior don't really belong here since it is
affected by the config which is not necessarily the same on Android.
There are already tests that the config options and flag options work
properly. Android wrapper tests belong to Android.
2026-03-25 10:48:22 -07:00
Fabio D'Urso
1d2f14f625
[scudo] Use portable TEST_SKIP macro (#188045)
Which expands to ZXTEST_SKIP on Fuchsia.
2026-03-25 11:46:52 +01:00
Andrew Haberlandt
a5a7f6266e
[compiler-rt] CRT builtins tests should not run on mac/windows under LLVM_ENABLE_RUNTIMES (#187835)
#171941 got the builtins tests running under LLVM_ENABLE_RUNTIMES by
testing the builtins as part of the runtimes build.

As a consequence, CMake in `lib/builtins/` is no longer visible when
configuring the tests (but `test/builtins/` is). This means that the
`cmake_dependent_option` from `lib/builtins/` is not accounted for by
the tests, allowing COMPILER_RT_BUILD_CRT to be YES when
COMPILER_RT_HAS_CRT is NO. As a consequence, the CRT tests are running
on platforms where COMPILER_RT_HAS_CRT is false (#176892).


367da15a11/compiler-rt/lib/builtins/CMakeLists.txt (L1106-L1108)

Although the long-term solution could be to split both the builtins (and
their tests) out of compiler-rt into a top-level directory with shared
options, this works around the issue for the moment by checking both
COMPILER_RT_HAS_CRT and COMPILER_RT_BUILD_CRT before enabling the "crt"
feature.

Fixes #176892
2026-03-24 23:49:14 -07:00
Vitaly Buka
3b04d26abd
[asan] Convert __SANITIZER_DISABLE_CONTAINER_OVERFLOW__ tests to C (#188406)
As-is tests do not pass on android with older C++ headers.
There is nothing C++ specific in tests.

Followup to #181721.
2026-03-24 22:28:46 -07:00
Vitaly Buka
cb12534650 [compiler-rt] Suppress unused variable report in emutls
Pull Request: https://github.com/llvm/llvm-project/pull/188329
2026-03-24 18:22:41 -07:00
Vitaly Buka
9fd8bc0f0e
[libFuzzer] Fix -Wunused-variable when building with NDEBUG (#188301)
The variable `FuzzerInitIsRunning` is only used within `assert()`.
Follow up to #178342.
2026-03-24 18:23:37 +00:00
Joseph Huber
e73d8f8fc5
[compiler-rt] Support unit tests for the GPU build (#187895)
Summary:
This PR enables the basic unit tests for builtins to be run on the GPU
architectures. Other targets like profiling are supported, but the
host-device natures will make it more difficult to adequately unit
test. It may be be possible to do basic tests there, to simply verify
that
counters are present and in the proper format for when they are copied
to the host.
2026-03-24 11:44:24 -05:00
Daniil Kovalev
34875331d9
[PAC][compiler-rt] Use __ptrauth qualifier instead of builtins (#188109)
Since #100830 has landed, we no longer need to rely on builtins
2026-03-24 09:24:19 +00:00
Dan Blackwell
96fb2942cb
[ASan] Enable __SANITIZER_DISABLE_CONTAINER_OVERFLOW__ tests (#181721)
Now that the corresponding libcxx change has landed, these tests should
be passing on some platforms.

This patch re-enables them for all platforms, so that we can see which
bots these do not work on and mark them unsupported accordingly.

rdar://167946476
2026-03-24 08:23:15 +00:00
Midhunesh
6a8a1008b5
[compiler-rt] Error only if sanitizer builds are enabled (#187944)
This fix is to error out only if sanitizer builds are enabled as opposed
to forcing flang to use an option or install the development package.
2026-03-24 06:18:25 +05:30
Simon Tatham
44df4116c8
[compiler-rt][ARM] cmake properties for complicated builtin sources (#179919)
In the builtins library, most functions have a portable C implementation
(e.g. `mulsf3.c`), and platforms might provide an optimized assembler
implementation (e.g. `arm/mulsf3.S`). The cmake script automatically
excludes the C source file corresponding to each assembly source file it
includes. Additionally, each source file name is automatically
translated into a flag that lit tests can query, with a name like
`librt_has_mulsf3`, to indicate that a function is available to be
tested.

In future commits I plan to introduce cases where a single .S file
provides more than one function (so that they can share code easily),
and therefore, must supersede more than one existing source file.

I've introduced the `crt_supersedes` cmake property, which you can set
on a .S file to name a list of .c files that it should supersede. Also,
the `crt_provides` property can be set on any source file to indicate a
list of functions it makes available for testing, in addition to the one
implied by its name.
2026-03-23 16:01:12 +00:00
Michael Jones
6891a6ef0e
[compiler-rt] Add bitmask to fix warning (#187812)
After #186881 was merged the gcc libc bots started complaining about the
conversion from u8 to 2 bit integer being unsafe (see:
https://lab.llvm.org/buildbot/#/builders/131/builds/42788). This PR
adds a bitmask that fixes the warning.
2026-03-20 16:46:38 -07:00
Christopher Ferris
8cc0124508
[scudo] Make the default for size/align checks to not die. (#187799) 2026-03-20 15:32:16 -07:00
Christopher Ferris
1b44e34b18
[scudo] Add free_sized and free_aligned_sized (#186881)
Add one new flag, dealloc_align_mismatch that turns on/off alignment
checks. Add three new config parameters, one for deallocate type
mismatch (such as abort on new/free if true), one for checking if the
size parameter matches on dealloc and one for checking if the alignment
is correct on a dealloc.

Add extra flags to be passed for to indicate to do an align/size check.

Update report functions to better indicate the errors. Add unit tests
for all of these.

This is based on these upstream cls by jcking:

https://github.com/llvm/llvm-project/pull/147735
https://github.com/llvm/llvm-project/pull/146556
2026-03-20 13:26:35 -07:00
Roman Vinogradov
ca54948d0b
[ASan] Fix missed poisoned suffix in first granule in __asan_region_is_poisoned (#187466)
Align beg address down instead of up in __asan_region_is_poisoned(), so
the shadow scan includes the first granule. This fixes a false negative
when first granule has an unpoisoned prefix and poisoned suffix.

Add test that covers this scenario.
2026-03-20 10:05:19 -07:00
Joseph Huber
d18a784d41
[compiler-rt] Define GPU specific handling of profiling functions (#185763)
Summary:
The changes in https://www.github.com/llvm/llvm-project/pull/185552
allowed us to
start building the standard `libclang_rt.profile.a` for GPU targets.
This PR expands this by adding an optimized GPU routine for counter
increment and removing the special-case handling of these functions in
the OpenMP runtime.

Vast majority of these functions are boilerplate, but we should be able
to do more interesting things with this in the future, like value or
memory profiling.
2026-03-19 10:51:48 -05:00
Ross Burton
015e3d2b20
[compiler-rt] Unify python shebangs (#187285)
As per PEP-0394[1], there is no real concensus over what binary names
Python has, specifically 'python' could be Python 3, Python 2, or not
exist.

However, everyone has a python3 interpreter and the scripts are all
written for Python 3. Unify the shebangs so that the ~50% of shebangs
that use python now use python3.

[1] https://peps.python.org/pep-0394/
2026-03-18 17:48:08 -07:00
Roman Vinogradov
2caba086ab
[ASan] Fix overflow and last byte handling in __asan_region_is_poisoned (#183900)
__asan_region_is_poisoned() uses an exclusive end address
(end = beg + size) to validate the region [beg, end) and to compute
the aligned inner shadow region. This causes correctness issue
near memory range upper boundary and could trigger address space
overflow on 32-bit targets.

1. Incorrect handling of the last byte of a memory range

   The implementation checks AddrIsInMem(end) instead of the last
   application byte (end - 1). For regions ending at the last byte
   of Low/Mid/HighMem (e.g. __asan_region_is_poisoned(kHighMemEnd, 1)),
   this returns end (kHighMemEnd + 1) instead of the original 
   pointer. This behavior is inconsistent with the function’s 
   semantics and with __asan_address_is_poisoned().

2) address space overflow and invalid shadow range

If a region ends at the top of the virtual address space (kHighMemEnd),
   e.g. on 32-bit targets, end = beg + size could wrap to 0.
   This violated the invariant beg < end and could trigger
   the CHECK failure.

   Additionally, overflow in RoundUpTo alignment computations
   for aligned_b could produce an invalid shadow region spanning
   LowShadow to HighShadow across ShadowGap, leading mem_is_zero()
   to access unmapped memory and crash.

Fix by switching to an inclusive last byte:

  last = beg + size - 1

All checks are now performed on beg and last. The aligned inner 
shadow region is also computed from [beg, last]. Additional guard 
for aligned_b prevents the mapping to shadow if aligned_b is wrapped
(in this case the aligned inner region is also empty and doesn't 
require the shadow scan via mem_is_zero()).

This fixes incorrect return values at memory range ends and 
prevents overflow related crashes on 32-bit targets.

Test is extended to cover these boundary cases.

---------

Co-authored-by: Vitaly Buka <vitalybuka@gmail.com>
2026-03-18 09:43:19 -07:00
Midhunesh
d783723a58
[compiler-rt] Update runtime build script to detect RPC XDR header for AIX (#186977)
`sanitizer_common` and its tests depend on the RPC XDR header for layout
compatibility. When this header is absent from a CI or build
environment, changes that silently break the expected struct layout go
undetected, since there is nothing to fail the build.
The default is opt-in — error on missing header is on by default for AIX
(where the dependency is known and the package is `bos.net.nfs.adt`) and
off by default elsewhere.

Changes:

1. On AIX, checks for `tirpc/rpc/xdr.h`; on all other platforms, checks
for `rpc/xdr.h`
2. Introduces `COMPILER_RT_REQUIRE_RPC_XDR_H` CMake option (default ON
on AIX, OFF elsewhere) that, when set, turns a missing header into a
fatal configuration error with an actionable message
3. Drive-by fix: Normalizes `HAVE_RPC_XDR_H` to 0 when the header is
absent, for consistent downstream `if()/#cmakedefine` behavior
2026-03-18 19:52:22 +05:30
cherrymui
1098b95dac
[sanitizer_common] Define SANITIZER_WEAK_IMPORT for Go race detector (#186525)
Currently, when building the Go race detector (when SANITIZER_GO
is set), SANITIZER_WEAK_IMPORT is no-op. It is perfectly fine to
define SANITIZER_WEAK_IMPORT for Go just like other cases. That
will tell the Go linker to treat _dyld_get_dyld_header as a weak
import.

Perhaps SANITIZER_WEAK_ATTRIBUTE can also be defined for Go. That
would be a separate patch.
2026-03-16 18:49:56 +00:00
Vitaly Buka
5a87cba929
[NFC][sanitizer] Accept ETIMEDOUT in getpwnam_r_invalid_user.cpp (#186538)
On some systems, looking up an result in a timeout.

Error here is not a sign of compiler-rt issue.

Fixes flakiness on
https://lab.llvm.org/buildbot/#/builders/sanitizer-ppc64le-linux
2026-03-14 00:33:28 +00:00
Brian Cain
cef418ec4b
[compiler-rt] Add ASan/UBSan runtime support for Hexagon Linux (#183982)
Add the architecture-specific pieces needed for the ASan and UBSan
sanitizer runtimes to build and run on hexagon-unknown-linux-musl.

Without this patch, building sanitizer runtimes for Hexagon Linux fails
with:

  sanitizer_linux.cpp: error: member access into incomplete type
      'struct stat64'

because musl libc does not provide struct stat64. This patch routes
Hexagon through the statx() syscall path (like LoongArch) to avoid the
stat64 dependency entirely.

Changes:

* asan_mapping.h: Add ASAN_SHADOW_OFFSET_CONST (0x20000000) for Hexagon
with shadow layout documentation.
* sanitizer_linux.cpp: Implement internal_clone() for Hexagon using
inline assembly (trap0 syscall, generic clone argument order: flags,
stack, ptid, ctid, tls). Route Hexagon through the statx() path for stat
operations since musl lacks struct stat64.
* sanitizer_linux.h: Add Hexagon to the internal_clone() declaration
guard.
* sanitizer_stoptheworld_linux_libcdep.cpp: Add Hexagon to the
StopTheWorld architecture guard with register definitions.
* sanitizer_asm.h: Define ASM_TAIL_CALL as 'jump' for Hexagon.
* CMakeLists.txt: Add -fno-emulated-tls for Hexagon targets. Hexagon
Linux uses native TLS via the UGP register; emulated TLS produces broken
sanitizer runtimes with unresolvable __emutls references.
2026-03-12 20:27:11 -05:00
Christopher Ferris
dae2923901
[scudo] Display flags on secondary cache entries. (#185786) 2026-03-12 13:19:33 -07:00
DylanFleming-arm
d682325961
[libc] Remove unused AOR_v20.02 directory (#185951)
As far as I am aware, AOR is no longer used anywhere within LLVM, as
most of the required code has since been ported to elsewhere within the
project.

Removes the entire directory, and updates some now outdated comments.
2026-03-12 10:14:04 -04:00
Keith Packard
ab6bb1bab6
compiler-rt/arm: Check for overflow when adding float denorms (#185245)
When the sum of two sub-normal values is not also subnormal, we need to
set the exponent to one.

Test case:

static volatile float x = 0x1.362b4p-127;
static volatile float x2 = 0x1.362b4p-127 * 2;

int
main (void)
{
	printf("x %a x2 %a x + x %a\n", x, x2, x + x);
	return x2 == x + x ? 0 : 1;
}

Signed-off-by: Keith Packard <keithp@keithp.com>
2026-03-12 10:37:48 +00:00
Nico Weber
d371f42a47
Revert "[CFI] Expand test to include minimal runtime" (#185935)
Reverts llvm/llvm-project#183646

Breaks tests if ubsan_minimal runtime isn't built, see:
https://github.com/llvm/llvm-project/pull/183646#issuecomment-3994252478
2026-03-11 17:42:05 +00:00
Alex Crichton
7a43f770a0
[WebAssembly] Remove __c_longjmp from compiler-rt (#185798)
This is similar to #185770 where it removes an
exception-handling-related symbol from `compiler-rt` in favor of having
definitions elsewhere. The compiler-rt library is linked into all shared
objects, for example, which can result in duplicate definitions of a
symbol where this tag wants to have one unique definition. The intention
behind this commit is to defer the definition of this symbol to
downstream libraries, such as the definition of `longjmp` itself. An
example of this is WebAssembly/wasi-libc#772 where the responsibility of
defining this symbol now lies with wasi-libc.
2026-03-10 21:55:06 -07:00
Alex Crichton
a3f28233fc
[WebAssembly] Move __cpp_exception to libunwind (#185770)
The `__cpp_exception` symbol is now defined in libunwind instead of
compiler-rt. This is moved for a few reasons, but the primary reason is
that compiler-rt is linked duplicate-ly into all shared objects meaning
that it's not suitable for define-once symbols such as
`__cpp_exception`. By moving the definition to the user of the symbol,
libunwind itself, that guarantees that the symbol should be defined
exactly once and only when appropriate. A secondary reason for this
movement is that it avoids the need to compile compiler-rt twice: once
with exception and once without, and instead the same build can be used
for both exceptions-and-not.
2026-03-11 00:43:11 +00:00
Joseph Huber
fd069a46bf
[copmiler-rt] Initial support for building profile library on the GPU (#185552)
Summary:
As suggested in https://github.com/llvm/llvm-project/pull/177665, we
should build a GPU version of the compiler-rt profile library instead of
writing it in-line in the lowering. This PR does not define anything GPU
specific, it simply re-uses the baremetal handling. Later PRs will
prevent the GPU specific handling we would want to do to optimize
counter handling on the GPU.

Note that this will require using the cache file, or setting these
options
manually for existing users. Hopefully if people are using the cache
file
as they should it won't break anything.
2026-03-10 13:45:18 -05:00
Christopher Ferris
3e9808befb
[scudo] Use a fixed format for the milliseconds in latest release. (#185097) 2026-03-09 12:50:32 -07:00
Fabio D'Urso
ae8f614a0c
[scudo] Add missing class name specifier in mem_map_fuchsia (#185389) 2026-03-09 18:48:53 +01:00
Matthew Nagy
2a9372ff02
halt_on_error flag for TySan and docs (#182479) 2026-03-09 15:42:25 +00:00
Rainer Orth
d6b33bda13
[ubsan_minimal] Build on Solaris (#184976)
Two tests currently `FAIL` on Solaris/amd64 and Solaris/sparcv9:

```
  SafeStack-Standalone-i386 :: overflow.c
  SafeStack-Standalone-x86_64 :: overflow.c
```

This happens because `libclang_rt.ubsan_minimal.a` isn't built on
Solaris although it's required with `-fsanitize-minimal-runtime`.

This patch fixes this.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.
2026-03-07 08:30:33 +01:00
Nico Weber
4d53c42f55 builtins: Make cmake formatting self-consistent aftr #183871
No behavior change.
2026-03-06 15:33:30 -05:00
Saleem Abdulrasool
57f1ec6e0a
builtins: adjust FP80 source management (#183871)
We would previously include the FP80 sources into the Windows build if
we built with the GNU driver rather than the `cl` driver.
2026-03-06 11:12:13 -08:00
Kito Cheng
d64a9fe781
[compiler-rt][RISCV] Initialize length only when __init_riscv_feature… (#115449)
…_bits success

That could give us a simple way to detect `__init_riscv_feature_bits`
got fail.

See also https://github.com/riscv-non-isa/riscv-c-api-doc/pull/95
2026-03-06 19:37:11 +08:00
Sadaf Ebrahimi
ea65e8593e
[scudo] Move getResidentPages function (#183138)
Moving getResidentPages out of linux.cpp and adding it to MemMapBase
2026-03-05 12:38:06 -06:00
Sean Fertile
df1a53ae24
Disable leak sanitizer test on ppc. (#184414)
Test is flaky and fails due to machine load on the build bots. Disable
until we can split the build bots over more machines.
2026-03-03 15:27:20 -05:00
PiJoules
f42b8a18d9
[sanitizer][Fuchsia] Define interceptor for reallocarray on Fuchsia (#184410) 2026-03-03 18:48:12 +00:00
Vitaly Buka
eba4a76597
[CFI] Expand test to include minimal runtime (#183646)
`ubsan_minimal` contains some CFI tests, but it would be nice have one
on CFI side.
2026-03-02 21:07:19 -08:00
Simon Tatham
36c6c689dc
[compiler-rt][ARM] Fix conditions for strict-mode FP testing (#183507)
On sufficiently old versions of the Arm architecture, the optimized FP
routines are not enabled. So commit a84ee1416b6c179 should not have
enabled the extra-strict tests that go with them.

Also in that commit, I wrote a comment saying I was setting two separate
compile-time definitions (-DCOMPILER_RT_ARM_OPTIMIZED_FP and
-DCOMPILER_RT_ARM_OPTIMIZED_FP_THUMB1), and then didn't actually do it!
This caused the strict mulsf3 tests to be wrongly disabled in Thumb2.
2026-03-02 09:30:19 +00:00
Benjamin Stott
d412b04a88
[UBSan] Wrap Location variants in anonymous union (#168866)
(Addresses the FIXME)
2026-03-01 06:25:12 +00:00
MacGyver Codilla
10b1b7857b
[ASan] Mark recent integration tests as accordingly for MSVC (#135889)
Both of these tests will cause an unsuccessful pass when using msvc.

`shadowed-stack-serialization.cpp` - XFAIL due to the metadata not being
generated.
`fakeframe-right-redzone.cpp` - UNSUPPORTED due to the optimization
limitations of the msvc compiler.

---------

Co-authored-by: MacGyver Codilla <mcodilla@microsoft.com>
2026-03-01 06:23:28 +00:00
Reagan
b2ce908a48
[compiler-rt][CMake] Fix build when specifying --stdlib= (with 2 dashes) (#136111)
You can pass the stdlib argument either as -stdlib and --stdlib - the
previous regex did not account for this however - which caused the build
to fail, as a --stdlib argument would be replaced with a single dash,
causing clang to assume reading from stdin and the build to fail:

clang++: error: -E or -x required when input is from standard input
clang++: error: cannot specify -o when generating multiple output files

The files
[libcxxabi/CMakeLists.txt](bf6986f9f0/libcxxabi/CMakeLists.txt (L261))
and
[libunwind/CMakeLists.txt](bf6986f9f0/libunwind/CMakeLists.txt (L257))
account for this by removing --stdlib first.

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2026-03-01 06:22:27 +00:00
Vitaly Buka
b354b206d3
[SafeStack] Allow -fsanitize-minimal-runtime with -fsanitize=safestack (#183644)
SafeStack does not require a full sanitizer runtime, so it should be
compatible
with the minimal runtime flag.
2026-02-27 03:35:58 +00:00