Commit Graph

15716 Commits

Author SHA1 Message Date
Aaron Ballman 7661d3bc9d Speculatively fix build bots
This should address the issues found by:
https://lab.llvm.org/buildbot/#/builders/105/builds/24292
2022-04-20 12:02:16 -04:00
Aaron Ballman 7d644e1215 [C11/C2x] Change the behavior of the implicit function declaration warning
C89 had a questionable feature where the compiler would implicitly
declare a function that the user called but was never previously
declared. The resulting function would be globally declared as
extern int func(); -- a function without a prototype which accepts zero
or more arguments.

C99 removed support for this questionable feature due to severe
security concerns. However, there was no deprecation period; C89 had
the feature, C99 didn't. So Clang (and GCC) both supported the
functionality as an extension in C99 and later modes.

C2x no longer supports that function signature as it now requires all
functions to have a prototype, and given the known security issues with
the feature, continuing to support it as an extension is not tenable.

This patch changes the diagnostic behavior for the
-Wimplicit-function-declaration warning group depending on the language
mode in effect. We continue to warn by default in C89 mode (due to the
feature being dangerous to use). However, because this feature will not
be supported in C2x mode, we've diagnosed it as being invalid for so
long, the security concerns with the feature, and the trivial
workaround for users (declare the function), we now default the
extension warning to an error in C99-C17 mode. This still gives users
an easy workaround if they are extensively using the extension in those
modes (they can disable the warning or use -Wno-error to downgrade the
error), but the new diagnostic makes it more clear that this feature is
not supported and should be avoided. In C2x mode, we no longer allow an
implicit function to be defined and treat the situation the same as any
other lookup failure.

Differential Revision: https://reviews.llvm.org/D122983
2022-04-20 11:30:12 -04:00
Nico Weber 7d2cc882d5 [compiler-rt][sanitizers] build ubsan, asan etc libraries with Mac Catalyst support
Like D118875, but for ubsan, asan, etc.

With this, I can successfully run:

    bin/clang++ -target x86_64-apple-ios14.0-macabi foo.cc \
        -isysroot $(xcrun -show-sdk-path) -fsanitize=undefined

with a locally built libclang_rt.ubsan_osx_dynamic.dylib.

Differential Revision: https://reviews.llvm.org/D124059
2022-04-20 09:22:25 -04:00
Andrew Browne 204c12eef9 [DFSan] Print an error before calling null extern_weak functions, incase dfsan instrumentation optimized out a null check.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D124051
2022-04-19 17:01:41 -07:00
Kirill Stoimenov ab99a414ef [ASan] Removed checks if the tested functions were emitted.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D124030
2022-04-19 19:20:52 +00:00
Nico Weber f6b2ddbf38 [compiler-rt] Use ld64 flag -lto_library instead of DYLD_LIBRARY_PATH
Makes

 bin/llvm-lit \
  projects/compiler-rt/test/profile/Profile-arm64/instrprof-darwin-dead-strip.c

pass on my machine.

Without this change, ld64 complains that the bitcode was generated by LLVM 15
while the reader is 13.1 -- the version of Xcode on my machine. Looks like the
DYLD_LIBRARY_PATH technique isn't working.

-lto_library was added back in ld64-136, which was in Xcode 4.6, which was
released over 10 years ago. So relying on it should be safe by now.

Differential Revision: https://reviews.llvm.org/D124018
2022-04-19 13:54:57 -04:00
Kirill Stoimenov 64c929ec09 [ASan] Fixed a reporting bug in (load|store)N functions which would print unknown-crash instead of the proper error message when a the data access is unaligned.
Reviewed By: kda, eugenis

Differential Revision: https://reviews.llvm.org/D123643
2022-04-19 15:07:17 +00:00
Kirill Stoimenov 70f13bd752 Revert "[ASan] Fixed a reporting bug in (load|store)N functions which would print unknown-crash instead of the proper error message when a the data access is unaligned."
This reverts commit d81d317999.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D123966
2022-04-18 23:33:41 +00:00
Kirill Stoimenov d81d317999 [ASan] Fixed a reporting bug in (load|store)N functions which would print unknown-crash instead of the proper error message when a the data access is unaligned.
Reviewed By: kda, eugenis

Differential Revision: https://reviews.llvm.org/D123643
2022-04-18 22:46:37 +00:00
Blue Gaston a6efcf1c31 Format fix in recent change. Removed whitespace. [NFC] 2022-04-18 09:23:01 -07:00
Piotr Kubaj 315d792130 [PowerPC] Fix sanitizers build on FreeBSD
1. Add correct pc, sp and bp for FreeBSD.
2. Since there's no personality.h header on FreeBSD, move SANITIZER_PPC64V2
   case below FREEBSD case.
3. __ppc_get_timebase_freq() is glibc-specific. Add a shim for FreeBSD that
   does the same.
2022-04-18 07:16:13 -05:00
Vitaly Buka eb4d22917e [msan] Set poison_in_dtor=1 by default
It's still disabled by default at compile time.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D123875
2022-04-15 14:40:23 -07:00
Brad Smith 8cf83e9659 [VE][compiler-rt] Correct location of VE support in clear_cache function, NFC
Looks like when the VE support was added it was added a few lines below where it should have been.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D123439
2022-04-14 15:50:26 -04:00
Vitaly Buka c36fbe05a7 Revert "[sanitizer] Don't run malloc hooks for stacktraces"
Msan crashes on clang-s390x-linux bot

This reverts commit d3531fc7f0.
2022-04-13 23:52:36 -07:00
Blue Gaston e0c4454465 [Darwin][ASan][Sanitizer] Fixes Sanitizer NonUnique Identifier to Account for Mac arm64 architectures.
Current check assumes iOS as the only Apple devices running arm64.
    ```#if SANITIZER_MAC && !(defined(__arm64__) && SANITIZER_IOS)```
    Stops Apple Silicon from being flagged as requiring unique RTTI.
    This introduced unexpected behavior within the sanitizer.

    rdar://91446703

Differential Revision: https://reviews.llvm.org/D123736
2022-04-13 21:11:37 -07:00
Florian Mayer ffd656a2fe [HWASan] symbolize: use buildid index for locals.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D123644
2022-04-13 19:09:04 -07:00
Vitaly Buka 3a54bbb0f2 [sanitizer] Disable malloc_hook_skip on Darwin
Followup to D123566
2022-04-13 18:34:29 -07:00
Vitaly Buka d3531fc7f0 [sanitizer] Don't run malloc hooks for stacktraces
Usually when we generated stacktraces the process is in error state, so
running hooks may crash the process and prevent meaningfull error report.

Symbolizer, unwinder and pthread are potential source of mallocs.

https://b.corp.google.com/issues/228110771

Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D123566
2022-04-13 16:33:53 -07:00
Julian Lettner 8887c63e32 Adapt "cross compile?" check for Apple Silicon
This piece of code tries to implement the semantics "cross compile?" to
determine CFLAGS used for test binary compilation.
```
if(ANDROID OR ${arch} MATCHES "arm|aarch64|riscv32|riscv64")
```

Since Apple Silicon, macOS runs on arm64e, so we take the wrong branch
when compiling and running tests locally "on the host" on an AS machine.

Furthermore, for Apple code, we use the separate
`get_test_cflags_for_apple_platform` function to determine these test
compiliation flags and `get_test_cc_for_arch` is only ever used in the
"compile & run on host" case, so we can short-curcuit the "cross
compile?" check here.

rdar://91446703

Differential Revision: https://reviews.llvm.org/D123633
2022-04-13 15:26:14 -07:00
Vitaly Buka 5d4df59de1 Revert "[sanitizer] Don't run malloc hooks for stacktraces"
Breaks android and iOS bots.
https://green.lab.llvm.org/green/job/clang-san-iossim/5229/consoleFull#711521816a1ca8a51-895e-46c6-af87-ce24fa4cd561
https://lab.llvm.org/buildbot/#/builders/77/builds/16456

This reverts commit 6345d7f2a8.
2022-04-13 13:13:33 -07:00
Vitaly Buka 6345d7f2a8 [sanitizer] Don't run malloc hooks for stacktraces
Usually when we generated stacktraces the process is in error state, so
running hooks may crash the process and prevent meaningfull error report.

Symbolizer, unwinder and pthread are potential source of mallocs.

https://b.corp.google.com/issues/228110771

Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D123566
2022-04-13 11:44:38 -07:00
Nico Weber ba4537b227 [compiler-rt] Don't explictly ad-hoc sign dylibs on APPLE if ld is new enough
ld64 implicitly ad-hoc code-signs as of Xcode 12, and `strip` and friends know
how keep this special ad-hoc signature valid.

So this should have no effective behavior change, except that you can now strip
libclang_rt.asan_osx_dynamic.dylib and it'll still have a valid ad-hoc
signature, instead of strip printing "warning: changes being made to the file
will invalidate the code signature in:" and making the ad-hoc code signature
invalid.

Differential Revision: https://reviews.llvm.org/D123475
2022-04-13 08:35:51 -04:00
Nikita Popov 69fcf6a79e Revert "[ubsan] Simplify ubsan_GetStackTrace"
This reverts commit 63f2d1f4d4.

I don't quite understand why, but this causes a linker error for
me and a number of buildbots:

/home/npopov/repos/llvm-project/compiler-rt/lib/ubsan/../sanitizer_common/sanitizer_stacktrace.h:130: error: undefined reference to '__sanitizer::BufferedStackTrace::UnwindImpl(unsigned long, unsigned long, void*, bool, unsigned int)'
2022-04-13 10:41:23 +02:00
Fangrui Song 63f2d1f4d4 [ubsan] Simplify ubsan_GetStackTrace
Suggested by Vitaly Buka
2022-04-13 00:32:10 -07:00
Vitaly Buka 12e137ab24 [NFC][sanitizer] Consolidate malloc hook invocations 2022-04-12 20:08:29 -07:00
Vitaly Buka b84673b3f4 [NFC][sanitizer] Remove unnececary HOOK macros 2022-04-12 19:47:44 -07:00
Vitaly Buka 47a9528fb4 [NFC][msan] Rename SymbolizerScope to UnwinderScope and hide 2022-04-12 18:57:54 -07:00
Vitaly Buka ce1cb9d2c1 [NFC][sanitizer] Clang format some code 2022-04-12 18:45:50 -07:00
Fangrui Song 9f526057d6 [ubsan][test] Unsupport Android for new test diag-stacktrace.cpp
https://reviews.llvm.org/D123562#3446485 reported that the test failed
on arm-linux-android.
2022-04-12 12:55:44 -07:00
Fangrui Song fdd424e37a [ubsan] Fix print_stacktrace=1:fast_unwind_on_fatal=0 to correctly fallback to fast unwinder
ubsan_GetStackTrace (from 52b751088b) called by
~ScopeReport leaves top/bottom zeroes in the
`!WillUseFastUnwind(request_fast_unwind)` code path.
When BufferedStackTrace::Unwind falls back to UnwindFast,
`if (stack_top < 4096) return;` will return early, leaving just one frame in the stack trace.

Fix this by always initializing top/bottom like 261d6e05d5.

Reviewed By: eugenis, yln

Differential Revision: https://reviews.llvm.org/D123562
2022-04-12 11:24:19 -07:00
Vitaly Buka 6ddaf0ee71 [sanitizer] Fix internal_mmap in internal symbolizer 2022-04-12 00:39:04 -07:00
Vitaly Buka d5f8b8b6e9 [sanitizer] Fix typo in test 2022-04-11 21:11:28 -07:00
Vitaly Buka 7d6528fc37 [sanitizer] Update undefined symbols of symbolizer 2022-04-11 18:58:56 -07:00
Vitaly Buka 678ef2fbd5 [sanitizer] Make test pass with InternalSymbolizer 2022-04-11 17:36:01 -07:00
Vitaly Buka b87b642aa6 [sanitizer] Fix arg types of internal functions
They didn't match sanitizer_common for 32bit.
2022-04-11 17:36:01 -07:00
Florian Mayer a0570e7750 [HWASan] allow symbolizer script to index binaries by build id.
Tested on an example callstack with misplaced binaries from Android.
Tested Regex against callstack without Build ID to confirm it still works.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D123437
2022-04-11 14:12:31 -07:00
Arthur Eubanks 61d418f971 [test] Remove references to -fexperimental-new-pass-manager in tests
This has been the default for a while and we're in the process of removing the legacy PM optimization pipeline.
2022-04-11 13:29:08 -07:00
Ulrich Weigand f018a5f6e0 [compiler-rt][SystemZ] Skip fuzzer/coverage.test
This test is currently marked as XFAIL on s390x, but it is randomly
passing, causing build bot issues.  Setting as UNSUPPORTED for now.
2022-04-11 16:18:09 +02:00
Aaron Ballman bdbfaf0ca7 Giving a lot more functions prototypes; NFC
This should address https://lab.llvm.org/buildbot/#/builders/37/builds/12315
and speculatively fix other similar diagnostics.
2022-04-09 17:25:10 -04:00
Aaron Ballman 40ef3e6df6 Add some prototypes to these functions; NFC
This is expected to fix the issues in this build bot:
https://lab.llvm.org/buildbot/#/builders/37/builds/12312
2022-04-09 10:53:48 -04:00
Aaron Ballman 5af1ca841f Add some prototypes to these checks; NFC
This should address a build bot failure:
https://lab.llvm.org/buildbot/#/builders/18/builds/4495
2022-04-09 08:38:29 -04:00
Vitaly Buka e03c350eee [sanitizer] Disable new test on Android to fix a bot 2022-04-09 00:57:48 -07:00
Fangrui Song bbb72122aa [scudo][test] Link with -no-pie to be agnostic of CLANG_DEFAULT_PIE_ON_LINUX
This keeps the test behavior unchanged when CLANG_DEFAULT_PIE_ON_LINUX switches
to ON by default.

Note: current clang --target=mips64el-linux-gnu -fpie -pie -fuse-ld=lld
does not link with C++ exceptions, using -pie would lead to

```
ld.lld: error: cannot preempt symbol: DW.ref.__gxx_personality_v0
...
ld.lld: error: relocation R_MIPS_64 cannot be used against local symbol; recompile with -fPIC
...
```

when linking `ScudoUnitTests`: https://lab.llvm.org/buildbot/#/builders/169/builds/7311/steps/18/logs/stdio
2022-04-08 23:30:07 -07:00
Kevin Athey e9c8d0ff71 [MSAN] add __b64_pton and __b64_ntop intercepts
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D122849
2022-04-08 15:22:37 -07:00
Fangrui Song 2aa575fd7f Revert D120327 "compiler-rt: Add udivmodei5 to builtins and add bitint library"
It has several problems like not-compilable weak attribute with MSVC
(and the usage needs further scrutiny), and " different types for formal and actual parameter"
https://lab.llvm.org/buildbot/#/builders/127/builds/27760/steps/7/logs/stdio

This reverts commit 8843245ddd, 492c5c05e1, bf2dc4b376.
2022-04-08 12:39:42 -07:00
Jorge Gorbe Moya 8843245ddd Use portable formatting specified in test. NFCI. 2022-04-08 10:43:20 -07:00
Kevin Athey b401d2a43c Add one more definition for symbols in prctl unit test.
one more follow up to: https://reviews.llvm.org/D122851

Differential Revision: https://reviews.llvm.org/D123404
2022-04-08 09:46:15 -07:00
Kevin Athey 5562d9b3c0 Add definitions for symbols in unit test for prctl.
Follow up to: https://reviews.llvm.org/D122851

Differential Revision: https://reviews.llvm.org/D123395
2022-04-08 08:56:14 -07:00
Nikita Popov 7d2a1b6de4 [Sanitizer] Add -no-opaque-pointers to IR test (NFC)
This test is currently looking for specific typed-pointer IR,
so explicitly disable opaque pointers.
2022-04-08 15:42:05 +02:00
Nikita Popov 3876cd10ae [Profile] Add -no-opaque-pointers to IR tests (NFC)
The output differs slightly with opaque pointers (no GEP constexpr),
add -no-opaque-pointers for now.
2022-04-08 15:42:05 +02:00
Matthias Gehre 492c5c05e1 compiler-rt/lib/builtins/udivmodei5.c: Fix missing macro argument 2022-04-08 10:55:35 +01:00
Matthias Gehre bf2dc4b376 compiler-rt: Add udivmodei5 to builtins and add bitint library
According to the RFC [0], this review contains the compiler-rt parts of large integer divison for _BitInt.

It adds the functions
```
/// Computes the unsigned division of a / b for two large integers
/// composed of n significant words.
/// Writes the quotient to quo and the remainder to rem.
///
/// \param quo The quotient represented by n words. Must be non-null.
/// \param rem The remainder represented by n words. Must be non-null.
/// \param a The dividend represented by n + 1 words. Must be non-null.
/// \param b The divisor represented by n words. Must be non-null.

/// \note The word order is in host endianness.
/// \note Might modify a and b.
/// \note The storage of 'a' needs to hold n + 1 elements because some
///       implementations need extra scratch space in the most significant word.
///       The value of that word is ignored.
COMPILER_RT_ABI void __udivmodei5(su_int *quo, su_int *rem, su_int *a,
                                  su_int *b, unsigned int n);

/// Computes the signed division of a / b.
/// See __udivmodei5 for details.
COMPILER_RT_ABI void __divmodei5(su_int *quo, su_int *rem, su_int *a, su_int *b,
                                 unsigned int words);
```
into builtins.
In addition it introduces a new "bitint" library containing only those new functions,
which is meant as a way to provide those when using libgcc as runtime.

[0] https://discourse.llvm.org/t/rfc-add-support-for-division-of-large-bitint-builtins-selectiondag-globalisel-clang/60329

Differential Revision: https://reviews.llvm.org/D120327
2022-04-08 07:43:15 +01:00
Michael Forney 795b07f549 [asan] Always skip first object from dl_iterate_phdr
All platforms return the main executable as the first dl_phdr_info.
FreeBSD, NetBSD, Solaris, and Linux-musl place the executable name
in the dlpi_name field of this entry. It appears that only Linux-glibc
uses the empty string.

To make this work generically on all platforms, unconditionally
skip the first object (like is currently done for FreeBSD and NetBSD).
This fixes first DSO detection on Linux-musl. It also would likely
fix detection on Solaris/Illumos if it were to gain PIE support
(since dlpi_addr would not be NULL).

Additionally, only skip the Linux VDSO on linux.

Finally, use the empty string as the "seen first dl_phdr_info"
marker rather than (char *)-1. If there was no other object, we
would try to dereference it for a string comparison.

Reviewed By: MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D119515
2022-04-07 22:35:24 -07:00
Kevin Athey 0713053e4a [MSAN] extend prctl interceptor to support PR_SCHED_CORE
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D122851
2022-04-07 16:49:25 -07:00
Pengxuan Zheng 1c9415806b [compiler-rt][builtins] Move DMB definition to syn-ops.h
Compiler-rt cross-compile for ARMv5 fails because D99282 made it an error if DMB
is used for any pre-ARMv6 targets. More specifically, the "#error only supported
on ARMv6+" added in D99282 will cause compilation to fail when any source file
which includes assembly.h are compiled for pre-ARMv6 targets. Since the only
place where DMB is used is syn-ops.h (which is only included by
arm/sync_fetch_and_* and these files are excluded from being built for older
targets), this patch moves the definition there to avoid the issues described
above.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D123105
2022-04-07 14:57:41 -07:00
Fangrui Song 2edd903c05 [crt][test] Fix dso_handle.cpp for Linux systems which default to PIE 2022-04-07 09:37:59 -07:00
Petr Hosek f5e48a2ad3 [CMake][compiler-rt] Include the missing variables
This includes the missing variables as pointed out in
https://reviews.llvm.org/rGb0e2ffe151c3
2022-04-06 17:40:29 -07:00
Blue Gaston fc4c872d8f [Darwin][ASan] Fix "interceptor working?" check for DriverKit platform
The previous check for interceptors used `pthread_create()` which is not
available on DriverKit.  We need an intercepted symbol that satisfies
the following constraints:

- Symbol is available in DriverKit
- Symbol is provided by simulator runtime dylibs (`dlsym()` fails to
  look up host-provided symbols)

`puts()` satisfies all of the above constraints.

rdar://87895539

Reviewed By: yln

Differential Revision: https://reviews.llvm.org/D123245
2022-04-06 15:49:22 -07:00
Petr Hosek b0e2ffe151 [CMake][compiler-rt] Make CRT separately buildable
This is useful when building a complete toolchain to ensure that CRT
is built after builtins but before the rest of the compiler-rt.

Differential Revision: https://reviews.llvm.org/D120682
2022-04-06 00:48:49 -07:00
Petr Hosek 1558cddedb Revert "[CMake][compiler-rt] Make CRT separately buildable"
This reverts commit b89b18e350 since
it broke the sanitizer bots.
2022-04-06 00:01:06 -07:00
Petr Hosek b89b18e350 [CMake][compiler-rt] Make CRT separately buildable
This is useful when building a complete toolchain to ensure that CRT
is built after builtins but before the rest of the compiler-rt.

Differential Revision: https://reviews.llvm.org/D120682
2022-04-05 22:58:38 -07:00
Roy Sundahl 47e7a22471 [Darwin][ASan][Sanitizer] Enable dlclose-test for all darwin targets.
Test was being skipped on non-x86 darwin architectures.

rdar://79795770

Differential Revision: https://reviews.llvm.org/D123099
2022-04-05 12:21:36 -07:00
Andrew Browne 5748219fd2 [DFSan] Add dfsan-combine-taint-lookup-table option as work around for
false negatives when dfsan-combine-pointer-labels-on-load=0 and
dfsan-combine-offset-labels-on-gep=0 miss data flows through lookup tables.

Example case:
628a2825f8/absl/strings/ascii.h (L182)

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D122787
2022-04-05 11:05:10 -07:00
Alex Brachet 016e59bf2c Revert "[Scudo] enabling anonymous named pages on Linux 5.17 and onwards."
This reverts commit 6194992523.
2022-04-05 16:38:49 +00:00
David Carlier 6194992523 [Scudo] enabling anonymous named pages on Linux 5.17 and onwards.
Reviewers: vitalybuka

Reviewed-By: vitalybuka

Differential Revision: https://reviews.llvm.org/D122962
2022-04-05 09:46:02 +01:00
Dmitry Vyukov ea624e697b sanitizer_common: add Mutex::TryLock
Will be used in future changes.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D122905
2022-04-01 17:56:19 +02:00
Dmitry Vyukov abc51fac09 sanitizer_common: expose max_address from LoadedModule
Currently LoadedModule provides max_executable_address.
Replace it with just max_address.
It's only used for printing for human inspection and since
modules are non-overlapping, max_address is as good as max_executable_address
for matching addresses/PCs against modules (I assume it's used for that).
On the hand, max_address is more general and can used to match e.g. data addresses.
I want to use it for that purpose in future changes.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D122906
2022-04-01 17:56:03 +02:00
Michał Górny fd1da784ac [compiler-rt] [scudo] Use -mcrc32 on x86 when available
Update the hardware CRC32 logic in scudo to support using `-mcrc32`
instead of `-msse4.2`.  The CRC32 intrinsics use the former flag
in the newer compiler versions, e.g. in clang since 12fa608af4.
With these versions of clang, passing `-msse4.2` is insufficient
to enable the instructions and causes build failures when `-march` does
not enable CRC32 implicitly:

    /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/scudo_crc32.cpp:20:10: error: always_inline function '_mm_crc32_u32' requires target feature 'crc32', but would be inlined into function 'computeHardwareCRC32' that is compiled without support for 'crc32'
      return CRC32_INTRINSIC(Crc, Data);
             ^
    /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/scudo_crc32.h:27:27: note: expanded from macro 'CRC32_INTRINSIC'
    #  define CRC32_INTRINSIC FIRST_32_SECOND_64(_mm_crc32_u32, _mm_crc32_u64)
                              ^
    /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/../sanitizer_common/sanitizer_platform.h:132:36: note: expanded from macro 'FIRST_32_SECOND_64'
    #  define FIRST_32_SECOND_64(a, b) (a)
                                       ^
    1 error generated.

For backwards compatibility, use `-mcrc32` when available and fall back
to `-msse4.2`.  The `<smmintrin.h>` header remains in use as it still
works and is compatible with GCC, while clang's `<crc32intrin.h>`
is not.

Use __builtin_ia32*() rather than _mm_crc32*() when using `-mcrc32`
to preserve compatibility with GCC.  _mm_crc32*() are aliases
to __builtin_ia32*() in both compilers but GCC requires `-msse4.2`
for the former, while both use `-mcrc32` for the latter.

Originally reported in https://bugs.gentoo.org/835870.

Differential Revision: https://reviews.llvm.org/D122789
2022-04-01 13:00:21 +02:00
Nikita Popov 985c717cdb Revert "[compiler-rt] [scudo] Use -mcrc32 on x86 when available"
This reverts commit 09b53121c3.

Breaks the build with GCC 11.2 on x86_64:

In file included from /home/npopov/repos/llvm-project/compiler-rt/lib/scudo/scudo_crc32.h:27,
                 from /home/npopov/repos/llvm-project/compiler-rt/lib/scudo/scudo_crc32.cpp:14:
/usr/lib/gcc/x86_64-redhat-linux/11/include/smmintrin.h: In function ‘__sanitizer::u32 __scudo::computeHardwareCRC32(__sanitizer::u32, __sanitizer::uptr)’:
/usr/lib/gcc/x86_64-redhat-linux/11/include/smmintrin.h:846:1: error: inlining failed in call to ‘always_inline’ ‘long long unsigned int _mm_crc32_u64(long long unsigned int, long long unsigned int)’: target specific option mismatch
  846 | _mm_crc32_u64 (unsigned long long __C, unsigned long long __V)
2022-04-01 09:40:48 +02:00
Julian Lettner a5228bcaad [Darwin] Limit parallelism for sanitizer tests that use shadow memory on AS
On Darwin, we want to limit the parallelism during test execution for
sanitizer tests that use shadow memory.  The reason is explained by this
existing comment:

> Only run up to 3 processes that require shadow memory simultaneously
> on 64-bit Darwin. Using more scales badly and hogs the system due to
> inefficient handling of large mmap'd regions (terabytes) by the
> kernel.

Previously we detected 3 cases:
* on-device: limit to 1 process
* 64-bit: macOS & simulators, limit to 3 processes
* others (32-bit): no limitation

We checked for the 64-bit case like this: `if arch in ['x86_64',
'x86_64h']` which misses macOS running on AS. Additionally, we don't
care about 32-bit anymore, so I've simplified this to 2 cases: on-device
and everything else.

Differential Revision: https://reviews.llvm.org/D122751
2022-03-31 14:43:28 -07:00
Michał Górny 09b53121c3 [compiler-rt] [scudo] Use -mcrc32 on x86 when available
Update the hardware CRC32 logic in scudo to support using `-mcrc32`
instead of `-msse4.2`.  The CRC32 intrinsics use the former flag
in the newer compiler versions, e.g. in clang since 12fa608af4.
With these compilers, passing `-msse4.2` is insufficient to enable
the instructions and causes build failures when `-march` does not enable
CRC32:

    /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/scudo_crc32.cpp:20:10: error: always_inline function '_mm_crc32_u32' requires target feature 'crc32', but would be inlined into function 'computeHardwareCRC32' that is compiled without support for 'crc32'
      return CRC32_INTRINSIC(Crc, Data);
             ^
    /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/scudo_crc32.h:27:27: note: expanded from macro 'CRC32_INTRINSIC'
    #  define CRC32_INTRINSIC FIRST_32_SECOND_64(_mm_crc32_u32, _mm_crc32_u64)
                              ^
    /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/../sanitizer_common/sanitizer_platform.h:132:36: note: expanded from macro 'FIRST_32_SECOND_64'
    #  define FIRST_32_SECOND_64(a, b) (a)
                                       ^
    1 error generated.

For backwards compatibility, use `-mcrc32` when available and fall back
to `-msse4.2`.  The `<smmintrin.h>` header remains in use as it still
works and is compatible with GCC, while clang's `<crc32intrin.h>`
is not.

Originally reported in https://bugs.gentoo.org/835870.

Differential Revision: https://reviews.llvm.org/D122789
2022-03-31 17:49:42 +02:00
Carlo Marcelo Arenas Belón 81f5c6270c [compiler-rt] Implement __clear_cache on FreeBSD/powerpc
dd9173420f (Add clear_cache implementation for ppc64. Fix buffer to
meet ppc64 alignment., 2017-07-28), adds an implementation for
__builtin___clear_cache on powerpc64, which was promptly ammended to
also be used with big endian mode in f67036b62c (This ppc64 implementation
of clear_cache works for both big and little endian., 2017-08-02)

clang will use this implementation for it's builtin on FreeBSD and result
in an abort() in the cases where 32-bit generation was requested (ex in
macppc or when the big endian powerpc64 build was done with "-m32") and as
reported[1] recently with pcre2, but there is no reason why the same code
couldn't be used in those cases, so use instead the more generic identifier
for the PowerPC architecture.

While at it, update the comment to reflect that POWER8/9 have a 128 byte
wide cache line and so the code could instead use 64 byte windows instead
but that possible optimization has been punted for now.

[1] https://github.com/PhilipHazel/pcre2/issues/92

Reviewed By: jhibbits, #powerpc, MaskRay

Differential Revision: https://reviews.llvm.org/D122640
2022-03-31 14:19:26 +00:00
Argyrios Kyrtzidis 5426da8ffa [Support/BLAKE3] Re-enable building with the simd-optimized implementations, v2
* Support compiling with clang-5
* Check for `LLVM_DISABLE_ASSEMBLY_FILES` and have it set by
  `compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh`
  which wants to receive and process only bitcode files.
2022-03-31 01:00:03 -07:00
Dominic Chen 5fd0925bc9 [scudo] Reland: Add noreturn/pragma to suppress compiler warnings
Differential Revision: https://reviews.llvm.org/D121853
2022-03-30 11:42:20 -07:00
Julian Lettner 15c4239dff Do not generate x86_64 test targets on AS hosts
Differential Revision: https://reviews.llvm.org/D122700
2022-03-30 11:31:11 -07:00
Dominic Chen 22a95dd3e6 Revert "[scudo] Wrap clang pragma to avoid GCC error"
Revert "[scudo] Add noreturn/pragma to suppress compiler warnings"

This reverts commit 686dcbe8b0.
This reverts commit 030d8262a6.
2022-03-29 17:52:20 -07:00
Dominic Chen 6ba8c8abe9 [scudo] Provide allocator declaration
Ensure that extern allocator declaration is visible before definition

Differential Revision: https://reviews.llvm.org/D121848
2022-03-29 17:39:45 -07:00
Dominic Chen 030d8262a6 [scudo] Wrap clang pragma to avoid GCC error
Fixes: [scudo] Add noreturn/pragma to suppress compiler warnings

Differential Revision: https://reviews.llvm.org/D121853
2022-03-29 17:36:33 -07:00
Roland McGrath fd7ec90abd [lsan] On Fuchsia, don't use atexit hook for leak checks
This is a re-land of https://reviews.llvm.org/D86171 with fix.

Fuchsia's system libraries are instrumented and use the lsan
allocator for internal purposes.  So leak checking needs to run
after all atexit hooks and after the system libraries' internal
exit-time hooks.  The <zircon/sanitizer.h> hook API calls the
__sanitizer_process_exit_hook function at exactly the right time.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D88248
2022-03-29 17:13:55 -07:00
Dominic Chen 686dcbe8b0 [scudo] Add noreturn/pragma to suppress compiler warnings
Differential Revision: https://reviews.llvm.org/D121853
2022-03-29 14:26:15 -07:00
Dominic Chen db13f5a1b0 [scudo] Add missing include for extern variable declaration
Add include to resolve compiler warning about no previous extern declaration for non-static HashAlgorithm

Differential Revision: https://reviews.llvm.org/D122630
2022-03-29 14:26:15 -07:00
Dominic Chen d0eeb0fba0 [scudo] Fix definition of canCache() function
The called member function has boolean type, change this function to match

Differential Revision: https://reviews.llvm.org/D122631
2022-03-29 14:26:15 -07:00
Dominic Chen 92897217fa [scudo] Initialize local variable to avoid compiler warning
Compiler warns about HeaderPos possibly being uninitialized which should not be possible, but just initialize it anyway

Differential Revision: https://reviews.llvm.org/D122632
2022-03-29 14:26:15 -07:00
Vitaly Buka 01daf97a0b [NFC] clang-format sanitizer_interface_internal.h 2022-03-29 13:29:07 -07:00
Dominic Chen 0e1d2007aa [scudo] Use template specialization on Quarantine to avoid zero-length array
Use a separate templated QuarantineBlocks class to avoid a zero-length array

Differential Revision: https://reviews.llvm.org/D122518
2022-03-28 21:35:49 -07:00
Dominic Chen a52868a55c Revert "[scudo] Use template specialization on Quarantine to avoid zero-length array"
This reverts commit 7dda44c189.
2022-03-28 19:08:55 -07:00
Dominic Chen 9343fc7613 [scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow
Platforms may define uintptr_t differently, so perform an explicit cast

Differential Revision: https://reviews.llvm.org/D121852
2022-03-28 16:36:30 -07:00
Dominic Chen 7dda44c189 [scudo] Use template specialization on Quarantine to avoid zero-length array
Use a separate templated QuarantineBlocks class to avoid a zero-length array

Differential Revision: https://reviews.llvm.org/D122518
2022-03-28 16:36:25 -07:00
Roland McGrath 4e731abc55 [compiler-rt][AArch64] Initialize __aarch64_have_lse_atomics for Fuchsia
Use Fuchsia's zx_system_get_features API to determine
whether LSE atomics are available on the machine.

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D118839
2022-03-28 11:49:31 -07:00
Roland McGrath 39294589bf sanitizer_common: Remove Fuchsia support for reading flags from files
This has never really been used in practice.  Fuchsia is moving
away from the support this requires, so don't use it.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D122500
2022-03-28 10:54:04 -07:00
Kirill Stoimenov dd67e6972f [ASan] Reland of D116182 to always link asan_static library.
After landing D121813 the binary size increase introduced by this change can be minimized by using --gc-sections link options. D121813 allows each individual callbacks to be optimized out if not used.

Reviewed By: vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D122407
2022-03-24 19:32:23 +00:00
Dmitry Vyukov 1d4d2cceda [TSan] Add a runtime flag to print full thread creation stacks up to the main thread
Currently, we only print how threads involved in data race are created from their parent threads.
Add a runtime flag 'print_full_thread_history' to print thread creation stacks for the threads involved in the data race and their ancestors up to the main thread.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D122131
2022-03-24 17:30:27 +01:00
Martin Storsjö 98885c4e14 [compiler-rt] [cmake] Fix a typo in a variable name
There's no other references to this variable name, but other files
refer to the same with the same name but with double Fs.
2022-03-24 14:37:59 +02:00
Mitch Phillips 0f6d9501cf [NFCI] Fix set-but-unused warning in asan_fake_stack.cpp 2022-03-23 15:45:09 -07:00
Frederic Cambus 45c673816e [compiler-rt] Remove forgotten mention of SVN modules, LLVM now uses Git. 2022-03-23 15:29:30 +01:00
Danny Mösch a749e3295d Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
Snehasish Kumar 61c75eb637 [memprof] Initialize MemInfoBlock data.
This patch updates the existing default no-arg constructor for
MemInfoBlock to explicitly initialize all members. Also add missing
DataTypeId initialization to the other constructor. These issues were
exposed by msan on patch D121179. With this patch D121179 builds cleanly
on msan.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D122260
2022-03-22 14:35:57 -07:00
Frederic Cambus bc01d8fbcf [compiler-rt] Remove mentions of AuroraUX in code comments and docs.
AuroraUX was an operating system project based on an OpenSolaris kernel
and an Ada userland.

There appear to be no public code or release available online anymore.
The project page on Wikipedia [1] was deleted in January 2012, and a news
item [2] from November 2012 has more details.

[1] https://en.wikipedia.org/w/index.php?title=Special:Log/delete&page=AuroraUX
[2] https://www.phoronix.com/scan.php?page=news_item&px=MTIyMTI
2022-03-21 22:05:58 +01:00
James Y Knight 4a6fab793f [compiler-rt] Expand comment about Exynos 9810 workaround. 2022-03-21 13:35:11 +00:00
Dominic Chen 58a583c229 [scudo] Fix static and unused function type annotations
Differential Revision: https://reviews.llvm.org/D121855
2022-03-18 12:52:29 -07:00
Dominic Chen 26a5f9bd03 [scudo] Don't assume preprocessor macro is defined
Differential Revision: https://reviews.llvm.org/D121857
2022-03-18 12:52:18 -07:00
Dmitry Vyukov 9e66e5872c tsan: print signal num in errno spoiling reports
For errno spoiling reports we only print the stack
where the signal handler is invoked. And the top
frame is the signal handler function, which is supposed
to give the info for debugging.
But in same cases the top frame can be some common thunk,
which does not give much info. E.g. for Go/cgo it's always
runtime.cgoSigtramp.

Print the signal number.
This is what we can easily gather and it may give at least
some hints regarding the issue.

Reviewed By: melver, vitalybuka

Differential Revision: https://reviews.llvm.org/D121979
2022-03-18 16:12:11 +01:00
Dominic Chen 58b6521eb5 [scudo] Use portable sysconf instead of deprecated getpagesize
Differential Revision: https://reviews.llvm.org/D121859
2022-03-17 11:02:26 -07:00
Dominic Chen 6ce08d5c27 [scudo][tests] Pass read-only vector by reference
Differential Revision: https://reviews.llvm.org/D121850
2022-03-17 10:17:36 -07:00
Dominic Chen 03e82d94fc [scudo] Fix test harness integration
Explicitly specify the class name to avoid selecting the wrong Run function, and inherit from the correct Test parent

Differential Revision: https://reviews.llvm.org/D121854
2022-03-17 10:17:36 -07:00
Dominic Chen 7abd6837a0 [scudo] Use nullptr instead of integer-to-pointer cast
Differential Revision: https://reviews.llvm.org/D121856
2022-03-17 10:17:36 -07:00
Dominic Chen 4787e5c34e [scudo] Don't unmap other low memory pages if mapping doesn't exist
Tests can register multiple allocators, but only the first will initialize since it initializes the TSDRegistrySharedT. Then, destruction of subsequent allocator may end up unmapping a nullptr PrimaryBase with non-zero PrimarySize.

Differential Revision: https://reviews.llvm.org/D121858
2022-03-17 10:17:36 -07:00
Dominic Chen e536419279 [scudo] Explicitly mark enum as unsigned
Differential Revision: https://reviews.llvm.org/D121860
2022-03-17 10:17:36 -07:00
Dominic Chen a6b7f31895 [scudo] Remove unused vector value initializer
Differential Revision: https://reviews.llvm.org/D121861
2022-03-17 10:17:35 -07:00
Evgenii Stepanov c5ea8e9138 Use-after-dtor detection for trivial base classes.
-fsanitize-memory-use-after-dtor detects memory access after a
subobject is destroyed but its memory is not yet deallocated.
This is done by poisoning each object memory near the end of its destructor.

Subobjects (members and base classes) do this in their respective
destructors, and the parent class does the same for its members with
trivial destructors.

Inexplicably, base classes with trivial destructors are not handled at
all. This change fixes this oversight by adding the base class poisoning logic
to the parent class destructor.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D119300
2022-03-16 18:20:27 -07:00
Kirill Stoimenov d6aa3aa2da [ASan] Added .section statement to each function so they can be removed by --gc-sections.
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D121813
2022-03-16 17:35:15 +00:00
Florian Hahn 8a3d75a760
[ASan] Add read to large_func_test.cpp to prevent optimization.
After e5822ded56, the call to LargeFunction can be optimized out, as x
is never accessed in main. This is causing the test to fail, because the
out-of-bounds access won't be executed.

Adding an extra read and returning the value should prevent the
optimizer from removing the call.
2022-03-16 17:00:32 +00:00
Sam McCall 75acad41bc Use lit_config.substitute instead of foo % lit_config.params everywhere
This mechanically applies the same changes from D121427 everywhere.

Differential Revision: https://reviews.llvm.org/D121746
2022-03-16 09:57:41 +01:00
Manoj Gupta 1f82d0f795 [msan] Add interceptors for Linux 64-bit stat variants
glibc >= 2.33 uses shared functions for stat family functions.
D111984 added support for non-64 bit variants but they
do not appear to be enough as we have been noticing msan
errors on 64-bit stat variants on Chrome OS.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D121652
2022-03-15 20:22:28 -07:00
Vitaly Buka 678f88e0e2 [lsan] Attempt to fix s390x after a63932a8 2022-03-15 18:02:03 -07:00
Tavian Barnes 9a42715ae8 [sanitizer] Always initialize the regex in the regcomp() interceptor
When regcomp() fails, the same regex_t* should be passed to regerror()
for potentially better error messages.  But doing that with msan would
report a use-of-uninitialized-value.

Fixes https://github.com/google/sanitizers/issues/1496

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D120591
2022-03-15 14:30:57 -07:00
Vitaly Buka a63932a815 [lsan] Allow suppression of "unknown module"
If sanitizer cannot determine name of the module it
will use "<unknown module>". Then it can be suppressed
if needed.

Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D121674
2022-03-15 13:35:21 -07:00
Roman Lebedev c62746ac6e
[X86] Fix AMD Znver3 model checks
While `-march=` is correctly detected as `znver3` for the cpu,
apparently the model check is incorrect:
```
$ lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         48 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  32
  On-line CPU(s) list:   0-31
Vendor ID:               AuthenticAMD
  Model name:            AMD Ryzen 9 5950X 16-Core Processor
    CPU family:          25
    Model:               33
    Thread(s) per core:  2
    Core(s) per socket:  16
    Socket(s):           1
    Stepping:            0
    Frequency boost:     disabled
    CPU max MHz:         6017.8462
    CPU min MHz:         2200.0000
    BogoMIPS:            8050.07
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse
                         3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_p
                         state ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbn
                         oinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm
Virtualization features:
  Virtualization:        AMD-V
Caches (sum of all):
  L1d:                   512 KiB (16 instances)
  L1i:                   512 KiB (16 instances)
  L2:                    8 MiB (16 instances)
  L3:                    64 MiB (2 instances)
NUMA:
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-31
Vulnerabilities:
  Itlb multihit:         Not affected
  L1tf:                  Not affected
  Mds:                   Not affected
  Meltdown:              Not affected
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling
  Srbds:                 Not affected
  Tsx async abort:       Not affected
```

Model is 33 (0x21), while the code was expecting it to be `0x00 .. 0x1F`.
https://github.com/torvalds/linux/blob/v5.17-rc8/drivers/hwmon/k10temp.c#L432-L453 agrees.
I'm not sure if other ranges listed here should also be accepted.

I noticed this while implementing CPU model detection
for halide (https://github.com/halide/Halide/pull/6648)

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D121708
2022-03-15 20:28:02 +03:00
Steven Wu e168513aed [ASAN] Fix darwin-interface test
Fix darwin interface test after D121464. asan_rtl_x86_64.S is not
available on Darwin.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D121636
2022-03-15 06:14:07 -07:00
Andrew Browne dbf8c00b09 [DFSan] Remove trampolines to unblock opaque pointers. (Reland with fix)
https://github.com/llvm/llvm-project/issues/54172

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D121250
2022-03-14 16:03:25 -07:00
Andrew Browne edc33fa569 Revert "[DFSan] Remove trampolines to unblock opaque pointers."
This reverts commit 84af90336f.
2022-03-14 13:47:41 -07:00
Andrew Browne 84af90336f [DFSan] Remove trampolines to unblock opaque pointers.
https://github.com/llvm/llvm-project/issues/54172

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D121250
2022-03-14 13:39:49 -07:00
Andrew Browne 18564095a7 [DFSan] Remove use of setarch in dfsan test.
Use of setarch Was added by
f93c2b64ed

Running the test now it doesn't seem necessary because:

1) Explicitly only x86_64 is supported for dfsan.

2) https://reviews.llvm.org/D111522 makes it less flakey.

Differential Revision: https://reviews.llvm.org/D121439
2022-03-14 10:03:51 -07:00
Fangrui Song a53ea51dec [lsan] ppc64: dynamically pick address range for allocator
For ppc64 PIE, it seems that [0xa00000000000,0xc00000000000) may be occupied
which will lead to a segfault in certain kernel configurations
(clang-ppc64le-rhel). Use the `!kUsingConstantSpaceBeg` code path like Fuchsia.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D121257
2022-03-11 20:16:17 -08:00
Khem Raj 5017de8ba4 [builtins] Do not force thumb mode directive in arm/sync-ops.h
.thumb_func was not switching mode until [1]
so it did not show up but now that .thumb_func (without argument) is
switching mode, its causing build failures on armv6 ( rpi0 ) even when
build is explicitly asking for this file to be built with -marm (ARM
mode), therefore use DEFINE_COMPILERRT_FUNCTION macro to add function
header which considers arch and mode from compiler cmdline to decide if
the function is built using thumb mode or arm mode.

[1] https://reviews.llvm.org/D101975

Note that it also needs https://reviews.llvm.org/D99282

Reviewed By: peter.smith, MaskRay

Differential Revision: https://reviews.llvm.org/D104183
2022-03-11 16:25:49 -08:00
Petr Hosek 0c0f6cfb7b [CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE
This clarifies that this is an LLVM specific variable and avoids
potential conflicts with other projects.

Differential Revision: https://reviews.llvm.org/D119918
2022-03-11 15:43:01 -08:00
Kirill Stoimenov d477f1bb15 [ASan] Export optimized callbacks.
This is a part of optimized callback reverts. This is needed to export the callbacks from the rt-asan libraries.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D121464
2022-03-11 17:18:40 +00:00
Khem Raj a11d1cc41c [builtins] Use mcr for dmb instruction on armv6
At present compiler-rt cross compiles for armv6 ( -march=armv6 ) but includes
dmb instructions which are only available in armv7+ this causes SIGILL on
clang+compiler-rt compiled components on rpi0w platforms.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D99282
2022-03-10 19:30:00 -08:00
Kirill Stoimenov 120e0434bc [ASan] Added back @PLT to __asan_report_* calls to avoid compile errors.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D121409
2022-03-10 21:43:00 +00:00
Kirill Stoimenov 035441ff30 [ASan] Moved optimized callbacks out of asan_static to avoid DSO size increase.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D121405
2022-03-10 21:11:32 +00:00
Dmitry Vyukov 66298e1c54 tsan: fix another false positive related to open/close
The false positive fixed by commit f831d6fc80
("tsan: fix false positive during fd close") still happens episodically
on the added more stressful test which does just open/close.

I don't have a coherent explanation as to what exactly happens
but the fix fixes the false positive on this test as well.
The issue may be related to lost writes during asynchronous MADV_DONTNEED.
I've debugged similar unexplainable false positive related to freed and
reused memory and at the time the only possible explanation I found is that
an asynchronous MADV_DONTNEED may lead to lost writes. That's why commit
302ec7b9bc ("tsan: add memory_limit_mb flag") added StopTheWorld around
the memory flush, but unfortunately the commit does not capture these findings.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D121363
2022-03-10 17:02:51 +01:00
Vitaly Buka 43f208e94c [msan] Fix unittest for 9397bdc6
"1.1" is double which can't be represented precicely as a float.
2022-03-10 01:21:30 +00:00
Kevin Athey fc9e07873f Revert "[MSAN] add interceptor for timer_create, timer_settime, timer_gettime"
This reverts commit 0a4dec6cc2.

breaks buildbots
2022-03-09 14:57:05 -08:00
Kevin Athey b5e985e6f3 Revert "[MSAN] adjust Posix/timer.cpp"
This reverts commit f2a9753680.

breaks buildbot
2022-03-09 14:55:12 -08:00
Colin Cross e75f1d3c07 [CompilerRT] Fix build of compiler-rt with musl
Use the correct types for OFF_T, __sanitizer_time_t and
__sanitizer_dirent and forward time_t related functions
 to fix using compiler-rt with 32-bit musl libc.

Also redirect the time_t functions that are affected by
https://musl.libc.org/time64.html to use their 64-bit
ABI names.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D119358
2022-03-09 13:41:30 -08:00
Kevin Athey f2a9753680 [MSAN] adjust Posix/timer.cpp
follow up to 0a4dec6cc2.
add unsupported for s390 (SEGV)
restore line that s390 complains, so following asserts work.

Differential Revision: https://reviews.llvm.org/D121326
2022-03-09 13:02:08 -08:00
Kevin Athey 0a4dec6cc2 [MSAN] add interceptor for timer_create, timer_settime, timer_gettime
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D120602
2022-03-09 11:21:16 -08:00
Petr Hosek b0e369501f Revert "[MSAN] add interceptor for timer_create, timer_settime, timer_gettime"
This reverts commit c2aab0d380 due to
a leak in timer.cpp that showed up on several bots.
2022-03-09 10:46:20 -08:00
Xi Ruoyao db7bca2863 [sanitizer][mips] Fix the condition to include sanitizer_atomic_clang_mips.h
The Glibc header [1] define _ABIO32 unconditionally on MIPS.  So we need
to compare _MIPS_SIM and _ABIO32 to know if we are actually building for
MIPS32.  Using sanitizer_atomic_clang_mips.h can cause test failures and
hangs on MIPS64.

[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/sgidefs.h

Reviewed By: dvyukov, vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D121207
2022-03-09 10:20:05 -08:00
Kevin Athey c2aab0d380 [MSAN] add interceptor for timer_create, timer_settime, timer_gettime
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D120602
2022-03-08 16:59:43 -08:00
Andrew Browne 12bfea58b8 [DFSan] Fix several bugs in dfsan custom callbacks test.
Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D121249
2022-03-08 14:26:28 -08:00
Dmitry Vyukov f831d6fc80 tsan: fix false positive during fd close
FdClose is a subjet to the same atomicity problem as MemoryRangeFreed
(memory state is not "monotoic" wrt race detection).
So we need to lock the thread slot in FdClose the same way we do
in MemoryRangeFreed.
This fixes the modified stress.cpp test.

Reviewed By: vitalybuka, melver

Differential Revision: https://reviews.llvm.org/D121143
2022-03-08 10:40:56 +01:00
Petr Hosek 601022fd96 Revert "[CMake][compiler-rt] Make CRT separately buildable"
This reverts commit ed28461e27 since
it broke the VE bot.
2022-03-07 23:59:29 -08:00
Petr Hosek ed28461e27 [CMake][compiler-rt] Make CRT separately buildable
This is useful when building a complete toolchain to ensure that CRT
is built after builtins but before the rest of the compiler-rt.

Differential Revision: https://reviews.llvm.org/D120682
2022-03-07 23:05:20 -08:00
Kevin Athey 7fbc1f7ebe [MSAN] extend ioctl interceptor to support BLKSSZGET
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D120693
2022-03-04 15:39:30 -08:00
Stella Laurenzo 38151a08c2 Reapply "[cmake] Prefix gtest and gtest_main with "llvm_"."
This reverts commit 7cdda6b8ce.

Differential Revision: https://reviews.llvm.org/D121020
2022-03-04 13:45:43 -08:00
Ellis Hoag 9c35303981 [InstrProf][NFC] Fix warning by removing typecast
This fixes a warning about comparing mismatched types. Since `mmap()` already returns a `void *` use that as the pointer type for comparison.

Reviewed By: kyulee, zequanwu

Differential Revision: https://reviews.llvm.org/D120945
2022-03-04 10:48:25 -08:00
Colin Cross bcc65fb491 Pass through more LIBCXX_* variables to libfuzzer's custom lib++
Pass LIBCXX_HAS_PTHREAD_LIB, LIBCXX_HAS_RT_LIB  and LIBCXXABI_HAS_PTHREAD_LIB
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/D120946
2022-03-04 09:31:37 -08:00
Stella Laurenzo 7cdda6b8ce Revert "[cmake] Prefix gtest and gtest_main with "llvm_"."
lldb buildbot failure. will investigate and roll forward.

This reverts commit 9f37775472.
2022-03-02 11:13:46 -08:00
Stella Laurenzo 9f37775472 [cmake] Prefix gtest and gtest_main with "llvm_".
The upstream project ships CMake rules for building vanilla gtest/gmock which conflict with the names chosen by LLVM. Since LLVM's build rules here are quite specific to LLVM, prefixing them to avoid collision is the right thing (i.e. there does not appear to be a path to letting someone *replace* LLVM's googletest with one they bring, so co-existence should be the goal).

This allows LLVM to be included with testing enabled within projects that themselves have a dependency on an official gtest release.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D120789
2022-03-02 10:53:32 -08:00