Commit Graph

15901 Commits

Author SHA1 Message Date
Phoebe Wang b17c89d151 Revert "[compiler-rt] [builtins] Detect _Float16 support at compile time"
This reverts commit ce6d40f5c2.

Revert due to it broke the sanitizer-windows buildbot: https://lab.llvm.org/buildbot/#/builders/127/builds/33583/steps/4/logs/stdio
2022-07-30 09:41:33 +08:00
Dimitry Andric ce6d40f5c2 [compiler-rt] [builtins] Detect _Float16 support at compile time
Instead of detecting `_Float16` support at CMake configuration time,
detect it at compile time by checking for the predefined (by the
compiler) macro `__FLT16_MAX__` instead.

This solves the issue where compiler-rt is built simultaneously for both
x86_64 and i386 targets, and the CMake configuration uses x86_64
compilation to detect `_Float16` support, while it may not be supported
by the i386 target (if it does not have SSE2).

While here, rename `COMPILERT_RT_HAS_FLOAT16` to `CRT_HAS_FLOAT16`, to
conform more to the naming style used in `int_lib.h` and `int_types.h`.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D130718
2022-07-29 20:58:52 +02:00
Blue Gaston cea1b790f6 [TSan][Darwin] Additional TSAN test requiring weak symbol for dyld64
Tests require a weak symbol for dyld weak-def coalescing.

Differential Revision: https://reviews.llvm.org/D130732

Adding additional weak attribute
2022-07-29 11:24:40 -07:00
Luís Marques a0f1304616 [compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt tests, fixes test__extendhfsf2
Since D92241, compiler-rt/cmake/builtin-config-ix.cmake automatically tests
the host compiler for support of _Float16 and conditionally defines
COMPILER_RT_HAS_FLOAT16. That defines the macro while the compiler-rt
builtins are being built. To also define it during the compiler-rt test
runs requires whitelisting the architecture in
compiler-rt/test/builtins/CMakeLists.txt, as done in this patch. That seems
brittle. Ideally, we'd move to a solution where the target compiler was
automatically tested as well, but I'm not sure how feasible that is with the
current CMake setup.

For now, this patch whitelists RISC-V, fixing errors in test__extendhfsf2.
Alternate solutions that fix the root issue are welcome, though.

Differential Revision: https://reviews.llvm.org/D129432
2022-07-29 13:27:44 +02:00
Luís Marques 5bc19fe8f6 Revert "[compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt tests, fixes test__extendhfsf2"
This reverts commit 55920d9282.
2022-07-29 13:25:53 +02:00
Luís Marques 55920d9282 [compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt tests, fixes test__extendhfsf2
Since D92241, compiler-rt/cmake/builtin-config-ix.cmake automatically tests
the host compiler for support of _Float16 and conditionally defines
COMPILER_RT_HAS_FLOAT16. That defines the macro while the compiler-rt
builtins are being built. To also define it during the compiler-rt test
runs requires whitelisting the architecture in
compiler-rt/test/builtins/CMakeLists.txt, as done in this patch. That seems
brittle. Ideally, we'd move to a solution where the target compiler was
automatically tested as well, but I'm not sure how feasible that is with the
current CMake setup.

For now, this patch whitelists RISC-V, fixing errors in test__extendhfsf2.
Alternate solutions that fix the root issue are welcome, though.

Differential Revision: https://reviews.llvm.org/D129432
2022-07-29 13:24:29 +02:00
Rainer Orth 0b2d5fd48b [compiler-rt][Sanitizer] Link sanitizer libs with -latomic on SPARC
When building on Linux/sparc64, the 32-bit `libclang_rt.asan.so`,
`libclang_rt.ubsan_minimal.so`, and `libclang_rt.ubsan_standalone.so`
failed to link with undefined references to 64-bit atomics, which `clang`
cannot inline.  Even D130569 <https://reviews.llvm.org/D130569> didn't help
because those libraries are linked with `-nodefaultlibs`, so dependent
libraries need to be added explicitly.

That's what this patch does.

Tested on `sparc64-unknown-linux-gnu` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D130571
2022-07-27 12:30:18 +02:00
Blue Gaston a89982c40d [Sanitizers][Darwin] Allows '-mtargetos' to used to set minimum deployment target.
Currently, m{platform}-version-min is default flag used to set min deployment target within compilter-rt and sanitizers.
However, clang uses flags -target and -mtargetos for setting target triple and minimum deployment targets.
-mtargetos will be the preferred flag to set min version in the future and the
${platform}-version-min flag will not be used for future platforms.

This change allows darwin platforms to use either ${platform}-min-version or -mtargetos
without breaking lit test flags that allows for overriding the default min value in lit tests
Tests using flags: 'darwin_min_target_with_tls_support', 'min_macos_deployment_target'
will no longer fail if they use mtargetos instead of version-min.

rdar://81028225

Differential Revision: https://reviews.llvm.org/D130542
2022-07-26 11:25:49 -07:00
Than McIntosh b6374437af tsan: capture shadow map start/end on init and reuse in reset
Capture the computed shadow begin/end values at the point where the
shadow is first created and reuse those values on reset. Introduce new
windows-specific function "ZeroMmapFixedRegion" for zeroing out an
address space region previously returned by one of the MmapFixed*
routines; call this function (on windows) from DoResetImpl
tsan_rtl.cpp instead of MmapFixedSuperNoReserve.

See https://github.com/golang/go/issues/53539#issuecomment-1168778740
for context; intended to help with updating the syso for Go's
windows/amd64 race detector.

Differential Revision: https://reviews.llvm.org/D128909
2022-07-26 10:04:39 -04:00
Shafik Yaghmour aea82d4551 [Clang] Fix how we set the NumPositiveBits on an EnumDecl to cover the case of single enumerator with value zero or an empty enum
Currently in Sema::ActOnEnumBody(...) when calculating NumPositiveBits we miss
the case where there is only a single enumerator with value zero and the case of
an empty enum. In both cases we end up with zero positive bits when in fact we
need one bit to store the value zero.

This PR updates the calculation to account for these cases.

Differential Revision: https://reviews.llvm.org/D130301
2022-07-25 16:01:01 -07:00
Roy Sundahl 1850a7a9ca [asan][test] Additional test requiring weak symbol for dyld64.
Extension of D127929

rdar://80997227

Differential Revision: https://reviews.llvm.org/D130499
2022-07-25 13:56:02 -07:00
Dmitry Vyukov 7ec308715c tsan: prevent pathological slowdown for spurious races
Prevent the following pathological behavior:
Since memory access handling is not synchronized with DoReset,
a thread running concurrently with DoReset can leave a bogus shadow value
that will be later falsely detected as a race. For such false races
RestoreStack will return false and we will not report it.
However, consider that a thread leaves a whole lot of such bogus values
and these values are later read by a whole lot of threads.
This will cause massive amounts of ReportRace calls and lots of
serialization. In very pathological cases the resulting slowdown
can be >100x. This is very unlikely, but it was presumably observed
in practice: https://github.com/google/sanitizers/issues/1552
If this happens, previous access sid+epoch will be the same for all of
these false races b/c if the thread will try to increment epoch, it will
notice that DoReset has happened and will stop producing bogus shadow
values. So, last_spurious_race is used to remember the last sid+epoch
for which RestoreStack returned false. Then it is used to filter out
races with the same sid+epoch very early and quickly.
It is of course possible that multiple threads left multiple bogus shadow
values and all of them are read by lots of threads at the same time.
In such case last_spurious_race will only be able to deduplicate a few
races from one thread, then few from another and so on. An alternative
would be to hold an array of such sid+epoch, but we consider such scenario
as even less likely.
Note: this can lead to some rare false negatives as well:
1. When a legit access with the same sid+epoch participates in a race
as the "previous" memory access, it will be wrongly filtered out.
2. When RestoreStack returns false for a legit memory access because it
was already evicted from the thread trace, we will still remember it in
last_spurious_race. Then if there is another racing memory access from
the same thread that happened in the same epoch, but was stored in the
next thread trace part (which is still preserved in the thread trace),
we will also wrongly filter it out while RestoreStack would actually
succeed for that second memory access.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D130269
2022-07-25 10:40:11 +02:00
Dmitry Vyukov 7505cc301f tsan: remove tracking of racy addresses
We used to deduplicate based on the race address to prevent lots
of repeated reports about the same race.

But now we clear the shadow for the racy address in DoReportRace:

  // This prevents trapping on this address in future.
  for (uptr i = 0; i < kShadowCnt; i++)
    StoreShadow(&shadow_mem[i], i == 0 ? Shadow::kRodata : Shadow::kEmpty);

It should have the same effect of not reporting duplicates
(and actually better because it's automatically reset when the memory is reallocated).

So drop the address deduplication code. Both simpler and faster.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D130240
2022-07-25 10:33:26 +02:00
Khem Raj 8f24a56a3a [compiler-rt][CMake] Enable TF intrinsics on powerpc32 Linux
clang generates calls to these intrinsics when used for ppc32/linux, when using libgcc this works ok but when using compiler-rt for rtlib it fails with missing intrinsic symbols. also see [1]

[1] https://lists.llvm.org/pipermail/llvm-dev/2014-May/072784.html

Reviewed By: MaskRay, glaubitz

Differential Revision: https://reviews.llvm.org/D121379
2022-07-24 10:17:22 -07:00
Dimitrije Milosevic 2bfb0fcb51 [MIPS][compiler-rt] Fix stat struct's size for O32 ABI
Add the MIPS O32 ABI value for the stat struct's size.

Differential Revision: https://reviews.llvm.org/D129749.
2022-07-23 11:53:00 +02:00
Ivan Trofimov 15e9b1d0c0 [libasan] Remove 4Mb stack limit for swapcontext unpoisoning
Reviewed By: vitalybuka, eugenis

Differential Revision: https://reviews.llvm.org/D129219
2022-07-22 17:37:44 -07:00
Vitaly Buka c93e4b6b2c [asan] Reset stack bounds of context
ClearShadowMemoryForContextStack assumes that context contains the stack
bounds. This is not true for a context from getcontext or oucp of
swapcontext.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D130218
2022-07-22 13:40:16 -07:00
Julian Lettner 2f46983981 [Sanitizer][Darwin] Factor out code for GCD worker registration
This is a NFC change to factor out GCD worker thread registration via
the pthread introspection hook.

In a follow-up change we also want to register GCD workers for ASan to
make sure threads are registered before we attempt to print reports on
them.

rdar://93276353

Differential Revision: https://reviews.llvm.org/D126351
2022-07-22 13:29:28 -07:00
Aaron Ballman 7068aa9841 Strengthen -Wint-conversion to default to an error
Clang has traditionally allowed C programs to implicitly convert
integers to pointers and pointers to integers, despite it not being
valid to do so except under special circumstances (like converting the
integer 0, which is the null pointer constant, to a pointer). In C89,
this would result in undefined behavior per 3.3.4, and in C99 this rule
was strengthened to be a constraint violation instead. Constraint
violations are most often handled as an error.

This patch changes the warning to default to an error in all C modes
(it is already an error in C++). This gives us better security posture
by calling out potential programmer mistakes in code but still allows
users who need this behavior to use -Wno-error=int-conversion to retain
the warning behavior, or -Wno-int-conversion to silence the diagnostic
entirely.

Differential Revision: https://reviews.llvm.org/D129881
2022-07-22 15:24:54 -04:00
tlattner 44f81dfba4 Remove references to old mailing lists that have moved to discourse. Replace with links to discourse.
Reviewed By: #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D129675
2022-07-22 09:59:03 -07:00
Dmitry Vyukov b988d8ddc2 tsan: remove unnecessary brackets
Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D130236
2022-07-21 12:11:44 +02:00
Rainer Orth 3776db9a4f [sanitizer_common] Support Solaris < 11.4 in GetStaticTlsBoundary
This patch, on top of D120048 <https://reviews.llvm.org/D120048>, supports
GetTls on Solaris 11.3 and Illumos that lack `dlpi_tls_modid`.  It's the
same method originally used in D91605 <https://reviews.llvm.org/D91605>,
but integrated into `GetStaticTlsBoundary`.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D120059
2022-07-21 09:18:10 +02:00
Ian Anderson 28800c2e18 [sanitizer] Use consistent checks for XDR
sanitizer_platform_limits_posix.h defines `__sanitizer_XDR ` if `SANITIZER_LINUX && !SANITIZER_ANDROID`, but sanitizer_platform_limits_posix.cpp tries to check it if `HAVE_RPC_XDR_H`. This coincidentally works because macOS has a broken <rpc/xdr.h> which causes `HAVE_RPC_XDR_H` to be 0, but if <rpc/xdr.h> is fixed then clang fails to compile on macOS. Restore the platform checks so that <rpc/xdr.h> can be fixed on macOS.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130060
2022-07-20 22:28:07 -07:00
Xi Ruoyao bba1f26f2e Port address sanitizer to LoongArch
Depends on D129371.

It survived all GCC ASan tests.

Changes are trivial and mostly "borrowed" RISC-V logics, except that a different SHADOW_OFFSET is used.

Reviewed By: SixWeining, MaskRay, XiaodongLoong

Differential Revision: https://reviews.llvm.org/D129418
2022-07-21 11:32:21 +08:00
Vitaly Buka 82995e0e82 [NFC][asan] Clang-format a code 2022-07-20 18:57:37 -07:00
Vitaly Buka e8554402b3 [NFC][memprof] Remove unused code 2022-07-20 18:50:45 -07:00
Vitaly Buka 26a7ee3d54 [NFC][asan] Use RoundDownTo 2022-07-20 18:50:44 -07:00
Xi Ruoyao dbec35ccf8 [sanitizer] Port sanitizer_common to LoongArch
Initial libsanitizer support for LoongArch. It survived all GCC UBSan tests.

Major changes:

1. LoongArch port of Linux kernel only supports `statx` for `stat` and its families.  So we need to add `statx_to_stat` and use it for `stat`-like libcalls.  The logic is "borrowed" from Glibc.
2. `sanitizer_syscall_linux_loongarch64.inc` is mostly duplicated from RISC-V port, as the syscall interface is almost same.

Reviewed By: SixWeining, MaskRay, XiaodongLoong, vitalybuka

Differential Revision: https://reviews.llvm.org/D129371
2022-07-20 00:58:40 -07:00
Vitaly Buka 868e1ee1d0 Revert "[libasan] Remove 4Mb stack limit for swapcontext unpoisoning"
This patches exposed existing incorectness of swapcontext imlementation.
swapcontext does not set oucp->uc_stack. Unpoisoning works if ucp is
from makecontext, but may try to use garbage pointers if it's from
previos swapcontext or from getcontext. Existing limit reduces
probability of garbage pointers are used.

I restore behavour which we had for years, and will look to improve
swapcontext support.

This reverts commit d0751c9725.
2022-07-19 21:40:19 -07:00
Kamau Bridgeman 2a408f200c [TSAN] Disable clone_setns test case on PPC64 RHEL 7.9 Targets
The compler-rt test case tsan/Linux/clone_setns.cpp fails on
PowerPC64 RHEL 7.9 targets.
Unshare fails with errno code EINVAL.
It is unclear why this happens specifically on RHEL 7.9 and no other
operating system like Ubuntu 18 or RHEL 8.4 for example.
This patch uses marcos to disable the test case for ppc64 rhel7.9
because there are no XFAIL directives to target rhel 7.9 specifically.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D130086
2022-07-19 13:25:21 -05:00
Louis Dionne 7300a651f5 [libc++] Re-apply "Always build c++experimental.a""
This re-applies bb939931a1, which had been reverted by 09cebfb978
because it broke Chromium. The issues seen by Chromium should be
addressed by 1d0f79558c.

Differential Revision: https://reviews.llvm.org/D128927
2022-07-19 10:44:19 -04:00
Andrew Turner 1b2fa907d7 Add the FreeBSD AArch64 memory layout
Use the FreeBSD AArch64 memory layout values when building for it.
These are based on the x86_64 values, scaled to take into account the
larger address space on AArch64.

Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D125758
2022-07-19 09:58:04 -04:00
Dmitry Vyukov 6d1f86095d tsan: optimize DenseSlabAlloc
If lots of threads do lots of malloc/free and they overflow
per-pthread DenseSlabAlloc cache, it causes lots of contention:

  31.97%  race.old  race.old            [.] __sanitizer::StaticSpinMutex::LockSlow
  17.61%  race.old  race.old            [.] __tsan_read4
  10.77%  race.old  race.old            [.] __tsan::SlotLock

Optimize DenseSlabAlloc to use a lock-free stack of batches of nodes.
This way we don't take any locks in steady state at all and do only
1 push/pop per Refill/Drain.

Effect on the added benchmark:

$ TIME="%e %U %S %M" time ./test.old 36 5 2000000
34.51 978.22 175.67 5833592
32.53 891.73 167.03 5790036
36.17 1005.54 201.24 5802828
36.94 1004.76 226.58 5803188

$ TIME="%e %U %S %M" time ./test.new 36 5 2000000
26.44 720.99 13.45 5750704
25.92 721.98 13.58 5767764
26.33 725.15 13.41 5777936
25.93 713.49 13.41 5791796

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D130002
2022-07-19 15:42:57 +02:00
serge-sans-paille eb0e3319bf [sanitizer] Don't call dlerror() after swift_demangle lookup through dlsym
Because the call to `dlerror()` may actually want to print something, which turns into a deadlock
as showcased in #49223.

Instead rely on further call to dlsym to clear `dlerror` internal state if they
need to check the return status.

Differential Revision: https://reviews.llvm.org/D128992
2022-07-19 09:07:30 +02:00
Ellis Hoag 3580daacf3 [InstrProf] Allow CSIRPGO function entry coverage
The flag `-fcs-profile-generate` for enabling CSIRPGO moves the pass
`pgo-instrumentation` after inlining. Function entry coverage works fine
with this change, so remove the assert. I had originally left this
assert in because I had not tested this at the time.

Reviewed By: davidxl, MaskRay

Differential Revision: https://reviews.llvm.org/D129407
2022-07-18 15:10:11 -07:00
Hans Wennborg 09cebfb978 Revert "[libc++] Always build c++experimental.a"
This caused build failures when building Clang and libc++ together on Mac:

  fatal error: 'experimental/memory_resource' file not found

See the code review for details. Reverting until the problem and how to
solve it is better understood.

(Updates to some test files were not reverted, since they seemed
unrelated and were later updated by 340b48b267b96.)

> This is the first part of a plan to ship experimental features
> by default while guarding them behind a compiler flag to avoid
> users accidentally depending on them. Subsequent patches will
> also encompass incomplete features (such as <format> and <ranges>)
> in that categorization. Basically, the idea is that we always
> build and ship the c++experimental library, however users can't
> use what's in it unless they pass the `-funstable` flag to Clang.
>
> Note that this patch intentionally does not start guarding
> existing <experimental/FOO> content behind the flag, because
> that would merely break users that might be relying on such
> content being in the headers unconditionally. Instead, we
> should start guarding new TSes behind the flag, and get rid
> of the existing TSes we have by shipping their Standard
> counterpart.
>
> Also, this patch must jump through a few hoops like defining
> _LIBCPP_ENABLE_EXPERIMENTAL because we still support compilers
> that do not implement -funstable yet.
>
> Differential Revision: https://reviews.llvm.org/D128927

This reverts commit bb939931a1.
2022-07-18 16:57:15 +02:00
Fangrui Song a1b8d9fb75 [test] Change -lowertypetests tests to use -passes= 2022-07-17 21:33:02 -07:00
Xi Ruoyao 36b52c38aa [sanitizer] Compare against the alignment of the latter range trying to find consecutive TLS blocks in GetStaticTlsBoundary
On a mips64el-linux-gnu system, the dynamic linker arranges TLS blocks
like:

    [0] 0xfff7fe9680..0xfff7fe9684, align = 0x4
    [1] 0xfff7fe9688..0xfff7fe96a8, align = 0x8
    [2] 0xfff7fe96c0..0xfff7fe9e60, align = 0x40
    [3] 0xfff7fe9e60..0xfff7fe9ef8, align = 0x8

Note that the dynamic linker can only put [1] at 0xfff7fe9688, not
0xfff7fe9684 or it will be misaligned.  But we were comparing the
distance between two blocks with the alignment of the previous range,
causing GetStaticTlsBoundary fail to merge the consecutive blocks.

Compare against the alignment of the latter range to fix the issue.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D129112
2022-07-17 00:45:15 -07:00
Rainer Orth 74f6672e59 [sanitizer_common] Several Solaris procmaps fixes
Since the introduction of GoogleTest sharding in D122251
<https://reviews.llvm.org/D122251>, some of the Solaris sanitizer tests
have been running extremly long (up to an hour) while they took mere
seconds before.  Initial investigation suggests that massive lock
contention in Solaris procfs is involved here.

However, there's an easy way to somewhat reduce the impact: while the
current `ReadProcMaps` uses `ReadFileToBuffer` to read `/proc/self/xmap`,
that function primarily caters to Linux procfs reporting file sizes of 0
while the size on Solaris is accurate.  This patch makes use of that,
reducing the number of syscalls involved and reducing the runtime of
affected tests by a factor of 4.

Besides, it handles shared mappings and doesn't call `readlink` for unnamed
map entries.

Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D129837
2022-07-16 06:59:00 +02:00
Julian Lettner 32a425ec0c [Sanitizer][Darwin][NFC] Small SANITIZER_APPLE cleanup
We introduced `SANITIZER_APPLE` here: https://reviews.llvm.org/D126263
2022-07-15 16:31:35 -07:00
Leonard Grey 1231a2cec0 [lsan][Darwin][nfc] Fix thread vector size
The reserve constructor was removed in 44f55509d7
but this one was missed. As a result, we attempt to iterate through 1024 threads
each time, most of which are 0.

Differential Revision: https://reviews.llvm.org/D129897
2022-07-15 17:34:29 -04:00
Leonard Grey b15cf06fb3 [lsan][nfc] Add missing newline to VReport 2022-07-15 15:44:23 -04:00
Petr Hosek cae5462a2c [compiler-rt][CMake] Set unwinder for MSan unittests
This addresses an issue introduced by 6699f55488.
2022-07-15 08:11:59 +00:00
Petr Hosek 6699f55488 [compiler-rt][CMake] Set --unwindlib=none when using LLVM libunwind
We already link libunwind explicitly so avoid trying to link toolchain's
default libunwind which may be missing. This matches what we already do
for libcxx and libcxxabi.

Differential Revision: https://reviews.llvm.org/D129472
2022-07-15 07:25:38 +00:00
Kostya Serebryany ef0081d608 [SanitizerCoverage] add weak definitions for the load/store callbacks.
Add weak definitions for the load/store callbacks.

This matches the weak definitions for all other SanitizerCoverage
callbacks.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D129801
2022-07-14 20:26:41 -07:00
Petr Hosek 2da550140a [compiler-rt][CMake] Use linker semantics for unwinder and C++ library
Try the shared library first, and if it doesn't exist fallback onto
the static one. When the static library is requested, skip the shared
library.

Differential Revision: https://reviews.llvm.org/D129470
2022-07-14 21:12:36 +00:00
Ellis Hoag af58684f27 [InstrProf] Add options to profile function groups
Add two options, `-fprofile-function-groups=N` and `-fprofile-selected-function-group=i` used to partition functions into `N` groups and only instrument the functions in group `i`. Similar options were added to xray in https://reviews.llvm.org/D87953 and the goal is the same; to reduce instrumented size overhead by spreading the overhead across multiple builds. Raw profiles from different groups can be added like normal using the `llvm-profdata merge` command.

Reviewed By: ianlevesque

Differential Revision: https://reviews.llvm.org/D129594
2022-07-14 11:41:30 -07:00
Vitaly Buka bb4d974135 [NFC] Clang-format D129645 2022-07-14 10:27:04 -07:00
Dmitry Vyukov ab02680b5a tsan: fix a bug in trace part switching
Callers of TraceSwitchPart expect that TraceAcquire will always succeed
after the call. It's possible that TryTraceFunc/TraceMutexLock in TraceSwitchPart
that restore the current stack/mutexset filled the trace part exactly up
to the TracePart::kAlignment gap and the next TraceAcquire won't succeed.
Skip the alignment gap after writing initial stack/mutexset to avoid that.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D129777
2022-07-14 17:49:00 +02:00
Alexander Potapenko b191056f44 [compiler-rt][hwasan] Support for new Intel LAM API
New version of Intel LAM patches
(https://lore.kernel.org/linux-mm/20220712231328.5294-1-kirill.shutemov@linux.intel.com/)
uses a different interface based on arch_prctl():
 - arch_prctl(ARCH_GET_UNTAG_MASK, &mask) returns the current mask for
   untagging the pointers. We use it to detect kernel LAM support.
 - arch_prctl(ARCH_ENABLE_TAGGED_ADDR, nr_bits) enables pointer tagging
   for the current process.

Because __NR_arch_prctl is defined in different headers, and no other
platforms need it at the moment, we only declare internal_arch_prctl()
on x86_64.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D129645
2022-07-13 19:11:13 -07:00