19277 Commits

Author SHA1 Message Date
Lang Hames
2c8b2dc3f4 [ORC-RT] Rename 'orc_rt_*CWrapper*' types and functions to 'orc_rt_*Wrapper*'.
The orc_rt_ prefix implies C API anyway (the C++ API should use the orc_rc::
namespace), so the 'C' is redundant here.
2025-03-07 14:31:42 +11:00
Lang Hames
a22881c9db [ORC-RT] Fix type name in comment. NFC. 2025-03-06 16:13:10 +11:00
Mircea Trofin
5223ddd83f
[ctxprof] Prepare profile format for flat profiles (#129626)
The profile format has now a separate section called "Contexts" - there will be a corresponding one for flat profiles. The root has a separate tag because, in addition to not having a callsite ID as all the other context nodes have under it, it will have additional fields in subsequent patches.

The rest of this patch amounts to a bit of refactorings in the reader/writer (for better reuse later) and tests fixups.
2025-03-05 07:22:35 -08:00
Mircea Trofin
1b46db7776
[ctxprof] ProfileWriter abstraction (#129590)
Introduce a `ProfileWriter` abstraction to replace the callback passed to `__llvm_ctx_profile_fetch`. Subsequent changes will add support for flat profile collection (as in, collection of non-contextual profile for those functions not under a contextual root), which require also a change in the profile format. The abstraction makes it easy to add "write flat" - related capabilities without constantly complicating the signature of `__llvm_ctx_profile_fetch`.
2025-03-04 12:41:16 -08:00
Alexander Shaposhnikov
a32d5438ac Revert "[compiler-rt][ubsan] Add support for f16 (#129624)"
This reverts commit 23a30e68888e764b2f4d32e51d415b50fa5f5cac.
The commit has broken some build bots.
2025-03-04 09:04:46 +00:00
Alexander Shaposhnikov
23a30e6888
[compiler-rt][ubsan] Add support for f16 (#129624)
LLVM supports long double <-> f16 conversions so we can remove the old FIXME.
2025-03-04 00:38:14 -08:00
Alexander Shaposhnikov
2127af80fa
[compiler-rt][ubsa] Reformat cast-overflow test. NFC (#129662)
Reformat cast-overflow test. NFC
2025-03-03 23:56:21 -08:00
Alexander Shaposhnikov
39402cde61
[compiler-rt][ubsan] Refactor cast-overflow test (#129460)
This PR cleans up cast-overflow.cpp, more specifically:
1. avoid using undefined value as an exit code (old case `9`)
2. narrowing conversions are allowed to produce `inf` and they are
well-defined. Remove dead code (old case `8`)
3. the same applies to the conversion int -> float16. Remove dead code
(old case `7`)

See also
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#:~:text=%2Dfsanitize%3Dfloat%2Dcast,to%20integer%20types.

Currently ubsan doesn't properly detect UB on float16 -> int casts, I
have a fix for that (will send as a separate PR).
2025-03-03 12:32:58 -08:00
pirama-arumuga-nainar
5cf9435fd4
[compiler-rt][rtsan] Do not intercept [f]truncate64 for musl (#129331)
Musl has 64-bit off_t by default and has macros that redefine
[f]truncate64 to [f]truncate.
2025-02-28 15:08:06 -08:00
PiJoules
fcc571eeb1
[asan] Define mallopt and mallinfo for Fuchsia asan runtime (#129105) 2025-02-28 11:14:39 -08:00
Meng Zhuo
76910f914c
[tsan][RISCV] Add Go support for linux/riscv64 (#127295)
This is needed to support race detector in Golang.

See also: https://github.com/golang/go/issues/64345
2025-02-28 18:27:48 +08:00
GkvJwa
1594fa8e5a
[asan][win] Fix CreateThread leak (#126738)
Fix #126541

Since ```t->Destroy``` cannot be called after ```start_routine```(When
calling standard thread_start in crt)

Intercept `ExitThread` and free the memory created by `VirtualAlloc'
2025-02-28 09:38:08 +08:00
David CARLIER
9a54c77aa3
Reland copy file range san (#129114) 2025-02-27 12:58:51 -08:00
Daniel Thornburgh
e5d93100b6 Revert "[compiler-rt][sanitizer_common] copy_file_range syscall interception. (#125816)" and fix
This reverts commit 7521207e415b19b2924930ac95c2fcf07d56f2f2.
This reverts commit 5f6a3e63a31aaebc620a18c47bc5590f6f705c98.
2025-02-27 12:12:51 -08:00
David CARLIER
7521207e41
[compiler-rt][sanitizer_common] fix copy_file_range test. (#129010)
Passing Large File Support.

Address #125816
2025-02-27 07:12:26 +00:00
David CARLIER
5f6a3e63a3
[compiler-rt][sanitizer_common] copy_file_range syscall interception. (#125816) 2025-02-27 05:33:38 +00:00
David CARLIER
f3b4d94f35
[compiler-rt][rtsan] truncate/ftruncate interception. (#128904) 2025-02-26 22:57:29 +00:00
Chris Apple
58035b5ef5
Revert "[compiler-rt][rtsan] stat api interception." (#128465)
Reverts llvm/llvm-project#128430

Reverting this as I could repro the failure here:

> Hi @devnexen I believe this change is causing failures on a bot. Any
idea what might be causing the problems?
> https://lab.llvm.org/staging/#/builders/202/builds/1324

https://github.com/llvm/llvm-project/pull/128430#issuecomment-2677298624
2025-02-24 14:21:52 +09:00
Vitaly Buka
8b1d38480b
[sanitizer] Support "bB" printf GLIBC extension (#128449)
https://www.gnu.org/software/libc/manual/html_node/Table-of-Output-Conversions.html

Without the patch llc triggers non-fatal Asan warning.
2025-02-23 18:46:52 -08:00
Vitaly Buka
8c917f3ccd
[NFC][sanitizer] Add test for length sub-specifier "z" (#128448) 2025-02-23 18:30:40 -08:00
David CARLIER
4d928d5b58
[compiler-rt][rtsan] stat api interception. (#128430) 2025-02-23 23:37:18 +00:00
David CARLIER
a8fb2d0c1c
[compiler-rt][rtsan] adding unlink/unlinkat interception. (#128292) 2025-02-23 09:17:48 +00:00
Cullen Rhodes
6d5ba79c66
[compiler-rt][asan] Re-enable ManyThreadsTest on AArch64 (#127795)
Disabled in 2ab51bf13a1f6ca96823b755c036227dfd0892f9, doesn't hang for
me on AArch64 (Graviton 3, tested 1000 iterations). May still be an
issue, but hard to know unless we enable it again to find out.

n.b. test was also disabled on PowerPC in
467afc5f847f72221a42d9142c5b4733b44b52dc for same reason and it has also
been observed on x86:
https://lists.llvm.org/pipermail/llvm-dev/2016-January/094607.html

Fixes: https://github.com/llvm/llvm-project/issues/24763
2025-02-21 09:45:58 +00:00
l0rinc
aad74dc971
[compiler-rt] FuzzedDataProvider: modernize outdated trait patterns (#127811) 2025-02-21 10:17:26 +01:00
Lang Hames
6c90f87b74 [ORC-RT] Add -num-threads=0 to testcase.
This testcase depends on stable output, which isn't guaranteed when
concurrent linking is enabled (the default).
2025-02-21 16:55:49 +11:00
Sirraide
b0210fee94
[Clang] [NFC] Fix more -Wreturn-type warnings in tests everywhere (#123470)
With the goal of eventually being able to make `-Wreturn-type` default to an 
error in all language modes, this is a follow-up to #123464 and updates even
more tests, mainly clang-tidy and clangd tests.
2025-02-20 19:49:37 +01:00
Cullen Rhodes
61cfa53896
[compiler-rt][asan] Re-enable forkpty test on AArch64 (NFC) (#127667)
Disabled in 86474c7a1addf59d511050552b697b8b2af61838, no longer failing
on AArch64 (for me at least).

Fixes: https://github.com/llvm/llvm-project/issues/24774
2025-02-18 17:01:23 -08:00
Lang Hames
059f044309 [ORC] Propagate weak & hidden flags when creating lazy reexports, redirectables.
Updates JITLinkRedirectableSymbolManager to take alias flags into account when
setting the scope and linkage of the created stubs (weak aliases get now get weak
linkage, hidden stubs get hidden visibility).

Updates lazyReexports to propagate alias flags (rather than trampoline flags)
when building the initial destinations map for the redirectable symbols manager.

Together these changes allow the LazyObjectLinkingLayer to link objects
containing weak and hidden symbols.
2025-02-18 22:18:34 +11:00
Ethan Luis McDonough
83e180cb70
[Clang][PGO] Fix profile function visibility bug (#127257)
This pull request fixes an issue that was introduced in #93365.
`__llvm_write_custom_profile` visibility was causing issues on Darwin.
This function needs to be publicly accessible in order to be accessed by
libomptarget, so this pull request makes `__llvm_write_custom_profile`
an explicitly exported symbol on Darwin. Tested on M3 and X86 macs.
2025-02-17 13:46:37 -06:00
Victor Campos
43d308dd0d
[compiler-rt] Add support for big endian for Arm's __negdf2vfp (#127096)
In soft floating-point ABI, this function takes the double argument as a
pair of registers r0 and r1.

The ordering of these two registers follow the endianness rules,
therefore the register on which the bit flipping must happen depends on
the endianness.
2025-02-17 11:43:36 +00:00
Jens Reidel
8730fd7c64
[compiler-rt][Mips] Align definition of __sanitizer_sigaction with musl (#124494)
The definition of __sanitizer_sigaction for MIPS matches the one in
glibc [1]. musl however uses a single definition of sigaction for all
architectures [2] that is more similar to the other architectures
supported by glibc. Fix the conditional logic so that
__sanitizer_sigaction matches the musl definition on MIPS.

[1]:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/sigaction.h;h=f7e3ad88abbf3c497aaed44247bc1085efebe462;hb=dc650eb715df0a272ce43dfb55a209d5b018cc04
[2]: https://git.musl-libc.org/cgit/musl/tree/include/signal.h#n169

---------

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-02-14 10:39:55 -08:00
Florian Mayer
8ed36373a2 [NFC] [sanitizer] allow getauxval in symbolizer 2025-02-12 17:20:28 -08:00
Florian Mayer
6936fadfc3
[compiler-rt] [sanitizer] avoid UB in allocator (#126977) 2025-02-12 15:49:55 -08:00
Ethan Luis McDonough
9e5c136d5a
[PGO][Offload] Profile profraw generation for GPU instrumentation #76587 (#93365)
This pull request is the second part of an ongoing effort to extends PGO
instrumentation to GPU device code and depends on #76587. This PR makes
the following changes:

- Introduces `__llvm_write_custom_profile` to PGO compiler-rt library.
This is an external function that can be used to write profiles with
custom data to target-specific files.
- Adds `__llvm_write_custom_profile` as weak symbol to libomptarget so
that it can write the collected data to a profraw file.
- Adds `PGODump` debug flag and only displays dump when the
aforementioned flag is set
2025-02-11 23:30:54 -06:00
Christopher Ferris
9db0f91ceb
[scudo] Modify header corrupption error message (#126812)
Update the error message to be explicit that this is likely due to
memory corruption.

In addition, check if the chunk header is all zero, which could mean
corruption or an attempt to free a pointer after the memory has been
released to the kernel. This case results in a slightly different error
message to also indicate this could still be a double free.
2025-02-11 17:41:15 -08:00
Victor Campos
dd369c771e
[compiler-rt] Fix tests of __aeabi_(idivmod|uidivmod|uldivmod) to support big endian (#126277)
This patch makes these functions' tests work in big endian mode:
 - `__aeabi_idivmod`.
 - `__aeabi_uidivmod`.
 -  `__aeabi_uldivmod`.

The three functions return a struct containing two fields, quotient and
remainder, via *value in regs* calling convention. They differ in the
integer type of each field.

In the tests of the first two, a 64-bit integer is used as the return
type of the call. And as consequence of the ABI rules for structs
(Composite Types), the quotient resides in `r0` and the remainder in
`r1` regardless of endianness. So, in order to access each component
from the 64-bit integer in the caller code, care must be taken to access
the correct bits as they do depend on endianness in this case.

In the test of the third one, the caller code has inline assembly to
access the components. This assembly code assumed little endian, so it
had to be made flexible for big endian as well.

`_YUGA_BIG_ENDIAN` is defined in `int_endianness.h`. It's a macro
internal to compiler-rt that's in theory compatible with more toolchains
than gcc and clang.
2025-02-11 09:49:56 +00:00
Rainer Orth
a0587414cb
[sanitizer_common][test] Remove second SanitizerCommon.ReportFile tem… (#126509)
…p file

The `SanitizerCommon.ReportFile` test leaves a temp file behind on every
run. While this is not a problem for manual builds, on buildbots those
files accumulate over time, interfering with other bots on the same
system.

The files in question are named like
`sanitizer_common.reportfile.tmp.XXXXXX.<pid>`. The issue can be seen in
Solaris `truss` output:
```
22633:	fstatat64(AT_FDCWD, "/tmp/sanitizer_common.reportfile.tmp.rzVEja", 0xFEFFBAD0, AT_SYMLINK_NOFOLLOW) Err#2 ENOENT
22633:	openat64(AT_FDCWD, "/tmp/sanitizer_common.reportfile.tmp.rzVEja", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
22633:	openat64(AT_FDCWD, "/tmp/sanitizer_common.reportfile.tmp.rzVEja.22633", O_WRONLY|O_CREAT|O_TRUNC, 0660) = 4
22633:	unlinkat(AT_FDCWD, "/tmp/sanitizer_common.reportfile.tmp.rzVEja", 0) = 0
```
The first temp file, created by `temp_file_name`, is removed at the end
of the test, the second one, created in `ReportFile::GetReportPath`
using `OpenFile`, is not.

This patch fixes this, simply removing the file.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
2025-02-11 09:02:05 +01:00
Piyou Chen
2cd8207b26
[RISCV][compiler-rt] drop __riscv_vendor_feature_bits (#126460)
Address https://github.com/riscv-non-isa/riscv-c-api-doc/pull/101
2025-02-11 15:19:19 +08:00
Jens Reidel
c9f1d2cbf1
[compiler-rt][Mips] Fix mips SP register definition (#124493)
The mainline Linux kernel defines EF_R29, not EF_REG29 [1]. Further, the
asm/reg.h header requires `_MIPS_SIM_*` to be defined, which reside in
asm/sgidefs.h [2].

[1]:
https://github.com/torvalds/linux/blob/v6.13/arch/mips/include/uapi/asm/reg.h#L151
[2]:
https://github.com/torvalds/linux/blob/v6.13/arch/mips/include/uapi/asm/sgidefs.h#L33-L35

---------

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-02-10 19:28:04 -08:00
Charlie Barto
73114e43ee
[compiler-rt][windows] Test fixups for MSVC. (#109887)
- add XFAIL/UNSUPPORTED annotations for tests run wtih real MSVC 
- macroify usages of clang-specific attributes in asan tests

- Add substitution for /Oy-/-fno-omit-frame-pointer
  This makes the dll_intercept_memset test work with mingw

These are most of the changes that are required to get things running
with MSVC, however there are some remaining build-flag tweaks.

Nothing in here should be a functional change.
2025-02-10 10:51:08 -08:00
David CARLIER
427b24a408
[compiler-rt][rtsan] adding readlink(at) interception (#126262) 2025-02-07 21:33:29 +00:00
Christopher Ferris
3d35246c50
[scudo] Make guard pages optional in the secondary (#125960)
Add an optional flag for the secondary allocator called
`EnableGuardPages` to enable/disable the use of guard pages. By default,
this option is enabled.
2025-02-06 17:03:30 -08:00
Kai Nacke
b7279ed5b3
[SystemZ][XRay] Make xray work with gcc (#126154)
It seems that depending on the platform, gcc acceptts or does not accept
`-mvx` without specifying an architecture actually having vector
instructions. The solution which seems to work across different versions
of gcc and clang is to specify the least architecture which has vector
instructions.

In addition, initialization of the unused variable CPU prevents a
compiler warning from gcc.
2025-02-06 19:00:20 -05:00
Zequan Wu
8d925a1c72 [compiler-rt] Fix binary-id-path.c after da053415d214d6a66ff5f8c69eb35b2c9ada9caf 2025-02-06 14:22:34 -08:00
Kai Nacke
d905c7e316
[XRay][SystemZ] Use stckf for non-clang compilers (#125289)
Turns out there are users who use gcc to compile compiler-rt. Using the
clang-specific builtin function `__builtin_readcyclecounter()` does not
work in this case.
Solution is to use inline assembly using the stckf instruction in case
the compiler is not clang.
2025-02-06 16:08:05 -05:00
Sinkevich Artem
da053415d2
[profile] Add %b LLVM_PROFILE_FILE option for binary ID (#123963)
Add support for expanding `%b` in `LLVM_PROFILE_FILE` to the binary ID
(build ID). It can be used with `%m` to avoid its signature collisions.

This is supported on all platforms where writing binary IDs into
profiles is implemented, as the `__llvm_write_binary_ids` function is
used.

Fixes #51560.
2025-02-06 16:05:10 -05:00
funsafe-ptr
6575154b6e
[compiler-rt] Fixed Android 8.1 getauxval(AT_PAGESZ) crashes if called from .preinit_array. (#113427) (#116121)
Signed-off-by: funsafe-ptr <funsafe-ptr@proton.me>
2025-02-06 09:40:22 -08:00
Lang Hames
e00f824e9a [ORC-RT] Use templates to express deeply nested function calls in testcase.
Makes this test smaller and more readable.
2025-02-06 17:31:08 +11:00
Lang Hames
88f55d16c4 [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!
2025-02-06 11:02:06 +11:00
Lang Hames
aefa30e230 [ORC-RT] Add a comment explaining the purpose of this testcase. NFC. 2025-02-06 11:02:06 +11:00