diff options
Diffstat (limited to 'compiler-rt')
26 files changed, 158 insertions, 52 deletions
diff --git a/compiler-rt/lib/builtins/assembly.h b/compiler-rt/lib/builtins/assembly.h index d7db7d8..d1e5328 100644 --- a/compiler-rt/lib/builtins/assembly.h +++ b/compiler-rt/lib/builtins/assembly.h @@ -304,7 +304,7 @@ .globl FUNC_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ DECLARE_SYMBOL_VISIBILITY(name) SEPARATOR \ - .set FUNC_SYMBOL(SYMBOL_NAME(name)), FUNC_SYMBOL(target) SEPARATOR + .set FUNC_SYMBOL(SYMBOL_NAME(name)), FUNC_SYMBOL(SYMBOL_NAME(target)) SEPARATOR #if defined(__ARM_EABI__) #define DEFINE_AEABI_FUNCTION_ALIAS(aeabi_name, name) \ diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h index 985bfb4..c9ba28a5 100644 --- a/compiler-rt/lib/scudo/standalone/combined.h +++ b/compiler-rt/lib/scudo/standalone/combined.h @@ -25,6 +25,7 @@ #include "size_class_allocator.h" #include "stack_depot.h" #include "string_utils.h" +#include "tracing.h" #include "tsd.h" #include "scudo/interface.h" @@ -671,10 +672,11 @@ public: void releaseToOS(ReleaseToOS ReleaseType) { initThreadMaybe(); + SCUDO_SCOPED_TRACE(GetReleaseToOSTraceName(ReleaseType)); if (ReleaseType == ReleaseToOS::ForceAll) drainCaches(); Primary.releaseToOS(ReleaseType); - Secondary.releaseToOS(); + Secondary.releaseToOS(ReleaseType); } // Iterate over all chunks and call a callback for all busy chunks located diff --git a/compiler-rt/lib/scudo/standalone/primary32.h b/compiler-rt/lib/scudo/standalone/primary32.h index e2de50b..49aa74a 100644 --- a/compiler-rt/lib/scudo/standalone/primary32.h +++ b/compiler-rt/lib/scudo/standalone/primary32.h @@ -511,6 +511,8 @@ uptr SizeClassAllocator32<Config>::tryReleaseToOS(uptr ClassId, template <typename Config> uptr SizeClassAllocator32<Config>::releaseToOS(ReleaseToOS ReleaseType) { + SCUDO_SCOPED_TRACE(GetPrimaryReleaseToOSTraceName(ReleaseType)); + uptr TotalReleasedBytes = 0; for (uptr I = 0; I < NumClasses; I++) { if (I == SizeClassMap::BatchClassId) @@ -1056,6 +1058,8 @@ uptr SizeClassAllocator32<Config>::releaseToOSMaybe(SizeClassInfo *Sci, uptr ClassId, ReleaseToOS ReleaseType) REQUIRES(Sci->Mutex) { + SCUDO_SCOPED_TRACE(GetPrimaryReleaseToOSMaybeTraceName(ReleaseType)); + const uptr BlockSize = getSizeByClassId(ClassId); DCHECK_GE(Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks); diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h index 3cb040c..7727049 100644 --- a/compiler-rt/lib/scudo/standalone/primary64.h +++ b/compiler-rt/lib/scudo/standalone/primary64.h @@ -22,6 +22,7 @@ #include "stats.h" #include "string_utils.h" #include "thread_annotations.h" +#include "tracing.h" namespace scudo { @@ -1307,6 +1308,8 @@ uptr SizeClassAllocator64<Config>::tryReleaseToOS(uptr ClassId, template <typename Config> uptr SizeClassAllocator64<Config>::releaseToOS(ReleaseToOS ReleaseType) { + SCUDO_SCOPED_TRACE(GetPrimaryReleaseToOSTraceName(ReleaseType)); + uptr TotalReleasedBytes = 0; for (uptr I = 0; I < NumClasses; I++) { if (I == SizeClassMap::BatchClassId) @@ -1376,6 +1379,8 @@ uptr SizeClassAllocator64<Config>::releaseToOSMaybe(RegionInfo *Region, uptr ClassId, ReleaseToOS ReleaseType) REQUIRES(Region->MMLock) EXCLUDES(Region->FLLock) { + SCUDO_SCOPED_TRACE(GetPrimaryReleaseToOSMaybeTraceName(ReleaseType)); + const uptr BlockSize = getSizeByClassId(ClassId); uptr BytesInFreeList; const uptr AllocatedUserEnd = diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h index 38c9a9e..f0b7bce 100644 --- a/compiler-rt/lib/scudo/standalone/secondary.h +++ b/compiler-rt/lib/scudo/standalone/secondary.h @@ -19,6 +19,7 @@ #include "stats.h" #include "string_utils.h" #include "thread_annotations.h" +#include "tracing.h" #include "vector.h" namespace scudo { @@ -118,7 +119,7 @@ public: bool canCache(UNUSED uptr Size) { return false; } void disable() {} void enable() {} - void releaseToOS() {} + void releaseToOS(ReleaseToOS) {} void disableMemoryTagging() {} void unmapTestOnly() {} bool setOption(Option O, UNUSED sptr Value) { @@ -351,6 +352,9 @@ public: // same time will not actually release any extra elements. Therefore, // let any other thread continue, skipping the release. if (Mutex.tryLock()) { + SCUDO_SCOPED_TRACE( + GetSecondaryReleaseToOSTraceName(ReleaseToOS::Normal)); + // TODO: Add ReleaseToOS logic to LRU algorithm releaseOlderThan(Time - static_cast<u64>(Interval) * 1000000); Mutex.unlock(); @@ -499,7 +503,9 @@ public: return true; } - void releaseToOS() EXCLUDES(Mutex) { + void releaseToOS([[maybe_unused]] ReleaseToOS ReleaseType) EXCLUDES(Mutex) { + SCUDO_SCOPED_TRACE(GetSecondaryReleaseToOSTraceName(ReleaseType)); + // Since this is a request to release everything, always wait for the // lock so that we guarantee all entries are released after this call. ScopedLock L(Mutex); @@ -574,6 +580,8 @@ private: } void releaseOlderThan(u64 Time) REQUIRES(Mutex) { + SCUDO_SCOPED_TRACE(GetSecondaryReleaseOlderThanTraceName()); + if (!LRUEntries.size() || OldestTime == 0 || OldestTime > Time) return; OldestTime = 0; @@ -669,7 +677,7 @@ public: bool setOption(Option O, sptr Value) { return Cache.setOption(O, Value); } - void releaseToOS() { Cache.releaseToOS(); } + void releaseToOS(ReleaseToOS ReleaseType) { Cache.releaseToOS(ReleaseType); } void disableMemoryTagging() { Cache.disableMemoryTagging(); } diff --git a/compiler-rt/lib/scudo/standalone/tracing.h b/compiler-rt/lib/scudo/standalone/tracing.h new file mode 100644 index 0000000..ac1f746 --- /dev/null +++ b/compiler-rt/lib/scudo/standalone/tracing.h @@ -0,0 +1,50 @@ +//===-- tracing.h -----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef SCUDO_TRACING_H_ +#define SCUDO_TRACING_H_ + +#if defined(SCUDO_ENABLE_TRACING) + +// This file must include definitions for all of the functions below. +#include "custom_scudo_tracing.h" + +#else + +// Should start a trace in the given scope, and end the trace when going out of +// scope. +#define SCUDO_SCOPED_TRACE(Name) + +// Create a trace name for the call to releaseToOS. +static inline const char *GetReleaseToOSTraceName(scudo::ReleaseToOS) { + return nullptr; +} + +// Create a trace name for the call to releaseToOSMaybe in the primary. +static inline const char * +GetPrimaryReleaseToOSMaybeTraceName(scudo::ReleaseToOS) { + return nullptr; +} + +static inline const char *GetPrimaryReleaseToOSTraceName(scudo::ReleaseToOS) { + return nullptr; +} + +// Create a trace name for the call to releaseToOS in the secondary. +static inline const char *GetSecondaryReleaseToOSTraceName(scudo::ReleaseToOS) { + return nullptr; +} + +// Create a trace name for the call to releaseOlderThan in the secondary. +static inline const char *GetSecondaryReleaseOlderThanTraceName() { + return nullptr; +} + +#endif + +#endif // SCUDO_TRACING_H_ diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp index 9786644..c5e12b47 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cpp @@ -281,6 +281,25 @@ TSAN_INTERCEPTOR(void, os_unfair_lock_lock, os_unfair_lock_t lock) { Acquire(thr, pc, (uptr)lock); } +// os_unfair_lock_lock_with_flags was introduced in macOS 15 +# if defined(__MAC_15_0) || defined(__IPHONE_18_0) || defined(__TVOS_18_0) || \ + defined(__VISIONOS_2_0) || defined(__WATCHOS_11_0) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunguarded-availability-new" +// We're just intercepting this - if it doesn't exist on the platform, then the +// process shouldn't have called it in the first place. +TSAN_INTERCEPTOR(void, os_unfair_lock_lock_with_flags, os_unfair_lock_t lock, + os_unfair_lock_flags_t flags) { + if (!cur_thread()->is_inited || cur_thread()->is_dead) { + return REAL(os_unfair_lock_lock_with_flags)(lock, flags); + } + SCOPED_TSAN_INTERCEPTOR(os_unfair_lock_lock_with_flags, lock, flags); + REAL(os_unfair_lock_lock_with_flags)(lock, flags); + Acquire(thr, pc, (uptr)lock); +} +# pragma clang diagnostic pop +# endif + TSAN_INTERCEPTOR(void, os_unfair_lock_lock_with_options, os_unfair_lock_t lock, u32 options) { if (!cur_thread()->is_inited || cur_thread()->is_dead) { diff --git a/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp b/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp index 43ca027..0091ebc 100644 --- a/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp +++ b/compiler-rt/test/asan/TestCases/Darwin/duplicate_os_log_reports.cpp @@ -1,5 +1,4 @@ // UNSUPPORTED: ios -// REQUIRES: shell // REQUIRES: darwin_log_cmd // RUN: %clangxx_asan -fsanitize-recover=address %s -o %t // RUN: { %env_asan_opts=halt_on_error=0,log_to_syslog=1 %run %t > %t.process_output.txt 2>&1 & } \ diff --git a/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c b/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c index 08bf5e1..5d4a812 100644 --- a/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c +++ b/compiler-rt/test/asan/TestCases/Linux/read_binary_name_regtest.c @@ -6,8 +6,7 @@ // will be unable to resolve its $ORIGIN due to readlink() restriction and will // thus fail to start, causing the test to die with SIGPIPE when attempting to // talk to it. -// RUN: not ls /usr/include/linux/seccomp.h || ( %clang_asan %s -o %t && ( not env ASAN_OPTIONS=symbolize=0 %run %t 2>&1 ) | FileCheck %s ) -// REQUIRES: shell +// RUN: not ls /usr/include/linux/seccomp.h || %clang_asan %s -o %t || not env ASAN_OPTIONS=symbolize=0 %run %t 2>&1 | FileCheck %s // UNSUPPORTED: android #include <errno.h> diff --git a/compiler-rt/test/asan/TestCases/suppressions-library.cpp b/compiler-rt/test/asan/TestCases/suppressions-library.cpp index 5427122..2da44e1 100644 --- a/compiler-rt/test/asan/TestCases/suppressions-library.cpp +++ b/compiler-rt/test/asan/TestCases/suppressions-library.cpp @@ -1,11 +1,11 @@ +// UNSUPPORTED: system-windows + // RUN: %clangxx_asan -O0 -DSHARED_LIB %s %fPIC -shared -o %dynamiclib %ld_flags_rpath_so // RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe // Check that without suppressions, we catch the issue. // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s -// REQUIRES: shell - // RUN: echo "interceptor_via_lib:"%xdynamiclib_filename > %t.supp // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s diff --git a/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp b/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp index 37c1dab..53166cc 100644 --- a/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp +++ b/compiler-rt/test/asan/TestCases/verbose-log-path_test.cpp @@ -1,9 +1,8 @@ +// UNSUPPORTED: system-windows + // RUN: rm -rf %t-dir && mkdir -p %t-dir // RUN: %clangxx_asan %s -o %t-dir/verbose-log-path_test-binary -// The glob below requires bash. -// REQUIRES: shell - // Good log_path. // RUN: rm -f %t-dir/asan.log.* // RUN: %env_asan_opts=log_path=%t-dir/asan.log:log_exe_name=1 not %run %t-dir/verbose-log-path_test-binary 2> %t.out diff --git a/compiler-rt/test/fuzzer/focus-function.test b/compiler-rt/test/fuzzer/focus-function.test index aa15692..717af0e 100644 --- a/compiler-rt/test/fuzzer/focus-function.test +++ b/compiler-rt/test/fuzzer/focus-function.test @@ -1,8 +1,7 @@ # Tests -focus_function # # TODO: don't require linux. -# Requires full shell support for the `for` loop syntax. -# REQUIRES: shell, linux +# REQUIRES: linux UNSUPPORTED: target=aarch64{{.*}} RUN: %cpp_compiler %S/OnlySomeBytesTest.cpp -o %t-exe @@ -22,9 +21,9 @@ FOCUS_F0: INFO: 0/1 inputs touch the focus function RUN: rm -rf %t-corpus RUN: mkdir %t-corpus # ABC triggers the focus function, others don't. -RUN: echo ABC$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/ABC -RUN: echo AXY$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/AXY -RUN: echo ABX$(for((i=0;i<2048;i++)); do echo -n x; done) > %t-corpus/ABX +RUN: %python -c 'print("ABC" + "x" * 2048)' > %t-corpus/ABC +RUN: %python -c 'print("AXY" + "x" * 2048)' > %t-corpus/AXY +RUN: %python -c 'print("ABX" + "x" * 2048)' > %t-corpus/ABX RUN: %run %t-exe -runs=10000 -focus_function=f0 %t-corpus 2>&1 | FileCheck %s --check-prefix=CORPUS_1_3 CORPUS_1_3: INFO: 1/3 inputs touch the focus function diff --git a/compiler-rt/test/fuzzer/sig-trap.test b/compiler-rt/test/fuzzer/sig-trap.test index 30d9d47..1672d1e 100644 --- a/compiler-rt/test/fuzzer/sig-trap.test +++ b/compiler-rt/test/fuzzer/sig-trap.test @@ -5,7 +5,7 @@ UNSUPPORTED: target={{.*windows.*}} RUN: %cpp_compiler %S/SigTrapTest.cpp -o %t RUN: not %run %t 2>&1 | FileCheck %s -CHECK: BINGO -CHECK: ERROR: libFuzzer: deadly signal +CHECK-DAG: BINGO +CHECK-DAG: ERROR: libFuzzer: deadly signal -RUN: trap "%run %t -handle_trap=0" TRAP +RUN: bash -c "trap '%run %t -handle_trap=0' TRAP" diff --git a/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp b/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp index 91acd28..b045ec7 100644 --- a/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp +++ b/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp @@ -4,7 +4,7 @@ // Android HWAsan does not support LSan. // UNSUPPORTED: android -// RUN: %clangxx_hwasan -O0 %s -o %t && HWASAN_OPTIONS=detect_leaks=1 %run %t +// RUN: %clangxx_hwasan -O0 %s -o %t && env HWASAN_OPTIONS=detect_leaks=1 %run %t #include <assert.h> #include <dlfcn.h> diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py index e2e8154..7734491 100644 --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -713,9 +713,9 @@ if config.target_os == "Linux": if config.android: return - from distutils.version import LooseVersion + from packaging.version import Version - ver = LooseVersion(ver_string) + ver = Version(ver_string) any_glibc = False for required in [ "2.19", @@ -727,7 +727,7 @@ if config.target_os == "Linux": "2.38", "2.40", ]: - if ver >= LooseVersion(required): + if ver >= Version(required): config.available_features.add("glibc-" + required) any_glibc = True if any_glibc: diff --git a/compiler-rt/test/profile/Linux/binary-id-offset.c b/compiler-rt/test/profile/Linux/binary-id-offset.c index dd4ce7d..6fc2eba 100644 --- a/compiler-rt/test/profile/Linux/binary-id-offset.c +++ b/compiler-rt/test/profile/Linux/binary-id-offset.c @@ -5,28 +5,30 @@ // (The DYN case would also apply to libraries, not explicitly tested here.) // DEFINE: %{cflags} = -// DEFINE: %{check} = ( \ -// DEFINE: %clang_profgen -fuse-ld=lld -Wl,--build-id -o %t %s %{cflags} && \ -// DEFINE: env LLVM_PROFILE_FILE=%t.profraw %run %t && \ -// DEFINE: llvm-readelf --notes %t && \ -// DEFINE: llvm-profdata show --binary-ids %t.profraw \ -// DEFINE: ) | FileCheck %s // REDEFINE: %{cflags} = -no-pie -// RUN: %{check} +// RUN: %clang_profgen -fuse-ld=lld -Wl,--build-id -o %t %s %{cflags} +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t +// RUN: llvm-readelf --notes %t > %t2 && llvm-profdata show --binary-ids %t.profraw >> %t2 && FileCheck %s < %t2 // REDEFINE: %{cflags} = -pie -fPIE -// RUN: %{check} +// RUN: %clang_profgen -fuse-ld=lld -Wl,--build-id -o %t %s %{cflags} +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t +// RUN: llvm-readelf --notes %t > %t2 && llvm-profdata show --binary-ids %t.profraw >> %t2 && FileCheck %s < %t2 // Moving the note after .bss also gives it extra LOAD segment padding, // making its memory offset different than its file offset. // RUN: echo "SECTIONS { .note.gnu.build-id : {} } INSERT AFTER .bss;" >%t.script // REDEFINE: %{cflags} = -no-pie -Wl,--script=%t.script -// RUN: %{check} +// RUN: %clang_profgen -fuse-ld=lld -Wl,--build-id -o %t %s %{cflags} +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t +// RUN: llvm-readelf --notes %t > %t2 && llvm-profdata show --binary-ids %t.profraw >> %t2 && FileCheck %s < %t2 // REDEFINE: %{cflags} = -pie -fPIE -Wl,--script=%t.script -// RUN: %{check} +// RUN: %clang_profgen -fuse-ld=lld -Wl,--build-id -o %t %s %{cflags} +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t +// RUN: llvm-readelf --notes %t > %t2 && llvm-profdata show --binary-ids %t.profraw >> %t2 && FileCheck %s < %t2 // CHECK-LABEL{LITERAL}: .note.gnu.build-id // CHECK: Build ID: [[ID:[0-9a-f]+]] diff --git a/compiler-rt/test/rtsan/unrecognized_flags.cpp b/compiler-rt/test/rtsan/unrecognized_flags.cpp index 9e44e9f..d6649db 100644 --- a/compiler-rt/test/rtsan/unrecognized_flags.cpp +++ b/compiler-rt/test/rtsan/unrecognized_flags.cpp @@ -1,5 +1,5 @@ // RUN: %clangxx -fsanitize=realtime %s -o %t -// RUN: RTSAN_OPTIONS="verbosity=1,asdf=1" %run %t 2>&1 | FileCheck %s +// RUN: env RTSAN_OPTIONS="verbosity=1,asdf=1" %run %t 2>&1 | FileCheck %s // UNSUPPORTED: ios // Intent: Make sure we are respecting some basic common flags diff --git a/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp b/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp index 9416da2..45e8ead 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/external_symbolizer_path.cpp @@ -19,8 +19,6 @@ // RUN: %env_tool_opts=external_symbolizer_path=%d/external_symbolizer_path.cpp.tmp.bin/llvm-symbolizer \ // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=NOT-FOUND -// REQUIRES: shell - // Mobile device will not have symbolizer in provided path. // UNSUPPORTED: ios, android diff --git a/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c b/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c index bf0e4e1..b8ca5c7 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c +++ b/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c @@ -2,9 +2,6 @@ // RUN: mkdir -p %t.dir // RUN: %clang %s -o %t.dir/suffix-log-path_test-binary -// The glob below requires bash. -// REQUIRES: shell - // Good log_path with suffix. // RUN: %env_tool_opts=log_path=%t.dir/sanitizer.log:log_exe_name=1:log_suffix=.txt %run %t.dir/suffix-log-path_test-binary 2> %t.out // RUN: FileCheck %s < %t.dir/sanitizer.log.suffix-log-path_test-binary.*.txt diff --git a/compiler-rt/test/tsan/Darwin/os_unfair_lock.c b/compiler-rt/test/tsan/Darwin/os_unfair_lock.c index 320e7f5..e2a491a 100644 --- a/compiler-rt/test/tsan/Darwin/os_unfair_lock.c +++ b/compiler-rt/test/tsan/Darwin/os_unfair_lock.c @@ -1,12 +1,14 @@ // RUN: %clang_tsan %s -o %t // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer' +#include <Availability.h> #include <os/lock.h> #include <pthread.h> #include <stdio.h> long global_variable; os_unfair_lock lock = OS_UNFAIR_LOCK_INIT; +char flags_available = 0; void *Thread(void *a) { os_unfair_lock_lock(&lock); @@ -15,6 +17,22 @@ void *Thread(void *a) { return NULL; } +void *ThreadWithFlags(void *a) { +#if defined(__MAC_15_0) || defined(__IPHONE_18_0) || defined(__TVOS_18_0) || \ + defined(__VISIONOS_2_0) || defined(__WATCHOS_11_0) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunguarded-availability-new" + os_unfair_lock_lock_with_flags(&lock, OS_UNFAIR_LOCK_FLAG_ADAPTIVE_SPIN); + flags_available = 1; +# pragma clang diagnostic pop +#else + os_unfair_lock_lock(&lock); +#endif + global_variable++; + os_unfair_lock_unlock(&lock); + return NULL; +} + int main() { pthread_t t1, t2; global_variable = 0; @@ -23,6 +41,16 @@ int main() { pthread_join(t1, NULL); pthread_join(t2, NULL); fprintf(stderr, "global_variable = %ld\n", global_variable); + + // CHECK: global_variable = 2 + + pthread_create(&t1, NULL, ThreadWithFlags, NULL); + pthread_create(&t2, NULL, ThreadWithFlags, NULL); + pthread_join(t1, NULL); + pthread_join(t2, NULL); + fprintf(stderr, + "global_variable = %ld, os_unfair_lock_lock_with_flags %savailable\n", + global_variable, flags_available ? "" : "un"); } -// CHECK: global_variable = 2 +// CHECK: global_variable = 4 diff --git a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp index 527bd85..c613317 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/coverage-levels.cpp @@ -1,7 +1,6 @@ // Test various levels of coverage // -// FIXME: Port the environment variable logic below for the lit shell. -// REQUIRES: shell +// UNSUPPORTED: system-windows // // RUN: rm -rf %t-dir && mkdir %t-dir // RUN: %clangxx -fsanitize=shift -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=func,trace-pc-guard %s -o %t diff --git a/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp b/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp index ffd95a5..4773884 100644 --- a/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/log-path_test.cpp @@ -1,9 +1,8 @@ +// UNSUPPORTED: system-windows + // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 // XFAIL: android -// The globs below do not work in the lit shell. -// REQUIRES: shell - // RUN: %clangxx -fsanitize=undefined %s -O1 -o %t // Regular run. @@ -38,4 +37,3 @@ int main(int argc, char *argv[]) { } // CHECK-ERROR: runtime error: -4 is outside the range of representable values of type 'unsigned int' - diff --git a/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp b/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp index 9567269..5326d83 100644 --- a/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp +++ b/compiler-rt/test/xray/TestCases/Posix/dlopen.cpp @@ -5,7 +5,7 @@ // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so // RUN: %clangxx_xray -g -fPIC -rdynamic -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp -o %t/main.o // -// RUN: XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlib.so 2>&1 | FileCheck %s +// RUN: env XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlib.so 2>&1 | FileCheck %s // REQUIRES: target={{(aarch64|x86_64)-.*}} diff --git a/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp b/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp index 82cc127..3b45643 100644 --- a/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp +++ b/compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp @@ -15,7 +15,7 @@ // Executable links with a and b explicitly and loads d and e at runtime. // RUN: %clangxx_xray -g -fPIC -rdynamic -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testliba.so %t/testlibb.so -o %t/main.o // -// RUN: XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlibd.so %t/testlibe.so 2>&1 | FileCheck %s +// RUN: env XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlibd.so %t/testlibe.so 2>&1 | FileCheck %s // REQUIRES: target={{(aarch64|x86_64)-.*}} diff --git a/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp b/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp index 7bce653..5014fce 100644 --- a/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp +++ b/compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp @@ -4,7 +4,7 @@ // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testlib.so -Wl,-rpath,%t -o %t/main.o -// RUN: XRAY_OPTIONS="patch_premain=true,verbosity=1" %run %t/main.o 2>&1 | FileCheck %s +// RUN: env XRAY_OPTIONS="patch_premain=true,verbosity=1" %run %t/main.o 2>&1 | FileCheck %s // REQUIRES: target={{(aarch64|x86_64)-.*}} diff --git a/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp b/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp index 640cf9b..9b3f63b5 100644 --- a/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp +++ b/compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp @@ -6,7 +6,7 @@ // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -shared -std=c++11 %t/testlib.cpp -o %t/testlib.so // RUN: %clangxx_xray -g -fPIC -fxray-instrument -fxray-shared -std=c++11 %t/main.cpp %t/testlib.so -Wl,-rpath,%t -o %t/main.o -// RUN: XRAY_OPTIONS="patch_premain=false" %run %t/main.o 2>&1 | FileCheck %s +// RUN: env XRAY_OPTIONS="patch_premain=false" %run %t/main.o 2>&1 | FileCheck %s // REQUIRES: target={{(aarch64|x86_64)-.*}} |