Commit Graph

15901 Commits

Author SHA1 Message Date
Matthias Braun 2030e6496a Avoid ar_to_bc.sh script in symbolizer build; add -ignore-non-bitcode flag to llvm-link
Remove the `ar_to_bc.sh` helper script in the compiler-rt symbolizer
build. Instead use `llvm-link` directly as D81109 introduced the
capability to read archives. I just needed to add a new flag
`-ignore-non-bitcode` to avoid `llvm-link` aborting when it found a
non-bitcode file in the archive.

Differential Revision: https://reviews.llvm.org/D128729
2022-06-28 14:49:35 -07:00
Ben Langmuir eab2a06f0f Revert "Reland "[X86] Support `_Float16` on SSE2 and up""
Broke compiler-rt on Darwin: https://green.lab.llvm.org/green/job/clang-stage1-RA/29920/

This reverts commit 527ef8ca98.
2022-06-28 10:59:03 -07:00
Phoebe Wang 527ef8ca98 Reland "[X86] Support `_Float16` on SSE2 and up"
Enable `COMPILER_RT_HAS_FLOAT16` to solve the lit fail.

This is split from D113107 to address #56204 and https://discourse.llvm.org/t/how-to-build-compiler-rt-for-new-x86-half-float-abi/63366

Reviewed By: zahiraam, rjmccall, bkramer

Differential Revision: https://reviews.llvm.org/D128571
2022-06-28 14:38:56 +08:00
Mitch Phillips ca479dac51 Mark ASan global-location-nodebug test as unspported on win.
Windows linkers don't have the easy reachable `-Wl,-S` option to strip
the binary. Disable the test for now.
2022-06-27 16:03:32 -07:00
Mitch Phillips 7b23552779 Fix-forward ASan on Windows.
D127911 deleted llvm.asan.globals. This had a side effect that we no
longer generated the `name` field for the `__asan_global` descriptor
from clang's decscription of the name, but the demangled name from the
LLVM IR. On Linux, this is the same as the clang-provided name. On
Windows, this includes the type, as the name in the IR is the mangled
name.

Attempt #1 to fix-forward the Windows bots by making the tests glob both
sides of the global name, thereby allowing types in the descriptor name.
2022-06-27 15:53:30 -07:00
Mitch Phillips dacfa24f75 Delete 'llvm.asan.globals' for global metadata.
Now that we have the sanitizer metadata that is actually on the global
variable, and now that we use debuginfo in order to do symbolization of
globals, we can delete the 'llvm.asan.globals' IR synthesis.

This patch deletes the 'location' part of the __asan_global that's
embedded in the binary as well, because it's unnecessary. This saves
about ~1.7% of the optimised non-debug with-asserts clang binary.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127911
2022-06-27 14:40:40 -07:00
Julian Lettner 62a71cc5ef [Sanitizer][Darwin] Mark test UNSUPPORTED instead of XFAIL
This is test is failing/passing depending on the host OS version.  Need
to investigate/fix before re-enabling.

rdar://95982696
2022-06-27 14:18:36 -07:00
Julian Lettner 1bdbf13746 [Sanitizer][Darwin] atos does not show line numbers for globals
atos does not show line numbers for globals and will probably not
support this anytime soon.  Mark test UNSUPPORTED instead of XFAIL.
2022-06-27 13:58:12 -07:00
Roy Sundahl d2dad6287c Add wait for child processe(s) to exit. (amended+clang-formatted)
It was possible for the parent process to exit before the
forked child process had finished. In some shells, this
causes the pipe to close and FileCheck misses some output
from the child. Waiting for the child process to exit before
exiting the parent, assures that all output from stdout and
stderr is combined and forwarded through the pipe to FileCheck.

rdar://95241490

Differential Revision: https://reviews.llvm.org/D128565
2022-06-27 13:09:34 -07:00
Vitaly Buka 11b414463d [test] Add workaround for flaky error we see on Windows bots 2022-06-27 12:37:44 -07:00
Than McIntosh 13fb97d688 tsan: add missing guard for DumpProcessMap call
Add a missing "#if !SANITIZER_GO" guard for a call to DumpProcessMap
in the Finalize hook (needed to build an updated Go race detector syso
image).

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D128641
2022-06-27 10:10:45 -04:00
Rainer Orth b4ae67fffa [asan][test] XFAIL global-location-nodebug.cpp on Solaris
A new test `FAIL`s on Solaris:

  FAIL: AddressSanitizer-i386-sunos ::
TestCases/global-location-nodebug.cpp (465 of 64279)
  FAIL: AddressSanitizer-i386-sunos-dynamic ::
TestCases/global-location-nodebug.cpp (961 of 64279)

The problem is the unconditional use of `-Wl,-S`:

  ld: fatal: dlopen() of support library (-lstdc++) failed with error:
ld.so.1: ld: -lstdc++: open failed: No such file or directory

`ld -S` has a completely different semantics compared to GNU `ld
-S`/`--strip-debug`: specify a link-edit support library.  To avoid this,
I've chosen to `XFAIL` the test.

Tested on `amd64-pc-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D128516
2022-06-25 10:40:11 +02:00
Petr Hosek f3caa98e49 Revert "[CMake][compiler-rt] Clean up the use of libcxx and libcxxabi"
This reverts commit 4164cfa537 since
it broke the clang-x86_64-debian-fast builder:

  https://lab.llvm.org/buildbot/#/builders/109/builds/41339
2022-06-25 03:10:55 +00:00
Petr Hosek 4164cfa537 [CMake][compiler-rt] Clean up the use of libcxx and libcxxabi
We no longer support the use of LLVM_ENABLE_PROJECTS for libcxx and
libcxxabi. We don't use paths to libcxx and libcxxabi in compiler-rt.

Differential Revision: https://reviews.llvm.org/D126905
2022-06-25 02:53:43 +00:00
Petr Hosek 72ec31afad [CMake] Use set rather than list PREPEND
list PREPEND is only supported since CMake 3.15.

Differential Revision: https://reviews.llvm.org/D128548
2022-06-25 02:19:55 +00:00
Petr Hosek 048e6bb46b [CMake][compiler-rt] Treat target cflags as list rather than string
This is need after 30dfe016d4.

Differential Revision: https://reviews.llvm.org/D128548
2022-06-24 22:37:00 +00:00
Mitch Phillips faf5e0ec73 Add no_sanitize('hwaddress') (and 'memtag', but that's a no-op).
Currently, `__attribute__((no_sanitize('hwaddress')))` is not possible. Add this piece of plumbing, and now that we properly support copying attributes between an old and a new global variable, add a regression test for the GlobalOpt bug that previously lost the attribute.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D127544
2022-06-24 12:04:11 -07:00
Kai Luo acc22aeb0f [AIX][libatomic] Fix link flags after 30dfe016d4 for libatomic on AIX
After 30dfe016d4, we no longer use string as link flags.

Patch by @tingwang.

Reviewed By: tingwang

Differential Revision: https://reviews.llvm.org/D128524
2022-06-24 13:56:32 +00:00
Petr Hosek 8bee6e52f8 Revert "[CMake][compiler-rt] Clean up the use of libcxx and libcxxabi"
This reverts commit c0d4f2282d which
broke clang-x86_64-debian-fast:

  https://lab.llvm.org/buildbot/#/builders/109/builds/41268
2022-06-24 08:24:45 +00:00
Petr Hosek c0d4f2282d [CMake][compiler-rt] Clean up the use of libcxx and libcxxabi
We no longer support the use of LLVM_ENABLE_PROJECTS for libcxx and
libcxxabi. We don't use paths to libcxx and libcxxabi in compiler-rt.

Differential Revision: https://reviews.llvm.org/D126905
2022-06-24 08:11:37 +00:00
Petr Hosek 30dfe016d4 [CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS
This avoids the need for string-ification and lets CMake deduplicate
potentially duplicate flags.

Differential Revision: https://reviews.llvm.org/D122750
2022-06-24 06:55:10 +00:00
Sergey Kosukhin 9f1d90bf91 [compiler-rt] Fix false positive detection of a target in compile-only mode
When `compiler-rt` is configured as a runtime, the configure-time target
detection for builtins is done in compile-only mode, which is basically a
test of whether the newly-built `clang` can compile a simple program with
an additional flag (`-m32` and `-m64` in my case). The problem is that on
my Debian system `clang` can compile `int foo(int x, int y) { return x + y; }`
with `-m32` but fails to include `limits.h` (or any other target-specific
header) for the `i386` target:
```
$ /path/to/build/./bin/clang --target=x86_64-unknown-linux-gnu -DVISIBILITY_HIDDEN  -O3 -DNDEBUG  -m32 -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -MD -MT CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o -MF CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o.d -o CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o -c /path/to/src/compiler-rt/lib/builtins/absvdi2.c
In file included from /path/to/src/compiler-rt/lib/builtins/absvdi2.c:13:
In file included from /path/to/src/compiler-rt/lib/builtins/int_lib.h:93:
In file included from /path/to/build/lib/clang/15.0.0/include/limits.h:21:
In file included from /usr/include/limits.h:25:
/usr/include/features.h:364:12: fatal error: 'sys/cdefs.h' file not found
           ^~~~~~~~~~~~~
1 error generated.
```

This is an attempt to make the target detection more robust: extend the test
program with `#include <limits.h>`.

Differential Revision: https://reviews.llvm.org/D127975
2022-06-23 15:11:39 +03:00
Julian Lettner f4a3df18a7 [ASan][Darwin] XFAIL test; atos does not show line numbers for globals
atos currently doesn't show source line numbers for global variables, so
global-location.cpp is failing after we switched from ASan-specific
metadata to normal symbolication.

See:
https://reviews.llvm.org/D127552
2022-06-22 18:19:31 -07:00
Lang Hames 232bd331cb [ORC-RT] Make the ORC runtime C API public.
This is a first step towards allowing programs to pre-link against the ORC
runtime, which would allow us to move some code that is currently in the LLVM
OrcTarget library into the ORC runtime instead.

The C API header has limited utility as-is, but serves as a minimal first step
and provides clients with tools for interacting with wrapper functions.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D127324
2022-06-16 19:02:23 -07:00
Fangrui Song 0e182469ee [sanitizer] Delete empty sanitizer_openbsd.cpp after D89759 2022-06-16 16:38:01 -07:00
Mitch Phillips 13e9c1d18e Reland "[ASan] Use debuginfo for symbolization."
This reverts commit 99796d06db.

Hint: Looking here because your manual invocation of something in
'check-asan' broke? You need a new symbolizer (after D123538).

An upcoming patch will remove the internal metadata for global
variables. With D123534 and D123538, clang now emits DWARF debug info
for constant strings (the only global variable type it was missing), and
llvm-symbolizer is now able to symbolize all global variable addresses
(where previously it wouldn't give you the file:line information).

Move ASan's runtime over from the internal metadata to DWARF.

Differential Revision: https://reviews.llvm.org/D127552
2022-06-16 13:58:55 -07:00
Kristina Bessonova 5cfbfa035f [sanitizer_common] Fix SanitizerCommon.ChainedOriginDepotStats test
This test was failing with the following error message if to run the test binary
directly, w/o using lit:

  $ Sanitizer-x86_64-Test --gtest_filter=SanitizerCommon.ChainedOriginDepot*
  ...
  [ RUN      ] SanitizerCommon.ChainedOriginDepotStats
  compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp:77: Failure
  Expected: (stats1.allocated) > (stats0.allocated), actual: 196608 vs 196608
  [  FAILED  ] SanitizerCommon.ChainedOriginDepotStats (867 ms)

Since the ChainedOriginDepot* tests are not doing any cleanup, by the time
SanitizerCommon.ChainedOriginDepotStats test starts executing the depot
may not be empty, so there will be no allocation for the test.

This patch introduces ChainedOriginDepot::TestOnlyUnmap() API that deallocates
memory when requested. This makes sure underlying TwoLevelMap initiates
the expected allocation during the test.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D127621
2022-06-16 11:59:58 +02:00
Colin Cross 80aa41d9df Pass through even more LIBCXX_* variables to libfuzzer's custom lib++
Similar to D120946, pass LIBCXX_HAS_GCC_S_LIB and LIBCXX_USE_COMPILER_RT
through to the custom lib++ builds so that libfuzzer doesn't end up with
a .deplibs section that links against those libraries when the
variables are set to false.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D127912
2022-06-15 19:05:29 -07:00
Kirill Stoimenov 99796d06db Revert "[ASan] Use debuginfo for symbolization."
This reverts commit f0ab8d90d4.
2022-06-15 23:42:46 +00:00
Mitch Phillips f0ab8d90d4 [ASan] Use debuginfo for symbolization.
Hint: Looking here because your manual invocation of something in
'check-asan' broke? You need a new symbolizer (after D123538).

An upcoming patch will remove the internal metadata for global
variables. With D123534 and D123538, clang now emits DWARF debug info
for constant strings (the only global variable type it was missing), and
llvm-symbolizer is now able to symbolize all global variable addresses
(where previously it wouldn't give you the file:line information).

Move ASan's runtime over from the internal metadata to DWARF.

Differential Revision: https://reviews.llvm.org/D127552
2022-06-15 15:36:36 -07:00
Benjamin Kramer 8bc0bb9564 Add a conversion from double to bf16
This introduces a new compiler-rt function `__truncdfbf2`.
2022-06-15 12:56:31 +02:00
Benjamin Kramer fb34d531af Promote bf16 to f32 when the target doesn't support it
This is modeled after the half-precision fp support. Two new nodes are
introduced for casting from and to bf16. Since casting from bf16 is a
simple operation I opted to always directly lower it to integer
arithmetic. The other way round is more complicated if you want to
preserve IEEE semantics, so it's handled by a new __truncsfbf2
compiler-rt builtin.

This is of course very bare bones, but sufficient to get a semi-softened
fadd on x86.

Possible future improvements:
 - Targets with bf16 conversion instructions can now make fp_to_bf16 legal
 - The software conversion to bf16 can be replaced by a trivial
   implementation under fast math.

Differential Revision: https://reviews.llvm.org/D126953
2022-06-15 12:56:31 +02:00
Petr Hosek 7524fe962e [libFuzzer] Use the compiler to link the relocatable object
Rather than invoking the linker directly, let the compiler driver
handle it. This ensures that we use the correct linker in the case
of cross-compiling.

Differential Revision: https://reviews.llvm.org/D127828
2022-06-15 07:16:40 +00:00
Peter S. Housel 612f0a7789 [ORC-RT] Add integration tests for AArch64
This change adds test cases targeting the AArch64 Linux platform to
the ORC runtime integration test suite.

Reviewed By: lhames, sunho

Differential Revision: https://reviews.llvm.org/D127720
2022-06-14 20:49:56 -07:00
Petr Hosek 18a1fc8459 [CMake][compiler-rt] Provide a dedicated option for LLVM unwinder
This allows configuring LLVM unwinder separately from the C++ library
matching how we configure it in libcxx.

This also applies changes made to libunwind+libcxxabi+libcxx in D113253
to compiler-rt.

Differential Revision: https://reviews.llvm.org/D115674
2022-06-14 17:26:25 +00:00
Mariusz Borsa a4bf361454 Revert "[Sanitizers] Cleanup handling of stat64/statfs64"
This reverts commit 6d890a0fb8.
2022-06-10 10:56:26 -07:00
Peter S. Housel 2be5abb7e9 [ORC][ORC_RT] Handle ELF .init_array with non-default priority
ELF-based platforms currently support defining multiple static
initializer table sections with differing priorities, for example
.init_array.0 or .init_array.100; the default .init_array corresponds
to a priority of 65535. When building a shared library or executable,
the system linker normally sorts these sections and combines them into
a single .init_array section. This change adds the capability to
recognize ELF static initializers with priorities other than the
default, and to properly sort them by priority, to Orc and the Orc
runtime.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D127056
2022-06-09 22:47:58 -07:00
Peter S. Housel 1aa71f8679 [ORC][ORC_RT] Integrate ORC platforms with LLJIT and lli
This change enables integrating orc::LLJIT with the ORCv2
platforms (MachOPlatform and ELFNixPlatform) and the compiler-rt orc
runtime. Changes include:

- Adding SPS wrapper functions for the orc runtime's dlfcn emulation
  functions, allowing initialization and deinitialization to be invoked
  by LLJIT.

- Changing the LLJIT code generation default to add UseInitArray so
  that .init_array constructors are generated for ELF platforms.

- Integrating the ORCv2 Platforms into lli, and adding a
  PlatformSupport implementation to the LLJIT instance used by lli which
  implements initialization and deinitialization by calling the new
  wrapper functions in the runtime.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D126492
2022-06-09 22:47:58 -07:00
Mariusz Borsa 6d890a0fb8 [Sanitizers] Cleanup handling of stat64/statfs64
There are differences in handling of stat64/statfs64 calls by sanitizers between Linux and macOS. Versions of macOS starting with 10.6 drop the stat64/statfs64 APIs completely, relying on the linker to redirect stat/statfs to the appropriate 64 bit versions. Emitting variables needed by sanitizers is thus controlled by convoluted sets of conditions, involving Linux, IOS, macOS and Android, sprinkled around files.

This change adresses it, allowing to specify presence/absence of stat64/statfs64 for each platform, in a single location. Also, it adresses the Android case which handles stat64, but not statfs64.

Adding Vitaly as a reviewer since he seems to be actively working on sanitizers, perhaps can comment on the Android bit

Differential Revision: https://reviews.llvm.org/D127343
2022-06-09 12:51:34 -07:00
Andrew Turner 95141aa9cb Fix TableLookupTest on FreeBSD
As with Linux placce the Counters array in the __libfuzzer_extra_counters
section. This fixes the test on FreeBSD.

Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D125902
2022-06-09 09:24:09 -04:00
David Carlier a4c97e1937 [Sanitizers] prctl interception update for the PR_SET_VMA option case.
Supports on Android but also from Linux 5.17

Reviewers: vitalybuka, eugenis

Reviewed-By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127326
2022-06-09 06:07:26 +01:00
Fangrui Song 62309ed955 [msan][test] Fix cpusetsize for another pthread_getaffinity_np.cpp test
Similar to D127368
2022-06-08 20:08:05 -07:00
Fangrui Song a86b171d8c [msan][test] Use a large cpusetsize for pthread_getaffinity_np
pthread_getaffinity_np (Linux `kernel/sched/core.c:sched_getaffinity`) fails
with EINVAL if 8*cpusetsize (constant in glibc: 1024) is smaller than
`nr_cpu_ids` (CONFIG_NR_CPUS, which is 2048 for several arch/powerpc/configs
configurations).

The build bot clang-ppc64le-linux-lnt seems to have a larger `nr_cpu_ids`.

Differential Revision: https://reviews.llvm.org/D127368
2022-06-08 18:50:23 -07:00
Kevin Athey 0777be69fb [MSAN] print out the only possible invalid parameter (EINVAL is returned)
One more round attempting to figure what is wrong.

Depends on: https://reviews.llvm.org/D127346

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127359
2022-06-08 16:23:04 -07:00
Andrew Turner ccae01cbce [compiler-rt] Fix Mmap on FreeBSD AArch64
On FreeBSD AArch64 safestack needs to use __syscall to handle 64 bit arguments

Reviewed by: MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D125901
2022-06-08 17:22:33 -04:00
Andrew Turner ad3faddaa6 [compiler-rt] Fix the longjmp sp slot on FreeBSD AArch64
The stack pointer is stored in the second slot in the jump buffer on
AArch64. Use the correct slot value to read this rather than the
following register.

Reviewed by: melver

Differential Revision: https://reviews.llvm.org/D125762
2022-06-08 17:22:27 -04:00
Andrew Turner b3c1442c6c [compiler-rt] Add the FreeBSD AArch64 shadow offset
As with 64 bit x86 use an offset in middle of the address space scaled up
to work with the full 48 bit space.

Reviewed by: MaskRay

Differential Revision: https://reviews.llvm.org/D125757
2022-06-08 17:22:16 -04:00
Andrew Turner 9496e39b4a [compiler-rt] Add the common FreeBSD AArch64 support
Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D125756
2022-06-08 17:22:01 -04:00
Kevin Athey d97d930d92 [MSAN] send output to stderr in test: pthread_getaffinity_np.
Must send output to stderr to view it.
This will be rolled back when diagnosis is complete.

Depends on: https://reviews.llvm.org/D127320

Differential Revision: https://reviews.llvm.org/D127346
2022-06-08 14:16:08 -07:00
Kevin Athey d50dc33d29 [MSAN] Add comment regarding why pthread_getaffinity_np is not supported on Android.
Depends on: https://reviews.llvm.org/D127264

Reviewed By: vitalybuka, fmayer

Differential Revision: https://reviews.llvm.org/D127327
2022-06-08 13:53:59 -07:00
Paul Kirth 56eb8dcf1e [compiler-rt][test] Restore original symbolize_stack test
In D126580 we updated the test to reflect that there should always
be a full trace. However, some executions do not have symbolizer
information, so we will restore the original test until we can formulate
a more robust test.

Reviewed By: leonardchan

Differential Revision: https://reviews.llvm.org/D127334
2022-06-08 19:15:52 +00:00
Leonard Chan 060907dd00 Revert "Reland "[NFC][compiler-rt][asan] Unify asan and lsan allocator settings""
This reverts commit b37d84aa8d.

This broke aarch64 asan builders for fuchsia. I accidentally changed the allocator
settings for fuchsia on aarch64 because the new asan allocator settings use:

```
// AArch64/SANITIZER_CAN_USE_ALLOCATOR64 is only for 42-bit VMA
// so no need to different values for different VMA.
const uptr kAllocatorSpace =  0x10000000000ULL;
const uptr kAllocatorSize  =  0x10000000000ULL;  // 3T.
typedef DefaultSizeClassMap SizeClassMap;
```

rather than reaching the final `#else` which would use fuchsia's lsan config.
2022-06-08 11:56:33 -07:00
Leonard Chan 033af5a537 [compiler-rt][hwasan] Check address tagging mode in InitializeOsSupport on Fuchsia
Differential Revision: https://reviews.llvm.org/D127262
2022-06-08 11:34:50 -07:00
Kevin Athey 7b1aa20a76 [MSAN] Add result printing for failed call in pthread_getaffinity_np.
Will be reverted when test failure is diagnosed.

Depends on: https://reviews.llvm.org/D127185

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127320
2022-06-08 11:14:24 -07:00
Nikita Popov 38ad963cc9 [sanitizer] Fix shift UB in LEB128 test
If u64 and uptr have the same size, then this will perform a shift
by the bitwidth, which is UB. We only need this code if uptr is
smaller than u64.
2022-06-08 14:21:25 +02:00
David CARLIER c06ef17359 [Sanitizers] intercept FreeBSD procctl
Reviewers: vitalybuka, emaster

Reviewed-By: viatelybuka

Differential Revision: https://reviews.llvm.org/D127069
2022-06-08 08:55:10 +01:00
Leonard Chan b37d84aa8d Reland "[NFC][compiler-rt][asan] Unify asan and lsan allocator settings"
I believe this should've been fixed with 4b15e665f8
which landed after this initial patch, but I reverted too early before I
saw the builder turn green again.
2022-06-07 18:09:48 -07:00
Kevin Athey 67069e1980 [MSAN] exclude android from pthread_getaffinity_np interceptor
Depends on https://reviews.llvm.org/D127185.

Differential Revision: https://reviews.llvm.org/D127264
2022-06-07 17:53:32 -07:00
Leonard Chan 13eb4fc3ce Revert "[NFC][compiler-rt][asan] Unify asan and lsan allocator settings"
This reverts commit dd045ddffc.

This broke the sanitizer-windows builder at https://lab.llvm.org/buildbot/#/builders/127/builds/30751.
2022-06-07 17:34:29 -07:00
Leonard Chan d1fb0a5a63 Fix for e1d84c421d
One of the checks in realloc_too_big.c actually printed a regular warning
and not an OOM error, so the check shouldn't be updated.
2022-06-07 17:28:24 -07:00
Leonard Chan 4b15e665f8 [compiler-rt][lsan] Choose lsan allocator via SANITIZER_CAN_USE_ALLOCATOR64
Rather than checking a bunch of individual platforms.

Differential Revision: https://reviews.llvm.org/D126825
2022-06-07 17:23:38 -07:00
Leonard Chan dd045ddffc [NFC][compiler-rt][asan] Unify asan and lsan allocator settings
This updates existing asan allocator settings to use the same allocator settings as what lsan uses for platforms where they already match.

Differential Revision: https://reviews.llvm.org/D126927
2022-06-07 17:21:19 -07:00
Leonard Chan e1d84c421d [compiler-rt][sanitizer] Have all OOM-related error messages start with the same format
This way downstream tools that read sanitizer output can differentiate between OOM errors
reported by sanitizers from other sanitizer errors.

Changes:

- Introduce ErrorIsOOM for checking if a platform-specific error code from an "mmap" is an OOM err.
- Add ReportOOMError which just prepends this error message to the start of a Report call.
- Replace some Reports for OOMs with calls to ReportOOMError.
- Update necessary tests.

Differential Revision: https://reviews.llvm.org/D127161
2022-06-07 16:46:01 -07:00
Lang Hames 5368c685d9 [ORC-RT] Remove a stale comment. 2022-06-07 16:42:37 -07:00
Kevin Athey 828c94c0f6 [MSAN] Add interceptor for pthread_getaffinity_np.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D127185
2022-06-07 16:27:44 -07:00
Paul Kirth acfeb1a6c2 [compiler-rt] Avoid truncating Symbolizer output
Repalce the fixed buffer in SymbolizerProcess with InternalScopedString,
and simply append to it when reading data.

Fixes #55460

Reviewed By: vitalybuka, leonardchan

Differential Revision: https://reviews.llvm.org/D126580
2022-06-07 21:50:39 +00:00
Arthur Eubanks f9ac557567 [NFC] Properly suppress unused argument warning in __isOSVersionAtLeast()
Casting to non-void causes
  expression result unused [-Wunused-value]
2022-06-06 19:41:26 -07:00
Kevin Athey 6dce56b2a3 [Driver] add -lresolv for all but Android.
As there 3 intercepts that depend on libresolv, link tests in ./configure scripts may be confuse by the presence of resolv symbols (i.e. dn_expand) even with -lresolv and get a runtime error.

Android provides the functionality in libc.

https://reviews.llvm.org/D122849
https://reviews.llvm.org/D126851

Reviewed By: eugenis, MaskRay

Differential Revision: https://reviews.llvm.org/D127145
2022-06-06 15:49:42 -07:00
Martin Storsjö 03c19f41a2 [builtins] Check __SEH__, when checking if ARM EHABI is implied
ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

This is the same change as 4a3722a2c3 /
D126866, applied on the compiler-rt builtins gcc_personality_v0
function.

Differential Revision: https://reviews.llvm.org/D126863
2022-06-06 23:23:08 +03:00
Kevin Athey 21f2ac9a2f [MSAN] Exclude dn_expand test from Android.
Depends on 1a729bce86

Differential Revision: https://reviews.llvm.org/D126981
2022-06-03 11:23:38 -07:00
Kevin Athey 1a729bce86 [MSAN] add dn_expand intercept.
This interceptor only addresses writes to inputs.  Reads of inputs are not checked.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D126851
2022-06-03 09:49:42 -07:00
Andrew Browne 31d12df3b9 [DFSan] Remove deprecated flag from build-libc-list.py
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D126429
2022-06-01 11:00:13 -07:00
Fangrui Song 241e645036 ar_to_bc.sh: Ignore non-bitcode files in archives
The script uses llvm-link to link LLVM bitcode files.
5426da8ffa used -DLLVM_DISABLE_ASSEMBLY_FILES=ON
to ignore object files compiled from lib/Support/BLAKE3/*.S.

A better approach (which fits Bazel better) is to ignore non-bitcode files.

Reviewed By: akyrtzi

Differential Revision: https://reviews.llvm.org/D126728
2022-06-01 10:28:14 -07:00
Nico Weber be223eb541 sanitizers: Do not include crypt.h if SANITIZER_INTERCEPT_CRYPT_R is undef
sanitizer_intercept_overriders.h might override SANITIZER_INTERCEPT_CRYPT_R to
be undefined. There's no need to require crypt.h in that case.

(The motivation is that crypt() moved from glibc into its own package at some
point, which makes intercepting it and building with a single sysroot that
supports both pre-bullseye and post-bullseye a bit hairy.)

Differential Revision: https://reviews.llvm.org/D126696
2022-06-01 13:27:06 -04:00
Brooks Davis 18efa420da compiler-rt: Allow build without __c11_atomic_fetch_nand
Don't build atomic fetch nand libcall functions when the required
compiler builtin isn't available. Without this compiler-rt can't be
built with LLVM 13 or earlier.

Not building the libcall functions isn't optimal, but aligns with the
usecase in FreeBSD where compiler-rt from LLVM 14 is built with an LLVM
13 clang and no LLVM 14 clang is built.

Reviewed By:	efriedma

Differential Revision:	https://reviews.llvm.org/D126710
2022-06-01 12:58:30 -04:00
Andrew Ng e06a81d810 [LSAN] Fix up LSAN weak symbols for Windows
Differential Revision: https://reviews.llvm.org/D126703
2022-06-01 10:18:51 +01:00
Mariusz Borsa e2adffc39c [Sanitizers][Darwin] Deprecate SANITIZER_MAC - fail compilation if encountered
Previous couple commits replaced SANITIZER_MAC with SANITIZER_APPLE in bulk.
This change will prompt anyone still trying to use SANITIZER_MAC to rename.

Differential Revision: https://reviews.llvm.org/D126577
2022-05-31 18:08:59 -07:00
Yuki Okushi 36c1183c78
[test] Remove an outdated FIXME
rG6a9c719ee1be4562a9e16f2c71ac3e51ef9c4292 removed the backticks and this FIXME comment is no longer necessary.

Differential Revision: https://reviews.llvm.org/D126528
2022-06-01 08:17:46 +09:00
Andrew Browne 15d5db276c [DFSan] build-libc-list.py no longer provides a list of default files.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D126430
2022-05-31 11:25:56 -07:00
Alex Brachet 7df55e5ed7 [scudo] Ensure pointer is not null
Differential revision: https://reviews.llvm.org/D126499
2022-05-31 17:16:49 +00:00
Alex Brachet 35a032eaf4 [InstrProf] Stop exporting lprofDirMode
This symbol should not be exposed and doesn't need to be.

Differential revision: https://reviews.llvm.org/D126548
2022-05-31 17:13:00 +00:00
Keno Fischer 167fb106d2 compiler-rt/cpu_model: Ensure constructor priority is set and align with GCC
GCC recently started setting constructor priority on init_have_lse_atomics [1]
to avoid undefined initialization order with respect to other initializers,
causing accidental use of ll/sc intrinsics on targets where this was not
intended (which presents a minor performance problem as well as a
compatibility problem for users wanting to use the rr debugger). I initially
thought compiler-rt does not have the same issue as libgcc, since it looks
like we're already setting init priority on the constructor.

Unfortuantely, it does not appear that the HAVE_INIT_PRIORITY check is ever
performed anyway, so despite appearances the init priority was not actually
applied. Fix that by applying the init priority unconditionally. It has been
supported in clang ever since it was first introduced and in any case for
more than 14 years in both gcc and clang. MSVC is already excluded from this
code path and we're already using constructors with init priority elsewhere
in compiler-rt without additional check (though mostly in the sanitizer
runtime, which may have more narrow target support). Regardless, I believe
that for our supported compilers, if they support the constructor attribute,
they should also support init priorities.

While we're here, change the init priority from 101, which is the highest
priority for end user applications, to instead use one of the priority levels
reserved for implementations (1-100; lower integers are higher priority).
GCC ended up using `90`, so this commit aligns the value in compiler-rt
to the same value to ensure that there are no subtle initialization order
differences between libgcc and compiler-rt.

[1] 75c4e4909a

Differential Revision: https://reviews.llvm.org/D126424
2022-05-30 20:31:49 +00:00
Pierre Gousseau 4278b7e16a [sanitizers] Fixes strndup API behaviour when intercepted by sanitizers
Sanitizers ignore flag allocator_may_return_null=1 in strndup() calls.
When OOM is emulated, this causes to the unexpected crash.

Committed by pgousseau on behalf of "Kostyantyn Melnik, kmnls.kmnls@gmail.com"

Reviewed by: pgousseau

Differential Revision: https://reviews.llvm.org/D126452
2022-05-30 17:00:10 +01:00
Roland McGrath a27b9139ab [scudo] Clean up Zircon header file uses
Make fuchsia.h and fuchsia.cpp each include what they use.
2022-05-27 21:39:03 -07:00
Julian Lettner 8e724ad965 [TSan][Darwin] Deflake test
The asserted order of THREAD_DESTROY and end of main() is not
guaranteed:
```
 7: Hello from pthread
 8: THREAD_TERMINATE 0x7e8000104000, self: 0x7e8000104000, name: child thread
 9: Done.
10: THREAD_DESTROY 0x7e8000104000, self: 0x7e8000104000, name: child thread
```

Resulting in:
```
error: CHECK: expected string not found in input
// CHECK: Done.
```

Remove checking for "Done." (end of main()) to deflake this test.
Alternatively, we could use `CHECK-DAG`.

rdar://94036145
2022-05-27 10:19:56 -07:00
John Paul Adrian Glaubitz a1ec3c5a88 [scudo] Link against libatomic on all MIPS targets
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D126418
2022-05-26 00:00:16 -07:00
Paul Kirth 7f5439945b [compiler-rt][test] Fix flake in symbolize_stack test
Addresses tests flakes described in
https://github.com/llvm/llvm-project/issues/55460

The test being updated can fail in FileCheck to match when given long
enough stack traces. This can be problematic when file system paths
become long enough to cause the majority of the long function name to
become truncated. We found in our CI that the truncated output would
often fail to match, thereby causing the test to fail when it should not.

Here we change the test to match on sybolizer output that should be more
reliable than matching inside the long function name.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D126102
2022-05-25 19:02:30 +00:00
Andrew Browne b2b0322a81 [DFSan] Add option to specify individual library files, and an option to exit with an error code if any library file was not found.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D126336
2022-05-24 16:15:46 -07:00
Mariusz Borsa 8246b2e156 [Sanitizers][Darwin] Replace SANITIZER_MAC with SANITIZER_APPLE in source files
This is a follow up to [Sanitizers][Darwin] Rename Apple macro SANITIZER_MAC -> SANITIZER_APPLE (D125816)

Performed a global search/replace as in title against LLVM sources

Differential Revision: https://reviews.llvm.org/D126263
2022-05-24 12:59:27 -07:00
Leonard Chan 6edbdf80ca Revert "[compiler-rt][scudo] Add missing preprocessor token" and "[compiler-rt][scudo] Simplify TBI checks"
This reverts commit 676eaa2ca9
and f6038cdca0 since builders are still
broken.
2022-05-24 11:30:31 -07:00
Leonard Chan 676eaa2ca9 [compiler-rt][scudo] Add missing preprocessor token
This should fix build errors seen on bots like
https://lab.llvm.org/buildbot/#/builders/57/builds/18263.
2022-05-24 11:12:30 -07:00
Leonard Chan f6038cdca0 [compiler-rt][scudo] Simplify TBI checks
Differential Revision: https://reviews.llvm.org/D111080
2022-05-24 10:53:09 -07:00
Leonard Chan c8644ea88e [compiler-rt][lsan] Update CanBeAHeapPointer for AArch64
While attempting to get the 64-bit lsan allocator working for Fuchsia, I
noticed this function would incorrectly return false for pointers returned
by the 64-bit allocator. On AArch64, this function attempts to get the VMA
size dynamically by counting the number of leading zeros from the function
frame address. This will fail if the frame address is significantly below an
allocated pointer (that is, the frame address has more leading zeros than an
allocated pointer). This is possible on Fuchsia and linux (when not called
from the initial thread stack).

It seems the intended use of this function is to speed up pointer scanning by
filtering out addresses that user code might not be able to access. Other
platforms this check is done on seem to hardcode the VMA size/shift, so it
seems appropriate to do this for aarch64 as well. This implies pointers on
aarch64 where the VMA size is <64 will pass through, but bad pointers will
still be caught by subsequent scan checks.

This patch also renames the function to something more fitting of what it's
trying to do.

Differential Revision: https://reviews.llvm.org/D123814
2022-05-24 10:22:46 -07:00
Julian Lettner 1962389979 [Sanitizer][Darwin] Add explanation for Apple platform macros
Differential Revision: https://reviews.llvm.org/D126229
2022-05-23 11:59:44 -07:00
Julian Lettner 806e8a1c8e [Sanitizer][Darwin] Add SANITIZER_DRIVERKIT platform macro 2022-05-23 11:21:45 -07:00
Paul Kirth d6a3c8ca18 Revert "tsan: add lock free stack pattern test"
This reverts commit 5deca650fd.
2022-05-21 00:12:06 +00:00
Paul Kirth f1d197f1a8 Revert "Mark new TSan test as unsupported on PPC."
This reverts commit b517d679dd.
2022-05-21 00:11:50 +00:00
Mitch Phillips de06626725 PPC+TSan whack-a-mole, round 3.
More details in https://reviews.llvm.org/D110552.

Last try until I revert the whole shenanigans.
2022-05-20 14:21:58 -07:00
Mitch Phillips bd62b70b51 Add 'ppc' as a target (for both 32- and 64-bit ppc).
Needed for a TSan test that won't pass on PPC. Relevant information is
in https://reviews.llvm.org/D110552.
2022-05-20 13:56:25 -07:00
Mitch Phillips b517d679dd Mark new TSan test as unsupported on PPC.
Notably fails under PPC. For now, just exclude it. More details in the
original Phabricator review, https://reviews.llvm.org/D110552.
2022-05-20 13:06:44 -07:00
Mitch Phillips 80ac0b9bc8 Fix up fuzzing test on Windows.
3bd112c720 fixed the fuzzing test on Linux, which, after
https://reviews.llvm.org/D125933, has one less branch. Turns out, on
Windows, that it still has the extra branch. I'm guessing that's because
exit() isn't known to be noreturn on Windows or something.

Either way, just make the test more tolerant.
2022-05-20 11:27:08 -07:00
Mitch Phillips 3bd112c720 Update fuzzing test to comply with new optimisation.
https://reviews.llvm.org/D125933 improved some of LLVM's handling of
binary ORs, which meant we have one less conditional branch, because the
'if (Size > 5 && Data[5] == 'R')' and 'if (bits == 63)' branches are now
correctly folded.
2022-05-20 11:01:31 -07:00
Alexey Katranov 5deca650fd tsan: add lock free stack pattern test
Add a set of tests that iterate over possible combinations of
memory orders for lock free stack implementation.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D110552
2022-05-20 13:36:01 +02:00
Julian Lettner ec563c5a90 [ASan] Add sleep_before_init flag
Also do a little bit of refactoring instead of just copy&paste.

Differential Revision: https://reviews.llvm.org/D126037
2022-05-19 20:41:43 -07:00
Mariusz Borsa 77014b9a13 [Sanitizers][Darwin] Rename Apple macro SANITIZER_MAC -> SANITIZER_APPLE
Initial introduction of the new macro before obsoleting the old one - the old name was really confusing.
Also moved SANITIZER_WATCHOS and SANITIZER_TVOS definitions under common #if defined(__APPLE__) block

Differential Revision: https://reviews.llvm.org/D125816
2022-05-18 14:46:41 -07:00
Mitch Phillips f9a3c43eaa [NFCI] clang-format gwp-asan files. 2022-05-18 14:10:44 -07:00
Mitch Phillips e831ea6912 [NFCI] clang-format scudo standalone 2022-05-18 14:04:04 -07:00
Eli Friedman dd20323f51 [compiler-rt builtins] Assert that atomic.c can be compiled correctly.
The spinlock requires that lock-free operations are available;
otherwise, the implementation just calls itself. As discussed in
D120026.

Differential Revision: https://reviews.llvm.org/D123080
2022-05-16 14:40:57 -07:00
John Paul Adrian Glaubitz d4aacc1a01 [sanitizer] Don't use newfstatat for Linux on SPARC
Linux on SPARC uses fstatat64 instead.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D125572
2022-05-16 12:21:55 -07:00
Timm Bäder 791e0d1bc8 [compiler-rt] Add NO_EXEC_STACK_DIRECTIVE on s390x
Differential Revision: https://reviews.llvm.org/D125454
2022-05-13 07:57:10 +02:00
Julian Lettner 824d83068e [TSan] Relax pthread introspection-based test
Thread create/destroy events are not guaranteed to belivered on the
parent thread, e.g., output from a CI job:
```
5: THREAD_CREATE 0x7e8000104000, self: 0x1102ebdc0, name: n/a
6: THREAD_START 0x7e8000104000, self: 0x7e8000104000, name: n/a
7: Hello from pthread
8: THREAD_TERMINATE 0x7e8000104000, self: 0x7e8000104000, name: child thread
9: THREAD_DESTROY 0x7e8000104000, self: 0x7e8000104000, name: child thread
```
Here, THREAD_DESTROY is delivered on the thread being destroyed.

rdar://92679941
2022-05-12 18:13:12 -07:00
Blue Gaston 9145cb8b7c [Sanitizers][Darwin] Add READ/WRITE detection on arm64 for darwin.
On arm64 the read/write flag is set on the esr register.
	Adding this flag check for arm64 enables a more accurate
	print out for sanitizer signal reports and matches the
	behavior on x86.

	Fixes bug: https://bugs.llvm.org/show_bug.cgi?id=27543 https://github.com/google/sanitizers/issues/653

	These tests are now passing:
		SanitizerCommon-asan-arm64-Darwin :: Posix/illegal_read_test.cpp
		SanitizerCommon-asan-arm64-Darwin :: Posix/illegal_write_test.cpp
		SanitizerCommon-asan-arm64e-Darwin :: Posix/illegal_read_test.cpp
  		SanitizerCommon-asan-arm64e-Darwin :: Posix/illegal_write_test.cpp
  		SanitizerCommon-tsan-arm64-Darwin :: Posix/illegal_read_test.cpp
  		SanitizerCommon-tsan-arm64-Darwin :: Posix/illegal_write_test.cpp
  		SanitizerCommon-tsan-arm64e-Darwin :: Posix/illegal_read_test.cpp
  		SanitizerCommon-tsan-arm64e-Darwin :: Posix/illegal_write_test.cpp
  		SanitizerCommon-ubsan-arm64-Darwin :: Posix/illegal_read_test.cpp
  		SanitizerCommon-ubsan-arm64-Darwin :: Posix/illegal_write_test.cpp
  		SanitizerCommon-ubsan-arm64e-Darwin :: Posix/illegal_read_test.cpp
  		SanitizerCommon-ubsan-arm64e-Darwin :: Posix/illegal_write_test.cpp

rdar://92104440

Differential Revision: https://reviews.llvm.org/D125416
2022-05-12 10:51:49 -07:00
Florian Mayer de67bc8edb [HWASan symbolize] Write error to stderr. 2022-05-10 17:00:57 -07:00
Florian Mayer be17d18ae8 [HWASan] deflake hwasan_symbolize test more.
Don't fail on corrupted ELF file on indexing. This happens because files
change in the directory from concurrent tests.
2022-05-10 16:57:44 -07:00
Nikita Popov ddfc84e634 [fuzzer] Reduce size of large.test
This halves the size of LargeTest, dropping time to compile this
file locally from 14s to 5.5s. Hopefully this will also fix the
persistent timeouts in pre-merge checks.

Differential Revision: https://reviews.llvm.org/D124237
2022-05-10 10:19:04 +02:00
Florian Mayer b77d16f7f3 [HWASan] deflake hwasan_symbolize test
Also enable on X86_64.

The directory would change during the test execution. This should not
necessarily prevent us from indexing a directory (a user might
potentially do that if they specify a parent directory of the actual
symbols directory, and change unrelated files).

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D125143
2022-05-09 14:11:52 -07:00
Clemens Wasser d08e5d4cc6 Make lsan TestCases more consistent
Inlining `LSAN_BASE` makes the lsan TestCases more consistent to the other sanitizer TestCases.
It is also needed on Windows: https://reviews.llvm.org/D115103

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D124322
2022-05-09 11:32:15 -07:00
Peter S. Housel 1dda6ad80c [test][ORC-RT] Disable elfnix_platform tests on non-x86_64 platforms
ORC ELFNixPlatform currently only supports x86_64.
2022-05-06 20:11:35 -07:00
Petr Hosek bf3cba71e1 Revert "[runtime] Build compiler-rt with --unwindlib=none"
This reverts commit 102bc634cb because
some tests are failing on sanitizer bots.
2022-05-06 19:53:30 -07:00
Petr Hosek 102bc634cb [runtime] Build compiler-rt with --unwindlib=none
This applies the change made to libunwind+libcxxabi+libcxx in D113253
to compiler-rt as well.

Differential Revision: https://reviews.llvm.org/D115674
2022-05-06 17:53:47 -07:00
Petr Hosek d7732695eb Revert "[runtime] Build compiler-rt with --unwindlib=none"
This reverts commit fecad835fb.
2022-05-06 17:52:10 -07:00
Petr Hosek fecad835fb [runtime] Build compiler-rt with --unwindlib=none
This applies the change made to libunwind+libcxxabi+libcxx in D113253
to compiler-rt as well.

Differential Revision: https://reviews.llvm.org/D115674
2022-05-06 17:36:17 -07:00
Florian Mayer 68cd47e0ca [HWASan] Clean up hwasan_symbolize.
The globals are better expressed as members of the Symbolizer, and all
functions operating on it should be methods instead.

Also using the standard idiom of wrapping the main code in
`if __name__ == '__main__'`.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D125032
2022-05-06 15:45:53 -07:00
Florian Mayer d8564dcbcf [HWASan] Allow to linkify symbolizer output.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D124950
2022-05-06 15:44:14 -07:00
Louis Dionne a097c4ce95 [compiler-rt] Fix issue with compiler-rt tests mixing <atomic> and <stdatomic.h>
Since D97044, libc++ implements <stdatomic.h>, which is not compatible
with the <atomic> header in C++03 mode. To fix the tests, avoid using
<stdatomic.h> at all, since it is not strictly required.

rdar://92867529

Differential Revision: https://reviews.llvm.org/D125118
2022-05-06 17:36:12 -04:00
Peter S. Housel 981523b2e4 [ORC-RT][ORC] Handle dynamic unwind registration for libunwind
This changes the ELFNix platform Orc runtime to use, when available,
the __unw_add_dynamic_eh_frame_section interface provided by libunwind
for registering .eh_frame sections loaded by JITLink. When libunwind
is not being used for unwinding, the ELFNix platform detects this and
defaults to the __register_frame interface provided by libgcc_s.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D114961
2022-05-06 14:00:29 -07:00
Nico Weber c9faea04b1 Revert "[HWASan] Allow to linkify symbolizer output."
This reverts commit 4af9392e13.
The new test fails on several machines (including some bots),
see https://reviews.llvm.org/D124950
2022-05-06 09:53:45 -04:00
Nico Weber f3d31c7f81 Revert "[HWASan] Clean up hwasan_symbolize."
This reverts commit 6ca1df61d2.
Prerequisite for reverting 4af9392e13.
2022-05-06 09:53:45 -04:00
Ben Shi 3902ebdd57 [compiler-rt][builtins] Fix wrong ABI of AVR __mulqi3 & __mulhi3
Reviewed By: aykevl, dylanmckay

Differential Revision: https://reviews.llvm.org/D125077
2022-05-06 13:46:49 +00:00
Sam McCall 7cc8377f2c Generalize "check-all" umbrella targets, use for check-clang-tools
The mechanism behind "check-all" is recording params of add_lit_testsuite()
calls in global variables LLVM_LIT_*, and then creating an extra suite with
their union at the end.
This avoids composing the check-* targets directly, which doesn't work well.

We generalize this by allowing multiple families of variables LLVM_{name}_LIT_*:
  umbrella_lit_testsuite_begin(check-foo)
  ... test suites here will be added to LLVM_FOO_LIT_* variables ...
  umbrella_lit_testsuite_end(check-foo)
(This also moves some implementation muck out of {llvm,clang}/CMakeLists.txt

This patch also changes check-clang-tools to use be an umbrella test target,
which means the clangd and clang-pseudo tests are included in it, along with the
the other testsuites that already are (like check-clang-extra-clang-tidy).

Differential Revision: https://reviews.llvm.org/D121838
2022-05-06 12:30:49 +02:00
Wael Yehia 93bb2f16e8 XFAIL some PGO tests on AIX until the new linker becomes publicly available. 2022-05-06 01:35:32 +00:00
Florian Mayer 6ca1df61d2 [HWASan] Clean up hwasan_symbolize.
The globals are better expressed as members of the Symbolizer, and all
functions operating on it should be methods instead.

Also using the standard idiom of wrapping the main code in
`if __name__ == '__main__'`.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D125032
2022-05-05 16:41:11 -07:00
Florian Mayer 4af9392e13 [HWASan] Allow to linkify symbolizer output.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D124950
2022-05-05 16:40:09 -07:00
Ben Shi 70a66c08fc [compiler-rt][builtins] Add helper functions for uint16/sint16/uint8/sint8 div and mod
__udivmodhi4 : uint16 div and mod
__udivmodqi4 : uint8 div and mod
__divmodhi4  : sint16 div and mod
__divmodqi4  : sint8 div and mod

The above helper functions in libgcc have special ABI as described at
https://gcc.gnu.org/wiki/avr-gcc#Exceptions_to_the_Calling_Convention .

Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D124600
2022-05-05 23:29:14 +00:00
H.J. Lu b226894d47 [sanitizer] Correct GetTls for x32
Since x32 pointer size is 4 bytes, the self pointer offset in TCB:

struct
{
  void *tcb;
  dtv_t *dtv;
  void *self;
  ...

should be 8, not 16.

Fixes https://github.com/llvm/llvm-project/issues/55288

Differential Revision: https://reviews.llvm.org/D125025
2022-05-05 13:55:19 -07:00
Tobias Burnus 6f095babc2 sanitizer_common: Define FP_XSTATE_MAGIC1 for old glibc
D116208 (commit 1298273e82) added FP_XSTATE_MAGIC1.
However, when building with glibc < 2.16 for backward-dependency
compatibility, it is not defined - and the build breaks.

Note: The define comes from Linux's asm/sigcontext.h but the
file uses signal.h which includes glibc's bits/sigcontext.h - which
is synced from the kernel's file but lags behind.

Solution: For backward compatility with ancient systems, define
FP_XSTATE_MAGIC1 if undefined.

//For the old systems, we were building with Linux kernel 3.19 but to support really old glibc systems, we build with a sysroot of glibc 2.12. While our kernel (and the users' kernels) have FP_XSTATE_MAGIC1, glibc 2.12 is too old. – With this patch, building the sanitizer libs works again. This showed up for us today as GCC mainline/13 has now synced the sanitizer libs.//

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D124927
2022-05-05 11:05:27 +01:00
Wael Yehia 2407c13aa4 [AIX][PGO] Enable linux style PGO on AIX
This patch switches the PGO implementation on AIX from using the runtime
registration-based section tracking to the __start_SECNAME/__stop_SECNAME
based. In order to enable the recognition of __start_SECNAME/__stop_SECNAME
symbols in the AIX linker, the -bdbg:namedsects:ss needs to be used.

Reviewed By: jsji, MaskRay, davidxl

Differential Revision: https://reviews.llvm.org/D124857
2022-05-05 04:10:39 +00:00
Ayke van Laethem 514371c370
[compiler-rt][AVR] Fix avr_SOURCES CMake variable
D123200 did not include the generic sources, which means that only the
AVR-specific sources were compiled. With this change, generic sources
are included as expected.

Tested with the following commands:

    cmake -G Ninja -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=avr -DCOMPILER_RT_BAREMETAL_BUILD=1 -DCMAKE_C_COMPILER=clang-14 -DCMAKE_C_FLAGS="--target=avr -mmcu=avr5 -nostdlibinc -mdouble=64" ../path/to/builtins

    ninja

Differential Revision: https://reviews.llvm.org/D124969
2022-05-05 02:29:04 +02:00
H.J. Lu f52e365092 [sanitizer] Use newfstatat for x32
Since newfstatat is supported on x32, use it for x32.

Differential Revision: https://reviews.llvm.org/D124968
2022-05-04 15:54:42 -07:00
Ayke van Laethem c1d6dca694
[compiler-rt][AVR] Use correct return value for __ledf2 etc
Previously the default was long, which is 32-bit on AVR. But avr-gcc
expects a smaller value: it reads the return value from r24.

This is actually a regression from https://reviews.llvm.org/D98205.
Before D98205, the return value was an enum (which was 2 bytes in size)
which was compatible with the 1-byte return value that avr-gcc was
expecting. But long is 4 bytes and thus places the significant return
value in a different register.

Differential Revision: https://reviews.llvm.org/D124939
2022-05-04 22:51:39 +02:00
Florian Mayer 1b2704f935 [HWASan] cleanup imports in hwasan_symbolize. 2022-05-04 11:22:36 -07:00
Martin Liska f1b9245199 tsan: fix GCC warnings
Fixes:

tsan/tsan_shadow.h:93:32: warning: enumerated and non-enumerated type in conditional expression [-Wextra]
tsan/tsan_shadow.h:94:44: warning: enumerated and non-enumerated type in conditional expression [-Wextra]

Differential Revision: https://reviews.llvm.org/D124828
2022-05-04 10:22:03 +02:00
Yuanfang Chen a61c8e1ebd tsan: for unittests, change to use test fixtures to clear racy stacks
After cd0a5889d7, unittest would run in shard mode where many tests
share a single process. Need to clear some global state to make the test
results stable.

Reviewed By: thetruestblue, rsundahl

Differential Revision: https://reviews.llvm.org/D124591
2022-05-03 10:18:00 -07:00
Martin Liska 903b8845fb sanitizer: Fix fallthrough detection.
First check for clang::fallthrough attribute that resolves:

sanitizer_stack_store.cpp:258:7: error: use of the 'fallthrough'
attribute is a C++17 extension [-Werror,-Wc++17-attribute-extensions]
2022-05-03 13:55:28 +02:00
Martin Liska 0a1bcab9f3 tsan: fix deadlock in libbacktrace
Fixes deadlock seen in GCC.

Fixes: #55226

Differential Revision: https://reviews.llvm.org/D124838
2022-05-03 12:51:20 +02:00
Martin Liska f496a0eba4 sanitizer: use pragma clang conditionally
Use the pragma only when __clang__ is defined.

Fixes:
sanitizer_common_libcdep.cpp:101: warning: ignoring ‘#pragma clang diagnostic’ [-Wunknown-pragmas]

Differential Revision: https://reviews.llvm.org/D124829
2022-05-03 11:34:30 +02:00
Martin Liska bc8e601257 sanitizer: support GCC's fallthrough attribute
Fixes:
sanitizer_stack_store.cpp:257:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

when being built with GCC.

Differential Revision: https://reviews.llvm.org/D124832
2022-05-03 11:30:13 +02:00
Vitaly Buka eeccdd318d Revert "tsan: model atomic read for failing CAS"
https://lab.llvm.org/buildbot/#/builders/70/builds/21206 hangs.

This reverts commit 2fec52a402.
2022-05-02 22:26:56 -07:00
Evgenii Stepanov 696092c703 [sanitizer] Use canonical syscalls everywhere
These "new" syscalls have been added in 2.6.16, more than 16 years ago.
Surely that's enough time to migrate. Glibc 2.33 is using them on both
i386 and x86_64. Android has an selinux filter to block the legacy
syscalls in the apps.

Differential Revision: https://reviews.llvm.org/D124212
2022-05-02 13:54:01 -07:00
Dmitry Vyukov 2fec52a402 tsan: model atomic read for failing CAS
See the added test and https://github.com/google/sanitizers/issues/1520
for the description of the problem.
The standard says that failing CAS is a memory load only,
model it as such to avoid false positives.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D124507
2022-05-02 12:57:56 +02:00