aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
AgeCommit message (Collapse)AuthorFilesLines
2023-07-25[X86] Support -march=graniterapids-d and update -march=graniterapidsFreddy Ye1-1/+8
Reviewed By: pengfei, RKSimon, skan Differential Revision: https://reviews.llvm.org/D155798
2023-07-24[builtins] Avoid using CRT_LDBL_128BIT in implementation. NFCAlex Richardson25-26/+29
Currently the *tf builtin functions can only be built if long double is an IEEE float, which prevents them from being available e.g. for x86 targets (unlike libgcc which has them). This non-functional change prepares the builtins library *tf functions for being able to target x86 by decoupling their presence from CRT_LDBL_128BIT and instead checking for a CRT_HAS_TF_MODE macro. This change is NFC since the CRT_HAS_TF_MODE is currently only set if long double is an IEEE 128-bit float. Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D153812
2023-07-24[builtins] Drop -fnested-functions flag from testsAlex Richardson2-6/+1
This flag does nothing for clang and is apparently not supported by GCC: aarch64-linux-gnu-gcc: error: unrecognized command-line option '-fnested-functions'; did you mean '-Wunused-function'? It looks like it was maybe supported by Apple GCC, but that is no longer a supported compiler. Differential Revision: https://reviews.llvm.org/D153819
2023-07-24[builtins] Fix building trunc*fhf2_test with GCCAlex Richardson2-2/+2
GCC does not support __fp16, use the TYPE_FP16 macro instead. Differential Revision: https://reviews.llvm.org/D153813
2023-07-24[NFC] Add MprotectReadWriteVitaly Buka4-0/+16
It's unused, but I need it for debuging. Seems usefull for completeness. Reviewed By: thurston Differential Revision: https://reviews.llvm.org/D156180
2023-07-23[sanitizer] use the right type for sizeof for interceptor hookWu, Yingcong1-1/+1
`PRE_READ` is called with a pointer and the size of the object the pointer points to. But there is one line of code not calling `PRE_READ` correctly(likely missing a dereference). This patch fixes the problem. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D154676
2023-07-22[InstrProf] Stabilize --show-prof-sym-list dump orderFangrui Song1-3/+3
D118181 leverages the iteration order of StringSet, which is not guaranteed to be deterministic.
2023-07-22[builtins][Mips] Un-break FreeBSD build of __clear_cacheJessica Clarke1-1/+5
Commit 674a17e9bbe8 ("MIPS/compiler_rt: use synci to flush icache on r6") completely removed the OS-specific guards under the guise of "For pre-r6, we can use cacheflush libc function, which is same on Linux and FreeBSD." However, the code in question had guards for Linux and OpenBSD, not Linux and FreeBSD, and FreeBSD does not have a cacheflush libc function as claimed, so this was neither the statement they intended to make nor was it sufficient justification for making the code completely unconditional. Whilst the upcoming FreeBSD 14 release has dropped support for MIPS, FreeBSD 13 has support for it. Fix this by only calling cacheflush on the OSes where it was previously called, and not on other OSes where it either definitely isn't available (FreeBSD) or is unknown (any other OS than the three mentioned in this commit).
2023-07-21[HWASAN][LSAN] Replace cstdint with stdint.hKirill Stoimenov1-1/+1
Reviewed By: brooksmoses, MaskRay Differential Revision: https://reviews.llvm.org/D155994
2023-07-21[Sanitizers][Darwin][Test] Mark symbolize_pc test on Darwin/TSan+UBSan as ↵Arthur Eubanks1-3/+3
UNSUPPORTED Followup to https://reviews.llvm.org/rG760c208f6ff9e97a9a11523c00874a1eec4f876b which XFAIL'd them, but they pass in some configurations.
2023-07-20[scudo] Clean up tests.Christopher Ferris8-29/+53
Modify the tests so that all clang warnings can be turned up to high. Fix all places flagged by -Wconversion. Fix a few unused variables not marked with UNUSED. For the memtag testing, only compile some tests for 64 bit since compiling them on 32 bit leads to warnings/errors. All of the tests are already skipped on 32 bit OSes, so this will not affect any real tests. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D155749
2023-07-20[Sanitizers][Darwin][Test] XFAIL symbolize_pc test on Darwin/TSan+UBSanMariusz Borsa1-0/+4
2023-07-19[sanitizer-common] Run module msan init before early sigaction testDaniel Thornburgh1-1/+1
MSAN wrappers can be inserted for e.g. the access to stderr in the constructor of the test, which can segfault if the constructor function runs before these data structures have been initialized. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D155648
2023-07-19[InstrProf][NFC] Ignore -Wcast-qual after D153911 to fix build failure on AIXJake Egan1-1/+7
/scratch/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c:202:40: error: cast from 'const int (*)[0]' to 'void *' drops const qualifier [-Werror,-Wcast-qual] (void *)&dummy_name, (void *)&dummy_vnds}; ^ 1 error generated.
2023-07-19[InstrProf] Ignore -Wcast-qual after D153911 to fix build failure (NFC)Jie Fu3-0/+30
/data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:46:60: error: cast from 'const char *' to 'struct __llvm_profile_header *' drops const qualifier [-Werror,-Wcast-qual] __llvm_profile_header *Header = (__llvm_profile_header *)ProfileData; ^ /data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:49:30: error: cast from 'const char *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual] (__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) + ^ /data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:77:41: error: cast from 'const struct __llvm_profile_data *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual] DstData = (__llvm_profile_data *)__llvm_profile_begin_data(); ^ /data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:109:60: error: cast from 'const char *' to 'struct __llvm_profile_header *' drops const qualifier [-Werror,-Wcast-qual] __llvm_profile_header *Header = (__llvm_profile_header *)ProfileData; ^ /data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:116:30: error: cast from 'const char *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual] (__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) + ^ /data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:129:40: error: cast from 'const struct __llvm_profile_data *' to 'struct __llvm_profile_data *' drops const qualifier [-Werror,-Wcast-qual] DstData = (__llvm_profile_data *)__llvm_profile_begin_data(), ^ /data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:179:34: error: cast from 'const char *' to 'struct ValueProfData *' drops const qualifier [-Werror,-Wcast-qual] VPMergeHook((ValueProfData *)SrcValueProfData, DstData); ^ /data/llvm-project/compiler-rt/lib/profile/InstrProfilingMerge.c:181:46: error: cast from 'const char *' to 'struct ValueProfData *' drops const qualifier [-Werror,-Wcast-qual] SrcValueProfData + ((ValueProfData *)SrcValueProfData)->TotalSize; ^ ...
2023-07-19[CMake] Clean up old code for handling MSVC runtime setting the old wayMartin Storsjö1-11/+0
This was left in place to reduce the risk of breaking anything, and to keep the diff smaller, in D155233. Differential Revision: https://reviews.llvm.org/D155431
2023-07-18[test] Make fuzzer/value-profile-div.test x86 specificFangrui Song1-2/+1
The test requires that an integer division by zero causes a trap, leading to a signal like SIGFPE. This is the case on x86. On many other architectures, such as Arm (unless software division is used and `__aeabi_idiv0` is patched), Power, RISC-V, LoongArch, there is no trap. Therefore, it's more appropriate to invert the condition to run the test. Reviewed By: Ami-zhang Differential Revision: https://reviews.llvm.org/D155644
2023-07-18[scudo] Fix memtag tests.Christopher Ferris1-5/+5
A few memtag tests were using EXPECT_DEBUG_DEATH which executes the statement unless NDEBUG is set. This meant the statement would cause an abort, but the EXPECT_DEATH part was not done. Change these to simply EXPECT_DEATH, these tests already verify that SCUDO_DEBUG is set before checking for DEATH. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D155538
2023-07-18[HWASAN][LSAN] Fix false positive memory leak reports on X86_64Kirill Stoimenov2-3/+25
Before this patch when running HWASAN on x86_64 with with memory tagging support we got a bunch of false memory leak reports. The reason for that is that the heuristic used to detect if an 8 bytes could be a user pointer was not valid when memory tagging is used as the top byte could contain non-zero information. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D155338
2023-07-18Revert "[sanitizer][asan][win] Intercept _strdup on Windows instead of strdup"Mitch Phillips1-17/+2
This reverts commit 31263211c6a4ef454216f2edbf9b2083a4c1474d. Reason: Broke the ASan Windows bot: https://reviews.llvm.org/rG31263211c6a4ef454216f2edbf9b2083a4c1474d
2023-07-17[sanitizer][asan][win] Intercept _strdup on Windows instead of strdupCharlie Barto1-2/+17
Intercept `_strdup` on windows, instead of the nonexistent `strdup`.
2023-07-18[fuzzer] Enable loongarch64Youling Tang2-3/+3
Enable fuzzer on loongarch64. Reviewed By: SixWeining, xen0n, MaskRay Differential Revision: https://reviews.llvm.org/D140601
2023-07-17[ubsan] Make sigaction.cpp test UNSUPPORTED rather than XFAILDaniel Thornburgh1-1/+1
The test fails on some builders but not on others; there's likely some kind of environment dependence that should be investigated. See https://reviews.llvm.org/D155317
2023-07-17[lsan][Darwin] Unconditionally strip high bits from potential pointersLeonard Grey1-9/+5
The method cache stashes a mask in the high bits under some circumstances: https://github.com/apple-oss-distributions/objc4/blob/689525d556eb3dee1ffb700423bccf5ecc501dbf/runtime/objc-cache.mm#L589 I'm hitting this now on macOS 13.4 arm64, so we can no longer rely on OBJC_FAST_IS_RW to identify potential pointers that need to be transformed Differential Revision: https://reviews.llvm.org/D153471
2023-07-17[compiler-rt][xray] Fix alignment of XRayFileHeaderLeandro Lupori1-2/+4
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[compiler-rt] [Arm] Make the tests for the runtime functions __aeabi_c{d,f} ↵Simi Pallipurath3-19/+24
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-17cmake: set _LARGEFILE_SOURCE=1 to fix a cmake errorSylvestre Ledru2-5/+5
``` -- 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[compiler-rt][NFC] Avoid implicit-integer-sign-change in ↵MarcoFalke1-2/+2
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[CMake] Switch the CMP0091 policy (MSVC_RUNTIME_LIBRARY) to the new behaviourMartin Storsjö2-14/+13
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-15[ubsan] Disable sigaction.cpp on archs for debuggingCaslyn Tonelli1-1/+1
Add `ubsan-tsan` condition to test disablement. Differential Revision: https://reviews.llvm.org/D155317
2023-07-14ubsan: disable sigaction test for aarch64Dmitry Vyukov1-0/+5
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[XRay] Add initial support for loongarch64Weining Lu8-4/+296
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[compiler-rt][AArch64] Correct how FMV use ifunc resolver abi.Pavel Iliin1-3/+26
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-13sanitizer_common: initialize sanitizer runtimes lazily from signal interceptorsDmitry Vyukov9-44/+79
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-12[Asan][Darwin][GCD] Add interceptor for dispatch_mach_create_fBlue Gaston1-0/+42
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[CMake] Use COMPILER_RT_BUILD_CRT in the condition for testPetr Hosek6-20/+30
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[debuginfod] Use dedicated cache dir for testsDaniel Thornburgh1-2/+4
2023-07-12Reland "[scudo] Support partial concurrent page release in SizeClassAllocator64"Chia-hung Duan4-43/+163
This reverts commit 2f04b688aadef747172a8f4a7d1658dc049b1e24. Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D155015
2023-07-12Revert "[CMake] Use COMPILER_RT_BUILD_CRT in the condition for test"Petr Hosek1-1/+1
This reverts commit 926f3759ec62a8f170e76a60316cc0bdd9dd2ec9.
2023-07-12[CMake] Use COMPILER_RT_BUILD_CRT in the condition for testPetr Hosek1-1/+1
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-11[compiler-rt] Move crt into builtinsPetr Hosek16-234/+129
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[llvm-cov][debuginfod] Make test more hermeticDaniel Thornburgh1-7/+8
2023-07-12[compiler-rt] [test] Mark a windows specific test as requiring an MSVC like ↵Martin Storsjö1-1/+1
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-11[msan] Fix -Wcast-qual error in msan_dl.cppThurston Dang1-1/+1
Fix build breakage from https://reviews.llvm.org/D154272. (I accidentally dropped the fix when I relanded the patch.)
2023-07-11Revert "[scudo] Support partial concurrent page release in SizeClassAllocator64"Chia-hung Duan1-105/+41
We should merge two top TransferBatches so that the range marking can be done correctly This reverts commit 57ae8a2a1acb1aa1a5f55c29b1b338a780d649d5. Differential Revision: https://reviews.llvm.org/D155009
2023-07-11Reland '[msan] Intercept dladdr1, and refactor dladdr'Thurston Dang5-13/+212
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-11Revert "[compiler-rt] Move crt into builtins"Petr Hosek16-129/+234
This reverts commit dae9d1b52469daca88a968e7b99a26420aef657c since it caused https://github.com/llvm/llvm-project/issues/63799.
2023-07-11[compiler-rt] Move crt into builtinsPetr Hosek16-234/+129
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-10[scudo] Simple coding style fix in mem_map_base.h (NFC)Chia-hung Duan1-2/+1
Reviewed By: cferris Differential Revision: https://reviews.llvm.org/D154894
2023-07-10[scudo] Print PushedBytesDelta in getStats()Chia-hung Duan2-20/+38
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