6782 Commits

Author SHA1 Message Date
Hans Wennborg
21f94950a8
[compiler-rt] Try bumping soft_rss_limit again (#188441)
Previous instance: #171469
2026-04-01 10:19:48 +02:00
PiJoules
911dc4139d
[compiler-rt][asan] Forward fix for free_aligned_sized_mismatch.cpp (#189760)
Mark this test as UNSUPPORTED for android since android's libc doesn't
seem to support aligned_alloc.
2026-03-31 22:04:54 +00:00
Samuel Thibault
c1ebd2f1c0
[compiler-rt] Disable asan tests on GNU/Hurd (#169209)
Like OpenBSD, asan does not support GNU/Hurd yet.
2026-03-31 13:55:12 -07:00
PiJoules
78c5d68029
[asan] Add size/alignment checks for free_[aligned_]sized (#189216)
Historically, alignment and size weren't taken into account when freeing
allocations since `free` just takes a pointer. With `free_sized` and
`free_aligned_sized`, we can do these size and alignment checks in asan
now. This adds a new report type specifically for these functions.

Checking is hidden behind a new env flag `free_size_mismatch` which is
enabled by default, but downstream users can opt out of it.

The bulk of this PR was generated by gemini but thoroughly reviewed and
edited by me to the best of my ability.
2026-03-31 19:10:43 +00:00
Simon Tatham
0cecacd971
[compiler-rt][ARM] Optimized double precision FP add/sub (#179921)
The one new assembly source file, `arm/adddf3.S`, implements both
addition and subtraction via cross-branching after flipping signs, since
both operations must provide substantially the same logic. The new cmake
properties introduced in a prior commit are used to arrange that
including `adddf3.S` supersedes the C versions of both addition and
subtraction, and also informs the test suite that both functions are
available to test.
2026-03-31 12:00:11 +01:00
PiJoules
a5fa4dba6e
[compiler-rt] Add interceptors for free_[aligned_]sized for asan+hwasan (#189109) 2026-03-27 23:16:52 +00:00
Dan Blackwell
015994b7f9
[ASan][test-only] Remove superfluous guards in stack_container_dynamic_lib.c (#188469)
As noted in https://github.com/llvm/llvm-project/pull/188406 comments,
the documentation recommends guarding only with
__has_feature(address_sanitizer). This patch updates the test to follow
the same pattern by removing the
__SANITIZER_DISABLE_CONTAINER_OVERFLOW__ checks. Having this macro
defined results in the common_interface_defs.h header defining the
contiguous container functions as no-ops anyway.

This is a followup to https://github.com/llvm/llvm-project/pull/188406.
2026-03-27 10:10:09 +00: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
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
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
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
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
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
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
Matthew Nagy
2a9372ff02
halt_on_error flag for TySan and docs (#182479) 2026-03-09 15:42:25 +00: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
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
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
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
Dan Blackwell
ed1a1eda0f
[compiler-rt][Fuzzer] Relax reduce_inputs.test to account for non-determinism (#182495)
I have seen that very occasionally this test is failing on a bot, with
only 3 files in the corpus. After running the test in a loop 4000+
times, I witnessed this same failure twice.

In both cases the first corpus member was some string not containing a
'F'; the second corpus member was 'F[' or 'FZ'; and the final corpus
member 'FUZ'.

In a normal run there is an intermediate corpus member 'FU.' - so this
test is failing in very rare cases where the fuzzer gets lucky and
matches 2 branch conditions in one mutation.

This patch allows the FileCheck condition to match 3 or 4 corpus files.
It may be possible for the fuzzer to reach the target in 2 files, but I
think that if that is possible, it will be exceptionally rare.

rdar://170440934
2026-02-25 10:55:41 -08:00
Simon Tatham
a84ee1416b
[compiler-rt][ARM] Enable strict mode in divsf3/mulsf3 tests (#179918)
Commit 5efce7392f3f6cc added optimized AArch32 assembly versions of
mulsf3 and divsf3, with more thorough tests. The new tests included test
cases specific to Arm's particular NaN handling rules, which are
disabled on most platforms, but were intended to be enabled for Arm.

Unfortunately, they were not enabled under any circumstances, because I
made a mistake in `test/builtins/CMakeLists.txt`: the command-line `-D`
option that should have enabled them was added to the cflags list too
early, before the list was reinitialized from scratch. So it never ended
up on the command line.

Also, the test file mulsf3.S only even _tried_ to enable strict mode in
Thumb1, even though the Arm/Thumb2 implementation would also have met
its requirements.

Because the strict-mode tests weren't enabled, I didn't notice that they
would also have failed absolutely everything, because they checked the
results using the wrong sense of comparison! I used `==`, but that
comparison was supposed to be a drop-in replacement for
`compareResultF`, which returns zero for equality. Changed the tests to
use `!=`.

Finally, I've also added a macro to each test so that it records the
source line number of each failing test case. That way, when a test
fails, you can find it in the test source more easily, without having to
search for the hex numbers mentioned in the failure message.
2026-02-24 09:08:06 +00:00
Honey Goyal
aeb7580d36
Make mmap-munmap interceptor fail earlier (#171295)
If the address range is not covered by shadow memory, make interceptors
like mmap fail earlier.

---------

Signed-off-by: Abhishek Varma <abhvarma@amd.com>
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Signed-off-by: hanhanW <hanhan0912@gmail.com>
Signed-off-by: Nikita B <n2h9z4@gmail.com>
Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Co-authored-by: Min-Yih Hsu <min.hsu@sifive.com>
Co-authored-by: Sersawy <65075626+Abdelrhmansersawy@users.noreply.github.com>
Co-authored-by: Krzysztof Parzyszek <Krzysztof.Parzyszek@amd.com>
Co-authored-by: Walter Lee <49250218+googlewalt@users.noreply.github.com>
Co-authored-by: cpist (He / Him) <tinyfrog12@gmail.com>
Co-authored-by: Jonathan Cohen <joncoh@apple.com>
Co-authored-by: Charitha Saumya <136391709+charithaintc@users.noreply.github.com>
Co-authored-by: Mircea Trofin <mtrofin@google.com>
Co-authored-by: Mingming Liu <mingmingl@google.com>
Co-authored-by: Atharv Mane <atharvamane19@gmail.com>
Co-authored-by: Sam Clegg <sbc@chromium.org>
Co-authored-by: vporpo <vasileios.porpodas@amd.com>
Co-authored-by: Usama Hameed <u_hameed@apple.com>
Co-authored-by: PiJoules <6019989+PiJoules@users.noreply.github.com>
Co-authored-by: Muhammad Bassiouni <60100307+bassiounix@users.noreply.github.com>
Co-authored-by: Roland McGrath <mcgrathr@google.com>
Co-authored-by: Jakub Kuderski <jakub@nod-labs.com>
Co-authored-by: LLVM GN Syncbot <llvmgnsyncbot@gmail.com>
Co-authored-by: Krzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Co-authored-by: Aiden Grossman <aidengrossman@google.com>
Co-authored-by: Kelvin Li <kli@ca.ibm.com>
Co-authored-by: Andrei Elovikov <a.elovikov@gmail.com>
Co-authored-by: Craig Topper <craig.topper@sifive.com>
Co-authored-by: NAKAMURA Takumi <geek4civic@gmail.com>
Co-authored-by: Marco Elver <elver@google.com>
Co-authored-by: Greg Clayton <gclayton@fb.com>
Co-authored-by: Charles Zablit <c_zablit@apple.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
Co-authored-by: Michael Spencer <bigcheesegs@gmail.com>
Co-authored-by: Florian Hahn <flo@fhahn.com>
Co-authored-by: Wenju He <wenju.he@intel.com>
Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
Co-authored-by: Luohao Wang <luohaothu@live.com>
Co-authored-by: John Harrison <harjohn@google.com>
Co-authored-by: Ebuka Ezike <yerimyah1@gmail.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
Co-authored-by: Alexey Bataev <a.bataev@outlook.com>
Co-authored-by: Rahul Joshi <rjoshi@nvidia.com>
Co-authored-by: Jessica Clarke <jrtc27@jrtc27.com>
Co-authored-by: puneeth_aditya_5656 <myakampuneeth@gmail.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Joseph Huber <huberjn@outlook.com>
Co-authored-by: Saina Daneshmand <66389676+SainaDaneshmandjahromi@users.noreply.github.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Fangrui Song <i@maskray.me>
Co-authored-by: Tom Stellard <tstellar@redhat.com>
Co-authored-by: Jie Fu <jiefu@tencent.com>
Co-authored-by: Timm Baeder <tbaeder@redhat.com>
Co-authored-by: Pranav Kant <prka@google.com>
Co-authored-by: woruyu <1214539920@qq.com>
Co-authored-by: Pradeep Kumar <pradeepku@nvidia.com>
Co-authored-by: Petr Hosek <phosek@google.com>
Co-authored-by: bala-bhargav <penugondabalabharghav@gmail.com>
Co-authored-by: Jhalak Patel <jhalakp@nvidia.com>
Co-authored-by: Utkarsh Saxena <usx@google.com>
Co-authored-by: Carl Ritson <carl.ritson@amd.com>
Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
Co-authored-by: Jay Foad <jay.foad@amd.com>
Co-authored-by: Sudharsan Veeravalli <svs@qti.qualcomm.com>
Co-authored-by: David Spickett <david.spickett@arm.com>
Co-authored-by: Ricardo Jesus <rjj@nvidia.com>
Co-authored-by: David Sherwood <david.sherwood@arm.com>
Co-authored-by: Oleksandr Tarasiuk <oleksandr.tarasiuk@outlook.com>
Co-authored-by: Yingying Wang <3171290993@qq.com>
Co-authored-by: Sergio Afonso <safonsof@amd.com>
Co-authored-by: Miloš Poletanović <poletanovicmilos97@gmail.com>
Co-authored-by: Milos Poletanovic <mpoletanovic@syrmia.com>
Co-authored-by: Abhishek Varma <avarma094@gmail.com>
Co-authored-by: Henry Linjamäki <henry.linjamaki@tuni.fi>
Co-authored-by: Henry Linjamäki <henry.mikael.linjamaki@intel.com>
Co-authored-by: Leandro Lupori <leandro.lupori@linaro.org>
Co-authored-by: Kerry McLaughlin <kerry.mclaughlin@arm.com>
Co-authored-by: Nikita Popov <npopov@redhat.com>
Co-authored-by: Michael Kruse <llvm-project@meinersbur.de>
Co-authored-by: Konrad Kleine <kkleine@redhat.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
Co-authored-by: Frederik Harwath <frederik.harwath@amd.com>
Co-authored-by: Fateme Hosseini <quic_fhossein@quicinc.com>
Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
Co-authored-by: Michael Buch <michaelbuch12@gmail.com>
Co-authored-by: Minsoo Choo <minsoochoo0122@proton.me>
Co-authored-by: Ryan Cowan <ryan.cowan@arm.com>
Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
Co-authored-by: Akash Banerjee <akash.banerjee@amd.com>
Co-authored-by: Dark Steve <Prasoon.Mishra@amd.com>
Co-authored-by: Aviral Goel <aviralg@users.noreply.github.com>
Co-authored-by: Osman Yasar <37121924+osmanyasar05@users.noreply.github.com>
Co-authored-by: Igor Wodiany <igor.wodiany@imgtec.com>
Co-authored-by: Florian Mayer <fmayer@google.com>
Co-authored-by: AidinT <at.aidin@gmail.com>
Co-authored-by: Justin Fargnoli <jfargnoli@nvidia.com>
Co-authored-by: Christopher Di Bella <cjdb@google.com>
Co-authored-by: Han-Chung Wang <hanhan0912@gmail.com>
Co-authored-by: Wei Xiao <wei3.xiao@intel.com>
Co-authored-by: vangthao95 <vang.thao@amd.com>
Co-authored-by: joaosaffran <joaosaffranllvm@gmail.com>
Co-authored-by: Razvan Lupusoru <razvan.lupusoru@gmail.com>
Co-authored-by: Aman LaChapelle <aman.lachapelle@gmail.com>
Co-authored-by: Jacob Lalonde <jalalonde@fb.com>
Co-authored-by: n2h9 <13541181+n2h9@users.noreply.github.com>
Co-authored-by: Joao Saffran <jderezende@microsoft.com>
Co-authored-by: Joshua Batista <jbatista@microsoft.com>
Co-authored-by: Balázs Benics <benicsbalazs@gmail.com>
Co-authored-by: Priyanshu Kumar <10b.priyanshu@gmail.com>
Co-authored-by: Osman Yasar <osmanyas05@gmail.com>
Co-authored-by: Sarah Kuhn <sarahlinhkuhn@gmail.com>
Co-authored-by: Luisa Cicolini <48860705+luisacicolini@users.noreply.github.com>
Co-authored-by: Osama Abdelkader <osama.abdelkader@gmail.com>
Co-authored-by: Andrew Haberlandt <ahaberlandt@apple.com>
Co-authored-by: Rohan Jacob-Rao <rohanjr@google.com>
Co-authored-by: Eugene Epshteyn <eepshteyn@nvidia.com>
Co-authored-by: Ian Anderson <iana@apple.com>
Co-authored-by: adams381 <adams@nvidia.com>
Co-authored-by: Nick Sarnie <nick.sarnie@intel.com>
Co-authored-by: Sadaf Ebrahimi <sadafebrahimi@google.com>
Co-authored-by: RattataKing <46631728+RattataKing@users.noreply.github.com>
Co-authored-by: Chibuoyim (Wilson) Ogbonna <ogbonnachibuoyim12@gmail.com>
Co-authored-by: Ian Wood <ianwood2024@u.northwestern.edu>
Co-authored-by: Andres-Salamanca <andrealebarbaritos@gmail.com>
Co-authored-by: Jason Molenda <jmolenda@apple.com>
Co-authored-by: A. Jiang <de34@live.cn>
Co-authored-by: Maksim Panchenko <maks@fb.com>
Co-authored-by: Peter Collingbourne <peter@pcc.me.uk>
Co-authored-by: Prabhu Rajasekaran <prabhukr@google.com>
Co-authored-by: Dmitry Sidorov <18708689+MrSidims@users.noreply.github.com>
Co-authored-by: Lang Hames <lhames@gmail.com>
Co-authored-by: Daniil Fukalov <dfukalov@gmail.com>
Co-authored-by: paperchalice <liujunchang97@outlook.com>
Co-authored-by: Viktoria Maximova <viktoria.maksimova@intel.com>
Co-authored-by: wanglei <wanglei@loongson.cn>
Co-authored-by: hev <wangrui@loongson.cn>
Co-authored-by: Zhihui Yang <youngwisdm@gmail.com>
Co-authored-by: Ash <97464181+tnuha@users.noreply.github.com>
Co-authored-by: YunQiang Su <syq@debian.org>
Co-authored-by: Victor Chernyakin <chernyakin.victor.j@outlook.com>
Co-authored-by: Thurston Dang <thurston@google.com>
Co-authored-by: Kewen Meng <Kewen.Meng@amd.com>
Co-authored-by: sohail <150878950+sohail103@users.noreply.github.com>
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Co-authored-by: azwolski <antoni.zwolski@intel.com>
Co-authored-by: Peter Hawkins <phawkins@google.com>
Co-authored-by: David Green <david.green@arm.com>
Co-authored-by: Sander de Smalen <sander.desmalen@arm.com>
Co-authored-by: Riyaz Ahmad <69200125+riyaz86a@users.noreply.github.com>
Co-authored-by: Riyaz Ahmad <riyaz.ahmad@ibm.com>
Co-authored-by: Honey Goyal <honey.goyal3@ibm.com>
2026-02-20 10:35:39 +05:30
Martin Storsjö
1d48322502 [ASan] [Windows] Fix a new test in mingw mode
The new test case added in 781719778003ca298ca57e486ab629b7f384844b
didn't work in mingw mode; defines set through `/D` only works when
using the clang-cl compiler driver, not the regular clang compiler
driver.

Switch this to use `-D`, which works with both plain clang and
clang-cl, so we don't need to use a lit macro for expanding
the right option to use.
2026-02-14 23:29:27 +02:00
Zack Johnson
7817197780
[ASan][Windows] Fix false positive for zero sized rtl allocations (#181015)
This is a follow up to #155943

On Windows, ASan's allocator internally upgrades zero-size allocation
requests to size 1 (since malloc(0) must return a unique non-NULL
pointer). However, when the user queries the allocation size through
Windows heap APIs (RtlSizeHeap, HeapSize, \_msize, GlobalSize,
LocalSize), ASan reports the internal size (1) instead of the originally
requested size (0).

This causes false positive heap-buffer-overflow errors in a common
pattern:

```c++
void *buf = HeapAlloc(GetProcessHeap(), 0, 0);
SIZE_T size = HeapSize(GetProcessHeap(), 0, buf);  // Returns 1, should be 0
if(size > 0) // could remove this and still be correct
    memset(buf, 0, size);  // ASan reports heap-buffer-overflow
```

The change adds a `from_zero_alloc` bit to `ChunkHeader` that tracks
whether an allocation was originally zero-size. This bit fits in the
existing spare capacity of the header's bitfield byte, so the 16-byte
ChunkHeader size is unchanged, but it also isn't the most elegant.

The 1-byte user region of a zero-size allocation is still poisoned, so
any actual access to it is correctly reported as an overflow.
2026-02-13 15:49:27 -05:00
Marina Taylor
cd47ae9f8f
[Profile] Enable binary profile correlation for Mach-O binaries (#179937)
The existing ELF/COFF correlation code mostly "just works" on Mach-O
files, with one gotcha: on disk, the pointers in `__llvm_covdata` are
stored in an encoded format due to dyld fixup chains. (In memory, they
would normally be fixed up at load time in a running binary, but the
correlator only looks at the on-disk values.)

LLVM's Mach-O reader knows how to decode the format, so this patch walks
the fixup table to create a set of mappings that the correlator can use
to resolve the values.

rdar://168259786
2026-02-09 18:31:04 +00:00
Jake Egan
839676bef1
[asan][AIX] Add vec_malloc and vec_calloc interceptors (#175584)
On AIX, when both the `__VEC__` and `_ALL_SOURCE` macros are defined
(they are defined by default), the malloc and calloc system calls are
mapped to vec_malloc and vec_calloc respectively, so we need the
following vec_malloc and vec_calloc interceptors.

Issue: #138916
2026-02-09 13:09:41 -05:00
Peter Collingbourne
fae1cc06e6
ubsan: Add loop detection runtime and e2e tests for -fsanitize-trap-loop.
Reviewers: fmayer, vitalybuka

Reviewed By: vitalybuka, fmayer

Pull Request: https://github.com/llvm/llvm-project/pull/179011
2026-02-06 17:14:14 -08:00
Rainer Orth
5c2b510f88
[ubsan][test] Skip Misc/Posix/static-link.cpp on Solaris (#175464)
The `UBSan-Standalone-x86_64 :: TestCases/Misc/Posix/static-link.cpp`
test currently `FAIL`s on Solaris/x86_64 with
```
ld: fatal: option '-z record' is incompatible with building a static executable
```
One cannot create static executables on Solaris since no `libc.a` is
delivered, so this patch skips the test.

Tested on `x86_64-pc-solaris2.11`.
2026-02-05 20:07:17 -08:00
Jake Egan
f00584dbec
[asan] Disable strict init checking on AIX (#178012)
The `__cxa_atexit` interceptor is disabled for `SANITIZER_AIX` because
Clang on AIX neither uses `__cxa_atexit` nor links against a library
with such. This interceptor calls `StopInitOrderChecking()`, which is
needed to prevent false positives for the `initialization-order-fiasco`
error observed in the asan test `init-order-atexit.cpp` that uses the
`strict_init_order` flag. For now, we'll disable the `strict_init_order`
flag, but we'll look to support it in the future by implementing an
`exit` interceptor or some other alternative. With the flag disabled, we
won't update `init-order-atexit.cpp` to ensure it continues to pass and
the false positive doesn't show up.
2026-02-04 22:39:47 -05:00
Wael Yehia
e1f69ee8e8
[AIX] Implement the ifunc attribute. (#153049)
Currently, the AIX linker and loader do not provide a mechanism to
implement ifuncs similar to GNU_ifunc on ELF Linux.
On AIX, we will lower `__attribute__((ifunc("resolver"))` to the llvm
`ifunc` as other platforms do. The llvm `ifunc` in turn will get lowered
at late stages of the optimization pipeline to an AIX-specific
implementation. No special linkage or relocations are needed when
generating assembly/object output.

On AIX, a function `foo` has two symbols associated with it: a function
descriptor (`foo`) residing in the `.data` section, and an entry point
(`.foo`) residing in the `.text` section. The first field of the
descriptor is the address of the entry point. Typically, the address
field in the descriptor is initialized once: statically, at load time
(?), or at runtime if runtime linking is enabled.

Here we would like to use the address field in the descriptor to
implement the `ifunc` semantics. Specifically, the ifunc function will
become a stub that jumps to the entry point in the address field. A
constructor function is linked into every linkage module. The
constructor walks an array of `{descriptor, resolver}` pairs, calling
the resolver and saving the result in the address field in the
descriptor (thus setting `foo`'s descriptor to point to the resolved
version early during program runtime).

Known limitations:
- Due to bug #161576, which affects object generation path, you will
need either `-ffunction-sections` or `-fno-integrated-as` to generate a
correct/linkable object file.
- aliases to ifuncs are not supported, a testcase has been added and
marked XFAIL. I'm planning to address in a follow-up PR because it's not
important enough, IMHO, for this PR
- dead ifuncs in a CU that contains at least one live ifunc, will result
in all ifuncs being kept by the linker. The fix for this is common with
a similar problem we have with PGO. PR #159435 is trying to provide a
mechanism that will allow the ifunc and PGO implementations to avoid the
dead code retention at the link step.
- the resolver must return a function that is in the same DSO as the
ifunc; the compiler will try to detect if this condition is violated and
report it, but it cannot detect it in general. To be safe, all candidate
functions (returned by a particular resolver) must either be static or
have hidden/protected visibility. This is so that the ifunc stub doesn't
have to save and restore the TOC register r2. In future work, this case
will be supported and the requirement will be lifted.

---------

Co-authored-by: Wael Yehia <wyehia@ca.ibm.com>
2026-02-03 14:15:16 -05:00
Simi Pallipurath
39413af931
[Compiler-rt] Implement AEABI Unaligned Read/Write Helpers in compiler-rt (#167913)
This patch adds implementations for the __aeabi_uread and __aeabi_uwrite
helper functions to compiler-rt.

Without these helpers, LLVM would need to inline byte wise sequences ,
which can increases code size, especially at -Os/-Oz. Using the helper
functions allows to retain correctness while avoiding the code-size
growth.

GCC-based toolchains already provide these AEABI helpers, so supporting
them in compiler-rt ensures parity and avoids accidental dependencies on
libgcc when LLVM begins emitting these calls.
2026-02-02 16:32:46 +00:00
Yaxing Cai
1b37911f1a
[ORC] Fix missing support of deinitialize on ELF platform and execution order by priority (#175981)
This PR fixes
1. issue #175509 about missing support of deinitialize on ELF platform. 
2. missing support of execution order by proirity at both initialize and
deinitialize stage.

cc: @tqchen @joker-eph
2026-01-22 17:31:28 +11:00
Alison Zhang
90895531cc
Update sanitizer_coverage_allowlist_ignorelist.cpp to use POSIX-compliant regex (#176396)
As `\+` is a GNU extension, it is not supported by the system grep on
AIX. This change replaces `%[0-9]\+` with `%[0-9][0-9]*`, which is
POSIX-compliant and therefore compatible with AIX.
2026-01-20 10:58:25 -05:00
anoopkg6
fb953283af
[dfsan] Add dataflow sanitizer support for SystemZ (#168991)
Add SystemZ specific changes for dataflow sanitizer on top of following
two common code changes
i) Fix Endianness issue
[#162881](https://github.com/llvm/llvm-project/pull/162881)
ii) Fix ShadowAddress computation
[#162864](https://github.com/llvm/llvm-project/pull/162864[](url))

See conversation in original
pr#[#162195](https://github.com/llvm/llvm-project/pull/162195)
2026-01-19 15:28:34 +01:00
Andrew Haberlandt
12ecbfb59b
[Darwin] [compiler-rt] Normalize DYLD_LIBRARY_PATH to workaround LD bug (#175685)
There is an issue in certain versions of LD which causes the wrong
libLTO to be used if the DYLD_LIBRARY_PATH is not normalized.

Will fix these failures:
```
AddressSanitizer-x86_64-darwin.TestCases/Darwin.odr-lto.cpp
AddressSanitizer-x86_64h-darwin.TestCases/Darwin.odr-lto.cpp
```

https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-cmake-RA-incremental/13428/

rdar://168024431
2026-01-13 00:44:41 +00:00
Thurston Dang
71293e4495
[lsan] Fix flaky test in swapcontext.cpp (#175635)
LSan, by design, can have false negatives, making it unreliable to check
that the leak was found in the stack-allocated case:
```
==123685==Scanning STACK range 0x7ffe6e554ca0-0x7ffe6e557000.
==123685==0x7ffe6e554de0: found 0x51e0000009f0 pointing into chunk 0x51e000000000-0x51e000000c00 of size 3072.
==123685==0x7ffe6e554e30: found 0x51e000000c00 pointing into chunk 0x51e000000c00-0x51e000001668 of size 2664. <- this prevented the leak from being found
```

This has led to flakiness on the buildbots e.g.,
https://lab.llvm.org/buildbot/#/builders/66/builds/24669
```
# | /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lsan/TestCases/swapcontext.cpp:44:11: error: CHECK: expected string not found in input
# | // CHECK: SUMMARY: {{.*}}Sanitizer: 2664 byte(s) leaked in 1 allocation(s)
...
Failed Tests (2):
  LeakSanitizer-HWAddressSanitizer-x86_64 :: TestCases/swapcontext.cpp
  LeakSanitizer-Standalone-x86_64 :: TestCases/swapcontext.cpp
```

This patch fixes the issue by clearing the buffer, as suggested by
Vitaly.
2026-01-12 13:56:18 -08:00
Sean Fertile
781677eca0
[PPC] Disable some ORC-powerpc64le-linux tests. (#175100)
Tests fail to link when using LLVM C++ library. Disabling the tests
until they can be investigated and the underlying cause identified and
fixed.
2026-01-09 07:00:17 -05:00
Andrew Haberlandt
65945ec2cc
[compiler-rt] [Darwin] Add darwin-remote feature for remote darwin test targets (#174905)
Some tests are already supported on "remote" devices and simulators.
However, there is currently no way to distinguish a remote macOS host
from a local one.

This adds the darwin-remote feature which is common to all test targets
which use a wrapper script (e.g. iossim_run.py).

rdar://167735355

---------

Co-authored-by: Dan Blackwell <danblackwell95@gmail.com>
2026-01-08 10:03:30 -08:00
Andrew Haberlandt
0aea22f13e
[compiler-rt] Support default-True lit config options (follow up to #174522) (#174642)
The option added in #174522 breaks simulator tests, since `set_default`
overrides `False` values with the default.

Since these options are either string or boolean, this patches
set_default to override only un-set or empty string values (empty string
is not truth-y and therefore would be overwritten by defaults currently,
so this is NFCI)
2026-01-06 12:47:56 -08:00
Andrew Haberlandt
305c413c92
[NFCI] [Darwin] Add APPLE_TARGET_IS_HOST lit option to compiler-rt (#174522)
Darwin supports running tests on targets other than the host machine
e.g. simulators. In such configurations, tests are run via a wrapper
script (e.g. iossim_run.py).

This refactors the lit test config to use a dedicated option to
distinguish test suites that run on the host from those that run in any
other configuration. This will allow the test suites to distinguish a
local osx configuration from a "remote" one.

rdar://167591463
2026-01-06 09:10:16 -08:00
Andrew Haberlandt
e9ba0e6bf0
[compiler-rt] Fix check-builtins buildbot failures (#174443)
After #171941, there are two issues:

First, some buildbots that use the old-style build are failing at:

```
Target ${BUILTIN_LIB_TARGET_NAME} does not exist"
```

Example failure:
https://lab.llvm.org/buildbot/#/builders/139/builds/25097

...during CMake configure. This appears to be caused by mismatch between
the builtin library's _target_ name and the output name from
set_output_name. This reverts the change to BUILTIN_LIB_TARGET_NAME made
by #171941, but still use the output name for naming the .sources.txt
file used for configuring builtins tests.

Second, this speculatively fixes an issue caused by two builtins
libraries that are produced with the same name in different directories
because of `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` (e.g.
`lib/clang/22/lib/i386-unknown-linux-gnu/libclang_rt.builtins.a` and
`lib/clang/22/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a`), and
thus the `.sources.txt` paths alias. This causes us to run the wrong
tests against one of the builtins libraries. The chosen fix is to store
the .sources.txt files in `get_compiler_rt_output_dir` (which takes
`LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` into account) rather than
`CMAKE_BINARY_DIR`.

As a side-effect, this allows for the replacement of
`COMPILER_RT_TEST_BUILTINS_DIR` with a simpler boolean option
`COMPILER_RT_TEST_EXTERNAL_BUILTINS`.

Example failure:
https://lab.llvm.org/buildbot/#/builders/66/builds/24433
2026-01-05 14:59:53 -08:00
Zequan Wu
2f06623953
[compiler-rt] fix crt target dependency. (#174475)
This fixes cmake error from
https://github.com/llvm/llvm-project/pull/171941 in chrome's llvm build
where we have `COMPILER_RT_BUILD_BUILTINS=OFF` and have
`COMPILER_RT_TEST_BUILTINS_DIR` set. That change makes it to depend on
`crt` even if we don't have it in the prebuilt dir.

Log:
```
 CMake Error at CMakeLists.txt:349 (add_dependencies):
  The dependency target "crt" of target "runtimes-test-depends" does not
  exist.


CMake Error at /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/cmake/modules/AddLLVM.cmake:2104 (add_dependencies):
  The dependency target "crt" of target "check-runtimes" does not exist.
Call Stack (most recent call first):
  /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/cmake/modules/AddLLVM.cmake:2145 (add_lit_target)
  CMakeLists.txt:353 (umbrella_lit_testsuite_end)


CMake Error at /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/CMakeLists.txt:127 (add_dependencies):
  The dependency target "crt" of target "compiler-rt-test-depends" does not
  exist.


CMake Error at /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/cmake/modules/AddLLVM.cmake:2104 (add_dependencies):
  The dependency target "crt" of target "check-compiler-rt" does not exist.
Call Stack (most recent call first):
  /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/cmake/modules/AddLLVM.cmake:2145 (add_lit_target)
  /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/CMakeLists.txt:129 (umbrella_lit_testsuite_end)


CMake Error at /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/cmake/modules/AddLLVM.cmake:2104 (add_dependencies):
  The dependency target "crt" of target "check-builtins" does not exist.
Call Stack (most recent call first):
  /b/s/w/ir/cache/builder/src/third_party/llvm/llvm/cmake/modules/AddLLVM.cmake:2171 (add_lit_target)
  /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/builtins/CMakeLists.txt:137 (add_lit_testsuite)
```
2026-01-05 14:47:46 -08:00
Andrew Haberlandt
d1aca4b147
Reland check-builtins target for LLVM_ENABLE_RUNTIMES (#171941)
Reland https://github.com/llvm/llvm-project/pull/166837 and
https://github.com/llvm/llvm-project/pull/171741

(Reverts the revert in #171940)

---------

Co-authored-by: Petr Hosek <phosek@google.com>
2026-01-05 08:01:56 -08:00
Wael Yehia
4cba804249 [unrelated][upstream-separately] XFAIL multc3_test.c fixunstfdi_test.c on AIX 64-bit 2026-01-05 16:04:21 +00:00
Aiden Grossman
9553f119b0
[lit] Drop shell feature from all upstream projects (#173341)
Now that no tests actually use the shell feature to conditionally run,
drop the feature altogether to prevent backslide.
2025-12-31 11:06:36 -08:00
Aiden Grossman
ed9bc1ccd4 [Fuzzer] Mark test as unsupported on Windows
bf932867acc003f4dd5bf4d8b295f764a3a85c91 enabled this test to run on
Windows again, but it started failing due to the use of ulimit.
Redisable it on Windows.

https://lab.llvm.org/buildbot/#/builders/107/builds/16280
2025-12-23 21:21:55 +00:00