Commit Graph

17229 Commits

Author SHA1 Message Date
Leandro Lupori
33acdc1e2f [compiler-rt][xray] Fix alignment of XRayFileHeader
XRayFileHeader storage was obtained from std::aligned_storage
using its default alignment and not the struct's alignment
requirement. This was causing a bus error on AArch32, on armv8
machines, where vld1.64/vst1.64 instructions with 128-bit
alignment requirement were being used to copy XRayFileHeader.

There is still another issue with fdr-single-thread.cpp test on
armv7. Now it runs until completion and produces a valid log file,
but for some reason the function name appears as _end in it,
instead of the expected mangled fn name.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D155013
2023-07-17 10:51:27 -03:00
Simi Pallipurath
6f4f1023fa [compiler-rt] [Arm] Make the tests for the runtime functions __aeabi_c{d,f} work on Big-Endian.
We are trying to build the compiler-rt as big-endian. And found that the tests compiler-rt/test/builtins/Unit/arm/aeabi_cdcmpeq_test.c and compiler-rt/test/builtins/Unit/arm/aeabi_cfcmpeq_test.c do not work on big endian at the moment. This patch makes these tests work on big endian as well.

Reviewed By: peter.smith, simon_tatham

Differential Revision: https://reviews.llvm.org/D155208
2023-07-17 12:27:32 +01:00
Sylvestre Ledru
b446c6dfcf cmake: set _LARGEFILE_SOURCE=1 to fix a cmake error
```
-- Performing additional configure checks with target flags: -mips32r2;-mabi=32;-D_LARGEFILE_SOURCE;-D_FILE_OFFSET_BITS=64
-- Performing Test COMPILER_RT_HAS_mips_FLOAT16
CMake Error: Parse error in command line argument: _LARGEFILE_SOURCE
 Should be: VAR:type=value
```
See: https://buildd.debian.org/status/fetch.php?pkg=llvm-toolchain-16&arch=mips64el&ver=1%3A16.0.6-4&stamp=1689111818&raw=0

Differential Revision: https://reviews.llvm.org/D155409
2023-07-17 09:59:56 +02:00
MarcoFalke
fa8401f9bf [compiler-rt][NFC] Avoid implicit-integer-sign-change in FuzzedDataProvider::ConsumeIntegralInRange
This makes the implicit conversion that is happening explicit.
Otherwise, each user is forced to suppress this
implicit-integer-sign-change runtime error in their their UBSAN
suppressions file.

For example, the runtime error might look like:

runtime error: implicit conversion from type 'long' of value -9223372036854775808 (64-bit, signed) to type 'uint64_t' (aka 'unsigned long') changed the value to 9223372036854775808 (64-bit, unsigned)
    #0 0x55fe29dea91d in long FuzzedDataProvider::ConsumeIntegralInRange<long>(long, long) src/./test/fuzz/FuzzedDataProvider.h:233:25
    [...]
SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change test/fuzz/FuzzedDataProvider.h:233:25 in

Differential Revision: https://reviews.llvm.org/D155206
2023-07-17 09:32:19 +02:00
Martin Storsjö
c6bd873403 [CMake] Switch the CMP0091 policy (MSVC_RUNTIME_LIBRARY) to the new behaviour
With the new behaviour, the /MD or similar options aren't added to
e.g. CMAKE_CXX_FLAGS_RELEASE, but are added separately by CMake.
They can be changed by the cmake variable
CMAKE_MSVC_RUNTIME_LIBRARY or with the target property
MSVC_RUNTIME_LIBRARY.

LLVM has had its own custom CMake flags, e.g. LLVM_USE_CRT_RELEASE,
which affects which CRT is used for release mode builds. Deprecate
these and direct users to use CMAKE_MSVC_RUNTIME_LIBRARY directly
instead (and do a best effort attempt at setting CMAKE_MSVC_RUNTIME_LIBRARY
based on the existing LLVM_USE_CRT_ flags). This only handles the
simple cases, it doesn't handle multi-config generators with
different LLVM_USE_CRT_* variables for different configs though,
but that's probably fine - we should move over to the new upstream
CMake mechanism anyway, and push users towards that.

Change code in compiler-rt, that previously tried to override the
CRT choice to /MT, to set CMAKE_MSVC_RUNTIME_LIBRARY instead of
meddling in the old variables.

This resolves the policy issue in
https://github.com/llvm/llvm-project/issues/63286, and should
handle the issues that were observed originally when the
minimum CMake version was bumped, in
https://github.com/llvm/llvm-project/issues/62719 and
https://github.com/llvm/llvm-project/issues/62739.

Differential Revision: https://reviews.llvm.org/D155233
2023-07-17 09:59:05 +03:00
Caslyn Tonelli
c3767a943f [ubsan] Disable sigaction.cpp on archs for debugging
Add `ubsan-tsan` condition to test disablement.

Differential Revision: https://reviews.llvm.org/D155317
2023-07-15 15:02:50 +00:00
Dmitry Vyukov
f6db55ea66 ubsan: disable sigaction test for aarch64
The test seems to segfault on aarch64 with tsan:
https://lab.llvm.org/buildbot/#/builders/179/builds/6662
Reason unknown, needs debugging.

Reviewed By: melver, Caslyn

Differential Revision: https://reviews.llvm.org/D155272
2023-07-14 16:39:29 +00:00
Weining Lu
ef33d6cbfc [XRay] Add initial support for loongarch64
Only support patching FunctionEntry/FunctionExit/FunctionTailExit for now.

Reviewed By: MaskRay, xen0n
Co-Authored-By: zhanglimin <zhanglimin@loongson.cn>

Differential Revision: https://reviews.llvm.org/D140727
2023-07-14 09:27:13 +08:00
Pavel Iliin
61962aa1ee [compiler-rt][AArch64] Correct how FMV use ifunc resolver abi.
The patch fixes second argument of Function Multi Versioning resolvers,
it is pointer to an extendible struct containing hwcap and hwcap2 not a
unsigned long hwcap2. Also fixes FMV features caching in resolver.

Differential Revision: https://reviews.llvm.org/D155026
2023-07-14 00:37:48 +01:00
Dmitry Vyukov
1377179396 sanitizer_common: initialize sanitizer runtimes lazily from signal interceptors
Currently if a program calls sigaction very early (before non-lazy sanitizer
initialization, in particular if .preinit_array initialization is not enabled),
then sigaction will wrongly fail since the interceptor is not initialized yet.

In all other interceptors we do lazy runtime initialization for this reason,
but we don't do it in the signal interceptors.
Do lazy runtime initialization in signal interceptors as well.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D155188
2023-07-13 16:28:25 +02:00
Blue Gaston
020cdaff61 [Asan][Darwin][GCD] Add interceptor for dispatch_mach_create_f
When enabling DriverKit, Address Sanitizer was unable to
intercept thread creation directly for dispatch workerthreads.

Because of this calls to GetStackTraceFromID failed and ASan was
unable to capture a meaningful stack trace.

This patch adds an interceptor for a dispatch function as a proxy
that is "close enough" to thread creation so that ASan is able
to meaningfully capture and register the dispatched thread.

Note: I propose not adding a test for this change.
Because this change is only meaningful in such a narrow usecase on Darwin
and is incredibly difficult to add a meaningful test.

Differential Revision: https://reviews.llvm.org/D154753
2023-07-12 20:52:10 -07:00
Petr Hosek
bb7a902c76 [CMake] Use COMPILER_RT_BUILD_CRT in the condition for test
Unlike COMPILER_RT_HAS_CRT this handles the case where CRT is available
but has been disabled by setting COMPILER_RT_BUILD_CRT. This addresses
an issue reported on D153989.

Differential Revision: https://reviews.llvm.org/D155126
2023-07-12 22:30:43 +00:00
Daniel Thornburgh
6be453ed7f [debuginfod] Use dedicated cache dir for tests 2023-07-12 14:28:56 -07:00
Chia-hung Duan
1a4bc114ec Reland "[scudo] Support partial concurrent page release in SizeClassAllocator64"
This reverts commit 2f04b688aa.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D155015
2023-07-12 18:25:01 +00:00
Petr Hosek
286f4c0f07 Revert "[CMake] Use COMPILER_RT_BUILD_CRT in the condition for test"
This reverts commit 926f3759ec.
2023-07-12 18:02:19 +00:00
Petr Hosek
926f3759ec [CMake] Use COMPILER_RT_BUILD_CRT in the condition for test
Unlike COMPILER_RT_HAS_CRT this handles the case where CRT is available
but has been disabled by setting COMPILER_RT_BUILD_CRT.
2023-07-12 17:41:16 +00:00
Petr Hosek
b47beecc81 [compiler-rt] Move crt into builtins
On Linux crt is typically use in combination with builtins. In the Clang
driver the use of builtins and crt is controlled by the --rtlib option.
Both builtins and crt also have similar build requirements where they
need to be built before any other runtimes and must avoid dependencies.
We also want builtins and crt these to be buildable separately from the
rest of compiler-rt for bootstrapping purposes. Given how simple crt is,
rather than maintaining a separate directory with its own separate build
setup, it's more efficient to just move crt into builtins. We still use
separate CMake option to control whether to built crt same as before.

This is an alternative to D89492 and D136664.

Differential Revision: https://reviews.llvm.org/D153989
2023-07-11 23:05:45 +00:00
Daniel Thornburgh
580f9f7ef0 [llvm-cov][debuginfod] Make test more hermetic 2023-07-11 16:00:46 -07:00
Martin Storsjö
4579843d59 [compiler-rt] [test] Mark a windows specific test as requiring an MSVC like environment
This test relies on MSVC style linking details, such as -Wl,-dll
(which could be expressed with just "-shared", which would work
with MinGW too) and an implicitly created import library named
"<basename>.lib" (which isn't created when linking in MinGW mode).

This fixes running the compiler-rt tests in MinGW environments.
2023-07-12 00:11:47 +03:00
Thurston Dang
0c9145f413 [msan] Fix -Wcast-qual error in msan_dl.cpp
Fix build breakage from https://reviews.llvm.org/D154272.
(I accidentally dropped the fix when I relanded the patch.)
2023-07-11 21:04:51 +00:00
Chia-hung Duan
2f04b688aa Revert "[scudo] Support partial concurrent page release in SizeClassAllocator64"
We should merge two top TransferBatches so that the range marking can be
done correctly

This reverts commit 57ae8a2a1a.

Differential Revision: https://reviews.llvm.org/D155009
2023-07-11 20:33:58 +00:00
Thurston Dang
9095d5c44b Reland '[msan] Intercept dladdr1, and refactor dladdr'
Relanding with #if SANITIZER_GLIBC to avoid breaking FreeBSD.
Also incorporates Arthur's BUILD.gn fix (thanks!) from https://reviews.llvm.org/rGc1e283851772ba494113311405d48cfb883751d1

Original commit message:
This patch adds an msan interceptor for dladdr1 (with support for RTLD_DL_LINKMAP and RTLD_DL_SYMENT) and an accompanying test. It also adds a helper file, msan_dl.cpp, that contains UnpoisonDllAddrInfo (refactored out of the dladdr interceptor) and UnpoisonDllAddr1ExtraInfo.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D154272
2023-07-11 20:05:54 +00:00
Petr Hosek
7c4dbff05d Revert "[compiler-rt] Move crt into builtins"
This reverts commit dae9d1b524 since
it caused https://github.com/llvm/llvm-project/issues/63799.
2023-07-11 15:32:49 +00:00
Petr Hosek
dae9d1b524 [compiler-rt] Move crt into builtins
On Linux crt is typically use in combination with builtins. In the Clang
driver the use of builtins and crt is controlled by the --rtlib option.
Both builtins and crt also have similar build requirements where they
need to be built before any other runtimes and must avoid dependencies.
We also want builtins and crt these to be buildable separately from the
rest of compiler-rt for bootstrapping purposes. Given how simple crt is,
rather than maintaining a separate directory with its own separate build
setup, it's more efficient to just move crt into builtins. We still use
separate CMake option to control whether to built crt same as before.

This is an alternative to D89492 and D136664.

Differential Revision: https://reviews.llvm.org/D153989
2023-07-11 07:41:04 +00:00
Chia-hung Duan
280ffafca5 [scudo] Simple coding style fix in mem_map_base.h (NFC)
Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D154894
2023-07-10 21:29:26 +00:00
Chia-hung Duan
316ca42a65 [scudo] Print PushedBytesDelta in getStats()
This gives a hint of potential bytes to release. Also remove the RSS
which is not supported yet. Will add it back when it's available.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D154551
2023-07-10 21:29:18 +00:00
Chia-hung Duan
57ae8a2a1a [scudo] Support partial concurrent page release in SizeClassAllocator64
After extracting memory groups, it's safe to do
1. markFreeBlocks
2. releaseFreeMemoryToOS concurrently with pushBlocks() and
popBatches(). This will improve the throughput of Scudo.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D153608
2023-07-10 17:24:37 +00:00
Zequan Wu
985486dca4 [Profile] Remove duplicate file locks when enabled continuous mode and online merging.
In `initializeProfileForContinuousMode`, we have already locked the profile file when merging is enabled, so there's no need to lock the same file second time in `openFileForMerging`.

On Linux/Darwin, the locking the same file twice doesn't cause any problem. But on Windows, it causes the problem to hang forever.

With this minor fix, continuous mode seems working with online merging on Windows.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D154748
2023-07-10 11:01:28 -04:00
Kirill Stoimenov
3c0ae1f5ab [ASAN] Moved mmap/munmap test to posix. 2023-07-07 22:42:31 +00:00
Chia-hung Duan
399eb5632f [scudo] Explicit casting for u16 arithmetic operation
This fixes the werror from https://lab.llvm.org/buildbot/#/builders/165/builds/38829

Reviewed By: enh

Differential Revision: https://reviews.llvm.org/D154733
2023-07-07 19:58:02 +00:00
Kirill Stoimenov
9b79e15da1 [ASAN] Disable mmap test on Windows. 2023-07-07 18:46:51 +00:00
Chia-hung Duan
1ff3a5d9bb [scudo] Allow pushing single block to the freelist of BatchClass
This CL removes the restriction that pushing blocks into BatchClassId
can only be done when freelist is not empty. Without this constraint,
BatchClassId is also available for gathering blocks into groups.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D153492
2023-07-07 17:27:48 +00:00
Kirill Stoimenov
a34e702aa1 [ASAN] Add mmap and munmap interceptor in ASAN
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D154659
2023-07-07 15:48:12 +00:00
David Spickett
e5a7e48652 [compiler-rt][xray] Disable fdr-single-thread test on Arm
For unknown reasons this casues a bus error.

See:
https://lab.llvm.org/buildbot/#/builders/178/builds/5157
2023-07-07 09:46:07 +00:00
Kito Cheng
2b5ea51a41 [compiler-rt][RISCV] Fix __fe_getround and __fe_raise_inexact for Zfinx
Zfinx extension also provide floating point environment like F extension, so
enable that on `__fe_getround` and `__fe_raise_inexact` too.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D154570
2023-07-07 14:24:50 +08:00
Thurston Dang
667b9add73 Revert "Reland '[msan] Intercept dladdr1, and refactor dladdr'"
This reverts my commit 015dabd767
due to breaking non-glibc builds.
2023-07-07 00:23:03 +00:00
Thurston Dang
1da10d25d9 [msan] Fix -Wcast-qual error in msan_dl.cpp
Attempt 2 at fixing a buildbot error https://lab.llvm.org/buildbot#builders/57/builds/28143
that I had introduced in D154272
2023-07-06 18:04:22 +00:00
Chia-hung Duan
bce8c9e3d7 [scudo] Try to release pages after unlocking the TSDs
This increases the parallelism and the usage of TSDs

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D152988
2023-07-06 17:40:26 +00:00
Chia-hung Duan
531f90acc5 [scudo] Verify the size of free blocks in primary allocator
When all the blocks (local caches are included) are freed, the size of
free blocks should be equal to `AllocatedUser`.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D152769
2023-07-06 17:40:25 +00:00
Thurston Dang
015dabd767 Reland '[msan] Intercept dladdr1, and refactor dladdr'
Reland with -Wcast-qual issue fixed

Original commit message:
This patch adds an msan interceptor for dladdr1 (with support for RTLD_DL_LINKMAP and RTLD_DL_SYMENT) and an accompanying test. It also adds a helper file, msan_dl.cpp, that contains UnpoisonDllAddrInfo (refactored out of the dladdr interceptor) and UnpoisonDllAddr1ExtraInfo.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D154272
2023-07-06 16:16:22 +00:00
Marco Elver
65bc9c3666 [compiler-rt] Fix __sanitizer_cpuset size on newer FreeBSD
Current FreeBSD has increased size of cpuset. Match it to not break the
build on newer FreeBSD.

Patch by John F. Carr

Fixes: https://github.com/llvm/llvm-project/issues/63485
2023-07-06 12:34:36 +02:00
Fangrui Song
f7624b080a [XRay][test] Remove unneeded REQUIRES: x86_64-target-arch
fdr-thread-order.cpp can be very slow when the thread contention is large.
Enable it for AArch64 and x86-64 for now.

fdr-mode.cpp fails on a ppc64le machine. Unsupport it on ppc64le for now.

The remaining modified tests pass on AArch64, ppc64le, and x86-64.
2023-07-05 21:34:02 -07:00
Fangrui Song
9e7a052eef [XRay][AArch64] Implement __xray_ArgLoggerEntry 2023-07-05 20:56:00 -07:00
zhanglimin
cea3a89841 [profile] Enable loongarch64
Mark loongarch64 as supported for profile. All tests passed.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D154405
2023-07-06 11:06:54 +08:00
Fangrui Song
88b9d4d77e [XRay][test] Replace some XFAIL with more appropriate REQUIRES 2023-07-05 20:06:37 -07:00
Mariusz Borsa
3ff080b53b [Sanitizers][Darwin][Test] Mark symbolize_pc test unsupported in Darwin/LSan context
LSan is unsupported on Darwin anyway, and this test fals on public Darwin bots

Differential Revision: https://reviews.llvm.org/D154389
2023-07-05 16:54:20 -07:00
Chia-hung Duan
b0ec18a3d1 [scudo] Extract steps releaseToOSMaybe into functions in
This refactor helps us identify which steps need FLLock so that we can
reduce the holding time of FLLock in SizeClassAllocator64.

Also move the data members to the end of class to align the style in
SizeClassAllocator32.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D152596
2023-07-05 20:31:32 +00:00
Caslyn Tonelli
4a5d626783 [scudo] SCUDO_FUCHSIA uses ReservedMemoryDefault
Some Fuchsia zx tests failed from https://reviews.llvm.org/D153888:
https://turquoise-internal-review.git.corp.google.com/c/integration/+/729619

Use `ReservedMemoryDefault` for `SCUDO_FUCHSIA` to use the default
MemMap API, while test failures are debugged.

Differential Revision: https://reviews.llvm.org/D154538
2023-07-05 20:22:17 +00:00
Fabio D'Urso
3003da7154 [scudo] Implement Fuchsia backend for the new MemMap API
Reviewed By: Caslyn, Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D153888
2023-07-05 14:07:37 +02:00
Blue Gaston
f171c76b68 [ASanAbi][Darwin] Build ios stable ABI library
In the initially commit, we limited the static archive to osx.

This patch removes that limitation.

Differential Revision: https://reviews.llvm.org/D153789
2023-07-04 14:32:59 -07:00