Commit Graph

5337 Commits

Author SHA1 Message Date
Roy Sundahl
f9450807dd [ubsan][test] Fix typo in D139230
Fix "runtime runtime error" -> "runtime error"

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D140321
2023-01-06 14:28:07 -08:00
Florian Hahn
93a0ff2328 [profile] Update test to make condition non-redundant.
The tests contain a redundant condition in the else if branch that can
be simplified with fb13dcf343.

Update the condition used to prevent it from getting removed.

Alive2 proof for check removal:
https://alive2.llvm.org/ce/z/iFBnsy
2023-01-05 19:07:04 +00:00
Fangrui Song
3ffda42e50 [test] Fix #if 2023-01-03 13:18:46 -08:00
Fangrui Song
de5416cb59 [dfsan] Support Linux AArch64
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake:ALL_DFSAN_SUPPORTED_ARCH
allows AArch64 but currently the instrumentation will crash.

Port Linux AArch64 memory mappings from msan but use
SizeClassAllocator64 for a slightly more efficient allocator (used by
asan/lsan). Change dfsan/lit.cfg.py to allow Linux aarch64. All tests
should pass.

* dfsan/origin_invalid.c uses x86_64 assembly. Just make it x86_64 specific.
* dfsan/interceptors.c our mallinfo interceptor takes an argument
  instead of returning a struct. This does not work on AArch64 which
  uses different registers for the two function types. Disable AArch64
  as msan/Linux/mallinfo.cpp does.

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D140770
2023-01-03 13:17:39 -08:00
Muhammad Omair Javaid
aa36207c78 [compiler-rt] XFAIL builtins unit tests on WoA
Following tests are marked XFAIl because they are dependent on native
C complex numbers but they are not a native type for Microsoft ABI [1].

Builtins-aarch64-windows :: divmodti4_test.c
Builtins-aarch64-windows :: fixunstfdi_test.c
Builtins-aarch64-windows :: multc3_test.c

Also trampoline_setup_test.c as it runs with only non-clang compiler while
WoA LLVM buildbots use clang.

[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support?view=msvc-170
2023-01-03 15:22:45 +04:00
Gulfem Savrun Yeniceri
1ae7d83803 [profile] Add binary ids into indexed profiles
This patch adds support for including binary ids in an indexed profile.
It adds a new field into the header that points to the offset of the
binary id section. The binary id section consists of a size of the
section, and a list of binary ids (if they are present) that consist
of two parts: length and data.

This patch guarantees that indexed profile is backwards compatible
after adding binary ids.

Differential Revision: https://reviews.llvm.org/D135929
2022-12-29 18:46:56 +00:00
Fangrui Song
df9400c579 [test] Fix dfsan/stack_trace.c 2022-12-29 10:30:41 -08:00
Fangrui Song
975327a609 [dfsan][test] Replace REQUIRES: x86_64-target-arch with lit.cfg.py check
Make it easier to support a new architecture.

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D140744
2022-12-28 15:35:09 -08:00
Hans Wennborg
fd0ca2c4e9 Revert "Reland "[pgo] Avoid introducing relocations by using private alias""
This caused lld on mac to assert when building instrumented clang (or
instrumented code in general). See comment on the code review for
reproducer.

> In many cases, we can use an alias to avoid a symbolic relocations,
> instead of using the public, interposable symbol. When the instrumented
> function is in a COMDAT, we can use a hidden alias, and still avoid
> references to discarded sections.
>
> New compiler-rt tests are Linux only for now.
>
> Previous versions of this patch allowed the compiler to name the
> generated alias, but that would only be valid when the functions were
> local. Since the alias may be used across TUs we use a more
> deterministic naming convention, and add a `.local` suffix to the alias
> name just as we do for relative vtables aliases.
>
> Reviewed By: phosek
>
> Differential Revision: https://reviews.llvm.org/D137982

This reverts commit c42e50fede.
2022-12-21 15:29:00 +01:00
Paul Robinson
17f804ef4b [hwasan] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-21 05:41:41 -08:00
Paul Robinson
8e60061290 [compiler-rt] Simplify lit test thumb checks 2022-12-21 05:33:32 -08:00
Louis Dionne
52aab0e4b4 [clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin
Previously, we would be passing down -stdlib=libc++ from the Driver
to CC1 whenever the default standard library on the platform was libc++,
even if -stdlib= had not been passed to the Driver. This meant that we
would pass -stdlib=libc++ in nonsensical circumstances, such as when
compiling C code.

This logic had been added in b534ce46bd to make sure that header
search paths were set up properly. However, since libc++ is now the
default Standard Library on Darwin, passing this explicitly is not
required anymore. Indeed, if no -stdlib= is specified, CC1 will end
up using libc++ if it queries which standard library to use, without
having to be told.

Not passing -stdlib= at all to CC1 on Darwin should become possible
once CC1 stops relying on it to set up framework search paths.

Furthermore, this commit also removes a diagnostic checking whether the
deployment target is too old to support libc++. Nowadays, all supported
deployment targets use libc++ and compiling with libstdc++ is not
supported anymore. The Driver was the wrong place to issue this
diagnostic since it doesn't know whether libc++ will actually be linked
against (e.g. C vs C++), which would lead to spurious diagnostics.
Given that these targets are not supported anymore, we simply drop
the diagnostic instead of trying to refactor it into CC1.

This is a re-application of 6540f32db0 which had been reverted in
49dd02bd08 because it broke a compiler-rt test. The test had broken
because we were compiling C code and passing -stdlib=libc++, which Clang
will now warn about.

rdar://103198514

Differential Revision: https://reviews.llvm.org/D139938
2022-12-20 19:56:28 -05:00
Paul Robinson
015f8cd78e [xray] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-20 07:36:08 -08:00
Paul Robinson
e6e4362901 [ubsan] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-19 12:04:08 -08:00
Paul Robinson
fbe3f89bcf [tsan] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-19 11:32:38 -08:00
Paul Robinson
975fa72506 [sanitizer-common] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-19 11:01:09 -08:00
Paul Kirth
c42e50fede Reland "[pgo] Avoid introducing relocations by using private alias"
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

New compiler-rt tests are Linux only for now.

Previous versions of this patch allowed the compiler to name the
generated alias, but that would only be valid when the functions were
local. Since the alias may be used across TUs we use a more
deterministic naming convention, and add a `.local` suffix to the alias
name just as we do for relative vtables aliases.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2022-12-19 18:45:58 +00:00
Paul Robinson
2f6439bcf9 [profile] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-19 09:44:49 -08:00
Paul Robinson
02012a78b8 [msan] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-19 06:44:42 -08:00
Paul Robinson
0773a5cbe8 [lsan] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-19 06:26:15 -08:00
Paul Robinson
5bdb9254d9 [fuzzer] Fix UNSUPPORTED criteria for two tests
Fuzzer might decide on a target arch different from the triple.
2022-12-16 12:48:16 -08:00
Paul Robinson
8a86860207 [fuzzer] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-16 11:41:53 -08:00
Paul Robinson
714301d784 [compiler-rt/cfi] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-16 11:10:27 -08:00
Paul Robinson
bc5e385e2f [compiler-rt/builtins] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-16 11:03:45 -08:00
Paul Robinson
38e9660eaa [asan] Convert more tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-16 10:36:48 -08:00
Paul Robinson
abd09754ed [asan] Convert tests to check 'target=...'
Part of the project to eliminate special handling for triples in lit
expressions.
2022-12-16 09:09:38 -08:00
Gulfem Savrun Yeniceri
59b3d8f1db Revert "[profile] Add binary ids into indexed profiles"
This reverts commit 7734053fd9
because it broke powerpc64 bot:
https://lab.llvm.org/buildbot#builders/231/builds/6229
2022-12-14 21:48:41 +00:00
Gulfem Savrun Yeniceri
7734053fd9 [profile] Add binary ids into indexed profiles
This patch adds support for including binary ids in an indexed profile.
It adds a new field into the header that points to the offset of the
binary id section. The binary id section consists of a size of the
section, and a list of binary ids (if they are present) that consist
of two parts: length and data.

This patch guarantees that indexed profile is backwards compatible
after adding binary ids.

Differential Revision: https://reviews.llvm.org/D135929
2022-12-14 20:26:36 +00:00
Nikita Popov
fe0bd3e24e [compiler-rt] Convert profile tests to opaque pointers (NFC) 2022-12-14 16:45:19 +01:00
Alexey Baturo
847fa84b3d [RISC-V][HWASAN] Adjust lit test support for RISC-V HWASAN feature
Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D131344
2022-12-14 16:13:55 +03:00
Roy Sundahl
b076e515a0 [ubsan][test] Be more specific than "error:" with implicit-check-not
The string "error:" is too general and reports false positive from system
messages that can occur on stderr when using network devices for testing.
The string "runtime error:" is sufficiently unique for these connection
errors to pass through w/o a false positive.

rdar://100564373

Reviewed By: thetruestblue

Differential Revision: https://reviews.llvm.org/D139230
2022-12-13 17:18:55 -08:00
Haowei Wu
beb3fa2d2e Revert "Reland "[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests""
This reverts commit 255c3e3dcb, which
breaks Msan-x86_64-Test.
2022-12-13 16:38:12 -08:00
Rainer Orth
255c3e3dcb Reland "[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests"
When trying to debug some `compiler-rt` unittests, I initially had a hard
time because

- even in a `Debug` build one needs to set `COMPILER_RT_DEBUG` to get
  debugging info for some of the code and
- even so the unittests used a hardcoded `-O2` which often makes debugging
  impossible.

This patch addresses this by instead using `-O0` if `COMPILER_RT_DEBUG`.

Changes relative to the previous commit:

- Use `string(APPEND)` for `COMPILER_RT_TEST_COMPILER_CFLAGS`.
- Omit `-O3` from `COMPILER_RT_TEST_COMPILER_CFLAGS` in non-debug builds for now.
- Provide `__sanitizer::integral_constant<bool, true>::value` instantiation
  for `sanitizer_type_traits_test.cpp` in debug builds.
- Disable subtests of `tsan/tests/unit/tsan_trace_test.cpp` that deadlock
  in debug builds.
- `XFAIL` `tsan/Linux/check_memcpy.c` in debug builds.

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

Differential Revision: https://reviews.llvm.org/D91620
2022-12-13 10:58:58 +01:00
Blue Gaston
c6e83ddb37 [Sanitizers][CFG][arm64e] Fix test because -fsanitize-coverage=control-flow does not sign BB entry
-fsanitize-coverage=control-flow does not sign entries into basic blocks on arm64e. This test compares a local pointer to a function [signed] with the basic block pointer. Because the entry into the
basic block is unsigned the addresses being compared are signed and unsigned, causing the path never to be taken.
This is a "bandaid" to get this test passing. We strip the signed bits from the pointer to the local functions so that the comparisons pass.
Filed radar: rdar://103042879 to note the behavior.

context: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp#L1068
    // blockaddress can not be used on function's entry block.
    if (&BB == &F.getEntryBlock())
      CFs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
    else
      CFs.push_back((Constant *)IRB.CreatePointerCast(BlockAddress::get(&BB),
                                                      IntptrPtrTy));
BlockAddress::get is responsible for signing the pointer.

Because of:
https://reviews.llvm.org/D133157

rdar://103042879

Differential Revision: https://reviews.llvm.org/D139661
2022-12-12 20:32:30 -08:00
Nikita Popov
fe516316e5 [Clang] Update compiler-rt sanitizer test to use opaque pointers (NFC) 2022-12-12 17:48:11 +01:00
Dmitry Vyukov
5addb736a9 sanmd: improve precision of UAR analysis
Only mark functions that have address-taken locals
as requiring UAR checking.

On a large internal app this reduces number of marked functions
from 78441 to 66618. Mostly small, trivial getter/setter-type
functions are unmarked, but also some amount of larger
number-crunching-type functions are unmarked as well.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D139811
2022-12-12 11:41:59 +01:00
Andrew Browne
5bb06c7cce [DFSan] Add callback that allows to track which function tainted data reaches.
Authored-by: Christopher Liebchen <liebchen@google.com>
Co-authored-by: Andrew Browne <browneee@google.com>

Reviewed By: browneee

Differential Revision: https://reviews.llvm.org/D139543
2022-12-11 23:10:17 -08:00
Paul Kirth
7597beac9d Revert "Reland "[pgo] Avoid introducing relocations by using private alias""
This reverts commit e89e8dcfad.

Some configurations still have references to discarded sections. I'm
reverting until these can be addressed.
2022-12-09 04:33:09 +00:00
Paul Kirth
e89e8dcfad Reland "[pgo] Avoid introducing relocations by using private alias"
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

This version makes the new runtime test a Linux only test.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2022-12-09 01:28:24 +00:00
Paul Kirth
7710e0e270 Revert "Reland "[pgo] Avoid introducing relocations by using private alias""
This reverts commit 3cfaea2d49.

The runtime test fails on Mac.
2022-12-09 00:23:57 +00:00
Paul Kirth
3cfaea2d49 Reland "[pgo] Avoid introducing relocations by using private alias"
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

This disables the failing runtime test on Windows, since the compiler
options (-fPIC) are unsupported on that platform.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2022-12-08 21:03:37 +00:00
Paul Kirth
0adc577c11 Revert "Reland "[pgo] Avoid introducing relocations by using private alias"""
This reverts commit 071c39df86.

One of the new runtimes tests causes a failure with MSVC, so I'm
reverting until the test can be fixed.
2022-12-08 18:15:55 +00:00
Paul Kirth
071c39df86 Reland "[pgo] Avoid introducing relocations by using private alias""
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D137982
2022-12-08 17:37:17 +00:00
Youling Tang
b89b42b31c [tsan] Add tsan support for loongarch64
This patch enabled tsan for loongarch64 with 47-bit VMA layout. All
tests are passing.

Also adds assembly routines to enable setjmp/longjmp for loongarch64
on linux.

Reviewed By: dvyukov, SixWeining, #sanitizers

Differential Revision: https://reviews.llvm.org/D138489
2022-12-08 10:08:49 +08:00
Nico Weber
9531fc37fb Unbreak check-all on macOS after dbe8c2c316
`${X86_64}` expands to `x86_64;x86_64h` on macOS, so

    get_test_cc_for_arch(${X86_64} METADATA_TEST_TARGET_CC METADATA_TEST_TARGET_CFLAGS)

calls the macro get_test_cc_for_arch() with the four arguments
`x86_64`, `x86_64h`, `METADATA_TEST_TARGET_CC`, and `METADATA_TEST_TARGET_CFLAGS`.

This writes the compiler into a variable called x86_64h, the cflags into a
variable called METADATA_TEST_TARGET_CC, and silently ignores the fourth
parameter.

As a fix, just pass `x86_64` instead of `${X86_64}`. Hopefully
that won't break anything on other platforms.
2022-12-06 10:19:58 -05:00
Dmitry Vyukov
08742e72a3 compiler-rt/test/metadata: restrict tests to x86_64
aarch64 builder broke with:

-- Supported architectures for crt: aarch64
CMake Error at compiler-rt/cmake/config-ix.cmake:244 (message):
  Unsupported architecture: x86_64
Call Stack (most recent call first):
  compiler-rt/cmake/config-ix.cmake:280 (get_target_flags_for_arch)
  compiler-rt/test/metadata/CMakeLists.txt:7 (get_test_cc_for_arch)
-- Configuring incomplete, errors occurred!

https://lab.llvm.org/buildbot/#/builders/223/builds/11423

Restrict the tests to x86_64 only.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D139323
2022-12-05 15:27:21 +01:00
Dmitry Vyukov
dbe8c2c316 Use-after-return sanitizer binary metadata
Currently per-function metadata consists of:
(start-pc, size, features)

This adds a new UAR feature and if it's set an additional element:
(start-pc, size, features, stack-args-size)

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D136078
2022-12-05 14:40:31 +01:00
Vitaly Buka
e92fe7af3f [test][msan] Update for noundef on retval 2022-12-04 22:47:56 -08:00
Mitch Phillips
c414bbefe4 Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.
Leaves the implementation and tests files in-place for right now, but
deletes the ability to build the old sanitizer-common based scudo. This
has been on life-support for a long time, and the newer scudo_standalone
is much better supported and maintained.

Also patches up some GWP-ASan wording, primarily related to the fact
that -fsanitize=scudo now is scudo_standalone, and therefore the way to
reference the GWP-ASan options through the environment variable has
changed.

Future follow-up patches will delete the original scudo, and migrate all
its tests over to be part of the scudo_standalone test suite.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D138157
2022-12-02 11:29:41 -08:00
Shoaib Meenai
442c13f9ff [compiler-rt] Fix check-profile dependencies
It relies on InstrProfData.inc being in the compiler resource directory.

Reviewed By: ellis

Differential Revision: https://reviews.llvm.org/D138969
2022-11-30 11:14:38 -08:00