19217 Commits

Author SHA1 Message Date
Piyou Chen
4806a5572e [RISCV][compiler-rt] drop __riscv_vendor_feature_bits (#126460)
Address https://github.com/riscv-non-isa/riscv-c-api-doc/pull/101

(cherry picked from commit 2cd8207b26ea4269630feba661f68554d7ae3c15)
2025-02-11 20:57:24 -08:00
Lang Hames
a9b4976064 [ORC-RT] Use templates to express deeply nested function calls in testcase.
Makes this test smaller and more readable.

(cherry picked from commit e00f824e9a5ea73830bd346115968fa9ace84cbf)
2025-02-08 16:19:54 +00:00
Lang Hames
0c23bde717 [ORC] Fix buggy calculation of second-level-page offset in unwind-info.
SecondLevelPageOffset should be incremented by SecondLevelPageSize bytes, not
one byte.

Failure to calculate the offset correctly leads to corrupted unwind-info (and
consequently broken exceptions / unwinding) when more than one second level
page is needed. Since JITLink's unwind support only produces
UNWIND_SECOND_LEVEL_REGULAR-style pages this would trigger for any file
containing more than 511 functions with unwind info. The included test-case
contains 1022 functions (sufficient for both the current format and any
future implementation that supports UNWIND_SECOND_LEVEL_COMPRESSED pages).

Thanks to @edoardo on discord for spotting this bug!

(cherry picked from commit 88f55d16c4c247a9eef326961a1445dee3f2e30c)
2025-02-08 16:19:53 +00:00
Lang Hames
7782b8310d [ORC-RT] Add a comment explaining the purpose of this testcase. NFC.
(cherry picked from commit aefa30e2301f155d4f4737d6f6c55c66eac58b2d)
2025-02-08 16:19:53 +00:00
Lang Hames
50c4c2bf68 Re-reapply "[ORC] Enable JIT support for the compact-unwind..." with fixes.
Re-enables compact-unwind support in JITLink, which was reverted in b04847b427d
due to buildbot failures.

The underlying cause for the failures on the buildbots was the lack of
compact-unwind registration support on older Darwin OSes. Since the
CompactUnwindManager pass now removes eh-frames by default we were left with
unwind-info that could not be registered. On x86-64, where eh-frame info is
produced by default the solution is to fall back to using eh-frames. On arm64
we simply can't support exceptions on older OSes.

This patch updates the EHFrameRegistrationPlugin to remove the compact-unwind
section (__LD,__compact_unwind) when installed, forcing use of eh-frames when
the EHFrameRegistrationPlugin is used. In LLJIT, the EHFrameRegistrationPlugin
continues to be used for all non-Darwin platform, and will be added on Darwin
platforms when the a CompactUnwindRegistrationPlugin instance can't be created
(e.g. due to missing support for compact-unwind info registration).

The lit.cfg.py script is updated to check whether the host OSes default unwind
info supports JIT registration, allowing tests to be disabled for older Darwin
OSes on arm64.

(cherry picked from commit eae6d6d18bd4d9e7dfe5fc1206d23d8ef663c8c7)
2025-02-08 16:19:52 +00:00
Ben Langmuir
2b09e5936a [asan][test] Disable suppressions-alloc-dealloc-mismatch.cpp on Darwin
The suppressions mechanism doesn't work reliably in optimized builds,
which turns out to be a known issue (see b87543c704724 / svn r308908).
Disable this test, as it is also testing a feature (alloc/dealloc
mismatch) that is disabled by default on Darwin anyway.

rdar://143830493
(cherry picked from commit 4985804c0608a83f6ab017137c3d3d4f02827774)
2025-02-05 13:35:58 -08:00
Vitaly Buka
2d1f7e0082 [asan][android] XFAIL suppressions-alloc-dealloc-mismatch
Android is missing suppression file on device.

Follow up to #124197.

(cherry picked from commit 751ae26b959c931efb6db84a27bf2a0444120094)
2025-02-05 13:35:58 -08:00
Ben Langmuir
5a406bde97 [asan][test] Attempt to fix suppressions-alloc-dealloc-mismatch.cpp on Darwin (#124987)
Add %env_asan_opts=alloc_dealloc_mismatch=1 since it is disabled by
default.

rdar://143830493
(cherry picked from commit f0d05b099dafda89df4c971b64b2051c33db5da1)
2025-02-05 13:35:58 -08:00
andrewjcg
6b654a09c2
[sanitizer] Support "alloc_dealloc_mismatch" suppressions (#124197)
This adds a stack-based suppression for alloc-dealloc-mismatch
violations, using the function name to match.
2025-01-28 18:04:12 -08:00
Julian Lettner
a34159f85e
[TSan][Apple] Fix interceptor build error (#124351)
In certain cases, the SDK headers declare
`OSSpinLock*` APIs as macros (instead of
functions), so users can be transparently
forwarded to non-deprecated APIs.

When enabled, building of TSan interceptors failed
because these macros interfere with the
interceptor machinery, i.e., they prevent proper
forward declaration of intercepted APIs.

In a previous change [1], we misattributed this to
the deprecation of `OSSpinLock*` APIs.

[1] ae484c21c05668f84b13304c28bc39f753e493de

rdar://143193907
2025-01-27 15:48:29 -08:00
Jens Reidel
b707d52fc5
[compiler-rt][Mips] Properly guard references to _ABIN32 (#124492)
When targeting ABIO32 (mips32), _ABIN32 is undefined and the
preprocessor directives cause compile errors. Guard references to
_ABIN32 with defined(_ABIN32), just like the references to _ABIO32.

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-01-27 13:49:44 -08:00
Meng Zhuo
4e81275674
[tsan] Add support for linux/riscv64 in lib/tsan/go/buildgo.sh (#124557) 2025-01-27 10:39:40 -08:00
David CARLIER
e21b80464a
[compiler-rt][rtsan] socketpair interception. (#124107) 2025-01-27 12:52:35 +00:00
David CARLIER
cfdd7d736a
[compiler-rt][rtsan] sched cpu affinity for linux interception. (#124194) 2025-01-27 12:50:10 +00:00
bernhardu
bbf377060a
[win/asan] GetInstructionSize: Support some more 7 or 8 byte instructions. (#124011)
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

```
Related: https://github.com/llvm/llvm-project/issues/96270

Co-authored-by: Roman Pišl <rpisl@seznam.cz>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <eric.pouech@gmail.com>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
```
2025-01-27 10:50:54 +01:00
bernhardu
351ee30529
[win/asan] GetInstructionSize: Support some more 6 byte instructions. (#124006)
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

```
Related: https://github.com/llvm/llvm-project/issues/96270

Co-authored-by: Roman Pišl <rpisl@seznam.cz>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <eric.pouech@gmail.com>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
```
2025-01-27 10:49:07 +01:00
Ellis Hoag
12f82fbe07
[compiler-rt] Fix Windows test after profile summary change (#124318)
Fix a Windows compiler-rt test that
https://github.com/llvm/llvm-project/pull/105915 broke.
2025-01-24 10:01:02 -08:00
Alexandros Lamprineas
474f5d2aef
[FMV][AArch64] Remove features predres and ls64. (#124266)
These cannot be detected by reading the ID_AA64ISAR1_EL1 register since
their corresponding bitfields are hidden. Additionally the instructions
that these features enable are unusable from EL0.

ACLE: https://github.com/ARM-software/acle/pull/382
2025-01-24 17:22:27 +00:00
gbMattN
1c0af8dced
[TySan] Added tests for methods of ignoring instrumentation (#124125)
TySan supports some preprocessor checks and ignorelists, but they are
currently untested. This PR adds some tests to make sure they all work.

@fhahn @AaronBallman, this is based off the discussion in the
documentation PR [#123595]
2025-01-24 09:33:37 +00:00
Lang Hames
212cdc9a37 Revert "[ORC] Enable JIT support for the compact-unwind frame info format..."
This reverts 4f0325873faccfbe171bae4babceb65975ca892e and follow-up patches
(see below) while I investigate some ongoing failures on the buildbots.

---

Revert "[clang-repl] Try to XFAIL testcase on arm32 without affecting arm64
darwin."

This reverts commit fd174f0ff3e793fe96a6663b1488ed159cfe042f.

Revert "[clang-repl] The simple-exception test now passes on arm64-darwin."

This reverts commit c9bc242e387f4a4a3dfcd86561f3ec0ca8a72d62.

Revert "[ORC] Destroy defunct MaterializationUnits outside the session lock."

This reverts commit a001cc0e6cdcfa672b8aff9ce6d14782bb96356a.

Revert "[ORC] Add explicit narrowing casts to fix build errors."

This reverts commit 26fc07d5d88760ad659599184fd10181287d2d9e.

Revert "[ORC] Enable JIT support for the compact-unwind frame info format on
Darwin."

This reverts commit 4f0325873faccfbe171bae4babceb65975ca892e.
2025-01-24 17:32:12 +11:00
David CARLIER
f3d2e75ead
[compiler-rt][rtsan] inotify api for Linux interception. (#124177) 2025-01-24 05:07:49 +00:00
David CARLIER
02a3004992
[compiler-rt][rtsan] preadv(64)/pwritev(64) interception. (#124115) 2025-01-24 05:07:33 +00:00
Lang Hames
4f0325873f [ORC] Enable JIT support for the compact-unwind frame info format on Darwin.
For Darwin/arm64 (including Apple Silicon Macs) this will enable exception
handling and stack unwinding in JIT'd code.

Darwin supports two unwind-info formats: DWARF eh-frames and compact-unwind. On
Darwin/x86-64 compilers usually produce both by default, and ORC supported
exceptions and unwinding via eh-frames (same as on Linux), discarding the
redundant compact-unwind info. On Darwin/arm64 compilers typically default to
producing compact-unwind only, with DWARF eh-frames as a fallback for functions
that can't be described in compact-unwind. Since ORC did not previously support
the compact-unwind format and eh-frames were not present ORC was unable to
handle exceptions or unwinding by default in Darwin/arm64 JIT'd code.

This patch enables support for the compact-unwind-info format, and contains
three major moving parts:

(1) The JITLink CompactUnwindManager class is responsible for transforming the
    __compact_unwind records produced by the linker into the __unwind_info
    tables that libunwind parses during unwinding. To enable this the
    CompactUnwindManager class provides three JITLink passes: The
    prepareForPrune pass that splits the __compact_unwind section into
    single-record blocks, allowing unused records to be dead-stripped; the
    processAndReserveUnwindInfo pass that reserves space for the final
    __unwind_info section, and the writeUnwindInfo pass that writes the
    __unwind_info section.

(2) The OrcTargetProcess UnwindInfoManager class maintains a table of
    registered JIT'd __unwind_info and __eh_frame sections, and handles
    requests from libunwind for unwind info sections (by registering a callback
    with libunwind's __unw_add_find_dynamic_unwind_sections function).

(3) The Orc UnwindInfoRegistrationPlugin, which scans LinkGraphs for
    __unwind_info and __eh_frame sections to register with the
    UnwindInfoManager.

This commit adds the CompactUnwindManager passes to the default JITLink
pipelines for Darwin/arm64 and Darwin/x86-64, and UnwindInfoManager intances to
the SelfExecutorProcessControl class (when built for apple platforms) and the
llvm-jitlink-executor tool.

The LLJIT class will now create an UnwindInfoRegistrationPlugin when targeting
a process running on Darwin if it detects that an UnwindInfoManager is
available to handle the registrations.

The ORC runtime macho_platform class already supported libunwind callbacks, so
out-of-process execution and unwinding support will work when loading the ORC
runtime.

The llvm-jitlink tool will only support compact-unwind when the orc-runtime is
loaded, as the UnwindInfoRegistrationPlugin requires access to an IR compiler
to load a helper module and llvm-jitlink does not provide an IR compiler.
2025-01-23 22:55:01 +00:00
thetruestblue
0b7cbd23a0
[Darwin][Sanitizers][CrashReporter] Adopt initializer for Crash Reporter Annotations struct (#123978)
An initializer for the Crash Reporter Annotatoins struct was added in
version 5. For the simplicity of not needing to always update the struct
in subsequent versions, this patchs checks for the initializer before
attempting to redefine the struct on its own.

Note -- we have an existing test for this that is disabled by default,
it is inherently flakey due to the nature of crash reporter. But we can
run that when making crash reporter related changes.

rdar://136156203
2025-01-23 12:48:33 -08:00
Brad Smith
e0cd57decb
[compiler-rt] Remove support and workarounds for Android 4 and older (#124056) 2025-01-23 13:00:39 -05:00
Ellis Hoag
a2453097e3
[llvm-profdata] Add block percent to detailed summary (#105915) 2025-01-23 09:30:23 -08:00
Paweł Bylica
091741a880
[libfuzzer] Clarify -max_len behavior on bigger files (#123095) 2025-01-23 09:19:21 +01:00
David CARLIER
939f2900d0
[compiler-rt][rtsan] getsockopt/setsockopt interception. (#124004) 2025-01-22 23:23:32 +00:00
David CARLIER
630177ccdd
[compiler-rt][rtsan] Fix madvise/posix_madvise for macOs. (#124020)
only bsd and linux intercept these syscalls.
Fix #123601
2025-01-22 23:03:48 +00:00
Victor Campos
ffde2687be
[compiler-rt] Make Arm builtins aware of endianness in VMOVs (#123204)
This patch makes Arm builtins aware of endianness in VMOVs.

Before this patch, the functions' definitions assumed little endian,
which made any program compiled for big endian incorrect.
2025-01-22 10:56:48 +00:00
David CARLIER
c745ece254
[compiler-rt][rtsan] page regions api interception update. (#123601)
madvise/mprotect/msync/mincore calls with care for signature difference
for the latter.
2025-01-22 10:40:04 +00:00
David CARLIER
6123a81b47
[compiler-rt][rtsan] Fix process_vm_readv/process_vm_writev signatures. (#123914)
missing pid_t first argument. Fix #123839
2025-01-22 19:05:58 +09:00
bernhardu
56592a8108
[win/asan] GetInstructionSize: Support some more 4 byte instructions. (#123709)
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

```
Related: https://github.com/llvm/llvm-project/issues/96270

Co-authored-by: Roman Pišl <rpisl@seznam.cz>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <eric.pouech@gmail.com>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
```
2025-01-22 10:27:05 +01:00
bernhardu
5f40570714
[win/asan] GetInstructionSize: Support some more 5 byte instructions. (#123844)
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.
```
Related: https://github.com/llvm/llvm-project/issues/96270

Co-authored-by: Roman Pišl <rpisl@seznam.cz>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <eric.pouech@gmail.com>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
```
2025-01-22 10:22:02 +01:00
Yi Kong
2ee36d40f0
[compiler-rt][rtsan] Fix sendmmsg and recvmmsg rtsan interceptor for MUSL (#123907)
MUSL have different signatures for sendmmsg and recvmmsg.

This fixes build breakage from #123484.
2025-01-22 18:18:18 +09:00
David CARLIER
8fad58a648
[compiler-rt][rtsan] process_vm_readv/process_vm_writev interception. (#123839) 2025-01-22 06:23:39 +00:00
David CARLIER
a31e25396e
[compiler-rt][rtsan] Fix recvmmsg rtsan interceptor for glibc < 2.21 (#123664)
linux/glibc prior to 2.21 had a different signature for recvmmsg.

Fix llvm#123484
2025-01-21 18:54:48 +00:00
Kyle Evans
a79098bc72
[compiler-rt] Destroy pthread attrs after use in tests (#114923)
The attr typically located on the stack is of an opaque pthread_attr_t
type, which may be a pointer that gets initialized by
pthread_attr_init(). Explicitly clean up the attr with
pthread_attr_destroy() to avoid a leak on such platforms to avoid
unexpected test failures with lsan enabled.

This primarily affects FreeBSD; NetBSD, musl, and glibc will seemingly
all use a full-sized pthread_attr_t.
2025-01-21 16:28:33 +00:00
Ami-zhang
79231a8684
[ORC-RT][LoongArch] Add initial support for loongarch64 in ELFNixPlatform (#123575)
Enable ELFNixPlatform support for loongarch64. These are few simple
changes, but it allows us to use the orc runtime in ELF/LoongArch64
backend.

This change adds test cases targeting the LoongArch64 Linux platform to
the ORC runtime integration test suite. Since jitlink for loongarch64 is
ready for general use, and ELF-based platforms support defining multiple
static initializer table sections with differing priorities, some
relevant test cases in compiler-rt for ELFNixPlatform support can be
enabled.
2025-01-21 14:25:03 +08:00
bernhardu
57466db7a4
[win/asan] GetInstructionSize: Support some more 3 byte instructions. (#120474)
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

```
Related: https://github.com/llvm/llvm-project/issues/96270

Co-authored-by: Roman Pišl <rpisl@seznam.cz>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <eric.pouech@gmail.com>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
```
2025-01-20 14:25:52 +01:00
David CARLIER
18d5d84d76
[compiler-rt][rtsan] intercept getpeername/recvmmsg/sendmmsg (#123484) 2025-01-20 08:11:33 +00:00
David CARLIER
02909a4046
[compiler-rt] rtsan pipe2 interception for Linux. (#123517)
completing fpurge interception for mac too.
2025-01-20 07:55:40 +00:00
David CARLIER
4aedb97009
[compiler-rt][rtsan] getsockname interception. (#123409) 2025-01-18 07:53:45 +00:00
Alexander Richardson
bbac349341
[compiler-rt] Install libc++ and libc++abi in build_symbolizer.sh (#123104)
This ensures that the directory layout of the libc++/libc++abi matches
exactly what we would get on a real installation. Currently the build
directory happens to match the install directory layout, but this will
no longer be true in the future.
2025-01-15 15:13:06 -08:00
David CARLIER
d15d410a35
[compiler-rt][rtsan] Fix fseek test build (unused variable warning). (#123116) 2025-01-15 20:33:18 +00:00
Wael Yehia
6ffc445103 [PGO][AIX] Disable multi-process continuous mode test in 32-bit
In PGO continuous mode, we mmap the profile file into shared memory, which
allows multiple processes to be updating the same memory.

The -fprofile-update=atomic option forces the counter increments to be atomic,
but the counter size is always 64-bit (in -m32 and -m64), so in 32-bit mode the
atomic operations are function calls to libatomic.a and these function calls use
locks.

The lock based libatomic.a functions are per-process, so two processes will race
on the same shared memory because each will acquire their own lock.
2025-01-15 19:21:14 +00:00
David CARLIER
c4443a1be4
[compiler-rt][rtsan] fseek api interception. (#122163) 2025-01-15 18:31:27 +00:00
David CARLIER
da4551aad0
[compiler-rt][sanitizer_common] Fix for solaris and *BSD platforms proposal. (#122956)
To fix llvm#122795 build failures for these.
2025-01-15 13:31:14 +00:00
Lang Hames
2a5281d0e0 [ORC-RT] Fix missing '\' line continuations in objc-imageinfo.S test.
These missing continuations were causing commands in this testcase to fail.
2025-01-15 13:21:28 +11:00
Paul Kirth
44d9beef7d
[rtsan][test] Prevent test check from being optimized out in LTO builds (#122524)
In LTO builds, some test checks can be optimized away, since the
compiler can
see through the memory accesses after inlining across TUs. This causes
the existing death tests to fail, since the functions are completely
optimized out and things like copying a lambda will no longer occur and
trigger the sanitizer.

To prevent that, we can use an empty inline assembly block to tell the
compiler that memory is modified, and prevent it from doing that.
2025-01-14 11:55:19 -08:00