Commit Graph

4444 Commits

Author SHA1 Message Date
Matthew G McGovern 81b1d3da09 [sanitizers][Windows] Implement __sanitizer_purge_allocator for Win64
Windows' memory unmapping has to be explicit, there is no madvise.
Similarly, re-mapping memory has to be explicit as well. This patch
implements a basic method for remapping memory which was previously
returned to the OS on Windows.

Patch by Matthew G. McGovern and Jordyn Puryear
2021-02-12 09:49:04 -08:00
Vitaly Buka 0b3d31222d [ASAN][NFC] Improve language 2021-02-12 02:55:58 -08:00
Vitaly Buka f2133f2e31 [NFC,memprof] Update test after D96319 2021-02-11 16:36:16 -08:00
Julian Lettner 9360f1a191 [Sanitizer] Fix sanitizer tests without reducing optimization levels
As discussed, these tests are compiled with optimization to mimic real
sanitizer usage [1].

Let's mark relevant functions with `noinline` so we can continue to
check against the stack traces in the report.

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

This reverts commit 04af72c542.

Differential Revision: https://reviews.llvm.org/D96357
2021-02-11 15:22:20 -08:00
Fangrui Song 0dc6122dd3 [asan][test] Fix Linux/odr-violation.cpp on gcc 2021-02-11 09:53:48 -08:00
Adhemerval Zanella 88d1724d9b [sanitizer] Fix suffix-log-path_test.c on arm-linux-gnu
The recent suffix-log-path_test.c checks for a full stacktrace and
since on some arm-linux-gnu configuration the slow unwinder is used
on default (when the compiler emits thumb code as default), it
requires -funwind-tables on tests.

It also seems to fix the issues disable by d025df3c1d.

Reviewed By: ostannard

Differential Revision: https://reviews.llvm.org/D96337
2021-02-11 14:26:04 -03:00
Vedant Kumar 897bec937e [test/ubsan] Allow unused FileCheck prefixes in TypeCheck/vptr.cpp
This test started failing after https://reviews.llvm.org/D95849
defaulted --allow-unused-prefixes to false.

Taking a look at the test, I didn't see an obvious need to add
OS-specific check lines for each supported value of %os.

rdar://74207657
2021-02-10 16:06:51 -08:00
Fangrui Song 096f547208 [asan][test] Fix Linux/odr-violation.cpp after symbolizer change D95927 2021-02-10 14:27:12 -08:00
Todd Lipcon 5dd29d9922
Fix xray fdr mode to allow multiple flushes
Reviewed By: dberris

Differential Revision: https://reviews.llvm.org/D96382
2021-02-10 12:57:24 +11:00
Nico Weber 23cd8d51ad Try to fix compiler-rt tests after 87dbdd2e3b on mac and win
These tests use `--check-prefix=CHECK-%os` but then didn't have
a CHECK line for every os.

In most tests, the linux expectations were sufficient (they match
the "wrap_" prefix with .*), so just remove the check-prefix there.
In the places where this didn't easily work, make sure there are
at least CHECK-Windows and CHECK-Darwin lines.
2021-02-09 09:28:52 -05:00
Julian Lettner 04af72c542 [Sanitizer] Fix failing sanitizer tests
The new pass manager was enabled by default [1].

The commit message states the following relevant differences:
  * The inliner works slightly differently
  * -O1 does some amount of inlining

These tests are affected because they specify `-O1` and then check the
reported stack trace.

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

Differential Revision: https://reviews.llvm.org/D96198
2021-02-08 09:56:32 -08:00
Jianzhou Zhao 0f3fd3b281 [dfsan] Add thread registration
This is a part of https://reviews.llvm.org/D95835.

This change is to address two problems
1) When recording stacks in origin tracking, libunwind is not async signal safe. Inside signal callbacks, we need
to use fast unwind. Fast unwind needs threads
2) StackDepot used by origin tracking is not async signal safe, we set a flag per thread inside
a signal callback to prevent from using it.

The thread registration is similar to ASan and MSan.

Related MSan changes are
* 98f5ea0dba
* f653cda269
* 5a7c364343

Some changes in the diff are used in the next diffs
1) The test case pthread.c is not very interesting for now. It will be
  extended to test origin tracking later.
2) DFsanThread::InSignalHandler will be used by origin tracking later.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D95963
2021-02-05 17:38:59 +00:00
Vitaly Buka 758928e3b8 [sanitizer] Fix the test on android 2021-02-04 18:02:02 -08:00
Amy Huang 8d7d2deb37 Fix test case from D94563.
The added test case failed on ppc, android, and other buildbots,
so require x86 targets.
2021-02-04 16:34:39 -08:00
Amy Huang 4737aab53d Fix a test case after committing D94563.
D94563 implemented `ReadBinaryName` on Windows, which causes a test case
to now pass, so remove the `XFAIL: windows-msvc` line.
2021-02-04 16:06:51 -08:00
Amy Huang 9ba623c655 [asan] Add %d variable to external_symbolizer_path option, so that user can specify paths relative to the location of the binary.
We want way to set a path to llvm-symbolizer that isn't relative
to the current working directory; this change adds a variable that
expands to the path relative to the current binary.
This approach came from comments in https://reviews.llvm.org/D93070

Differential Revision: https://reviews.llvm.org/D94563
2021-02-04 15:43:02 -08:00
Bill Torpey dd5c2b8de9 [sanitizer] Add suffix to report file name
For those using a GUI, it can be very helpful to have a
particular suffix appended to the report file name, so
it can be opened with a double-click.

(see also: https://github.com/google/sanitizers/issues/951)

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D46546
2021-02-04 13:50:11 -08:00
Nico Weber b995314143 Revert "[InstrProfiling] Use !associated metadata for counters, data and values"
This reverts commit 97ba5cde52.
Still breaks tests: https://reviews.llvm.org/D76802#2540647
2021-02-03 19:14:34 -05:00
Vitaly Buka 9da05cf6ed [asan] Fix pthread_create interceptor
AsanThread::Destroy implementation expected to be called on
child thread.

I missed authors concern regarding this reviewing D95184.

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D95731
2021-02-03 12:57:56 -08:00
Jianzhou Zhao 15f26c5f51 [dfsan] Wrap strcat
Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D95923
2021-02-03 18:50:29 +00:00
Jianzhou Zhao eb5c0a90e7 [dfsan] Test IGN and DFL for sigaction
Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D95957
2021-02-03 18:46:49 +00:00
Jianzhou Zhao 93afc3452c [dfsan] Clean TLS after signal callbacks
Similar to https://reviews.llvm.org/D95642, this diff fixes signal.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D95896
2021-02-03 17:21:28 +00:00
Petr Hosek 97ba5cde52 [InstrProfiling] Use !associated metadata for counters, data and values
C identifier name input sections such as __llvm_prf_* are GC roots so
they cannot be discarded. In LLD, the SHF_LINK_ORDER flag overrides the
C identifier name semantics.

The !associated metadata may be attached to a global object declaration
with a single argument that references another global object, and it
gets lowered to SHF_LINK_ORDER flag. When a function symbol is discarded
by the linker, setting up !associated metadata allows linker to discard
counters, data and values associated with that function symbol.

Note that !associated metadata is only supported by ELF, it does not have
any effect on non-ELF targets.

Differential Revision: https://reviews.llvm.org/D76802
2021-02-02 23:19:51 -08:00
Jianzhou Zhao 3f568e1fbb [dfsan] Wrap memmove
Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D95883
2021-02-03 05:15:56 +00:00
Jianzhou Zhao e1a4322f81 [dfsan] Clean TLS after sigaction callbacks
DFSan uses TLS to pass metadata of arguments and return values. When an
instrumented function accesses the TLS, if a signal callback happens, and
the callback calls other instrumented functions with updating the same TLS,
the TLS is in an inconsistent state after the callback ends. This may cause
either under-tainting or over-tainting.

This fix follows MSan's workaround.
  cb22c67a21
It simply resets TLS at restore. This prevents from over-tainting. Although
under-tainting may still happen, a taint flow can be found eventually if we
run a DFSan-instrumented program multiple times. The alternative option is
saving the entire TLS. However the TLS storage takes 2k bytes, and signal calls
could be nested. So it does not seem worth.

This diff fixes sigaction. A following diff will be fixing signal.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D95642
2021-02-02 22:07:17 +00:00
Tom Weaver 4f1320b77d Revert "[InstrProfiling] Use !associated metadata for counters, data and values"
This reverts commit df3e39f60b.

introduced failing test instrprof-gc-sections.c
causing build bot to fail:
http://lab.llvm.org:8011/#/builders/53/builds/1184
2021-02-02 14:19:31 +00:00
Fangrui Song a59283a745 [test] Fix unused FileCheck prefixes in compiler-rt 2021-02-01 22:32:13 -08:00
Fangrui Song 327196d688 [test] Fix unused FileCheck prefixes in compiler-rt/test 2021-02-01 21:24:58 -08:00
Petr Hosek df3e39f60b [InstrProfiling] Use !associated metadata for counters, data and values
C identifier name input sections such as __llvm_prf_* are GC roots so
they cannot be discarded. In LLD, the SHF_LINK_ORDER flag overrides the
C identifier name semantics.

The !associated metadata may be attached to a global object declaration
with a single argument that references another global object, and it
gets lowered to SHF_LINK_ORDER flag. When a function symbol is discarded
by the linker, setting up !associated metadata allows linker to discard
counters, data and values associated with that function symbol.

Note that !associated metadata is only supported by ELF, it does not have
any effect on non-ELF targets.

Differential Revision: https://reviews.llvm.org/D76802
2021-02-01 15:01:43 -08:00
Luís Marques 2de4f19ecd [LSan][RISCV] Enable LSan for RISCV64
Fixes the broken RISCV64 implementation of `internal_clone` and
adds RISCV64 support for LSan.

Differential Revision: https://reviews.llvm.org/D92403
2021-01-31 21:53:25 +00:00
Kostya Kortchinsky ba379fe527 [scudo][standalone] Restore GWP-ASan flag parsing
With D92696, the Scudo Standalone GWP-ASan flag parsing was changed to
the new GWP-ASan optional one. We do not necessarily want this, as this
duplicates flag parsing code in Scudo Standalone when using the
GWP-ASan integration.

This CL reverts the changes within Scudo Standalone, and increases
`MaxFlags` to 20 as an addionnal option got us to the current max.

Differential Revision: https://reviews.llvm.org/D95542
2021-01-27 12:35:34 -08:00
Jianzhou Zhao f86db34def [MSan] Move origins for overlapped memory transfer
Reviewed-by: eugenis

Differential Revision: https://reviews.llvm.org/D94572
2021-01-21 02:11:26 +00:00
Peter Collingbourne d302398ff0 hwasan: Update register-dump-read.c test to reserve x23 instead of x20.
D90422 changed this test to write a fixed value into register x23
instead of x20, but it did not update the list of reserved registers.
This meant that x23 may have been live across the register write,
although this happens to not be the case with the current compiler.
Fix the problem by updating the reserved register list.
2021-01-15 16:14:36 -08:00
Mitch Phillips 6a42cbf6d2 [GWP-ASan] Add inbuilt options parser.
Adds a modified options parser (shamefully pulled from Scudo, which
shamefully pulled it from sanitizer-common) to GWP-ASan. This allows
customers (Android) to parse options strings in a common way.

Depends on D94117.

AOSP side of these patches is staged at:

 - sepolicy (sysprops should only be settable by the shell, in both root and
 unrooted conditions):
 https://android-review.googlesource.com/c/platform/system/sepolicy/+/1517238

 - zygote updates:
 https://android-review.googlesource.com/c/platform/frameworks/base/+/1515009

 - bionic changes to add `gwp_asan.<process_name>` system property, and
 GWP_ASAN_OPTIONS environment variable:
 https://android-review.googlesource.com/c/platform/bionic/+/1514989

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D92696
2021-01-15 12:57:05 -08:00
Alex Richardson 00530dee5d [compiler-rt] Implement __atomic_is_lock_free
This function is called by the __atomic_is_lock_free() builtin if the value
cannot be resolved to true at compile time. Lack of this function is
causing the non-lockfree atomics tests in libc++ to not be run (see D91911)

This function is also added in D85044, but that review also adds support
for using lock-free atomics in more cases, whereas this is a minimal change
that just adds __atomic_is_lock_free() for the implementation of atomic.c.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D92302
2021-01-08 12:48:22 +00:00
Mitch Phillips 1f8031cd74 [android] Fix some tests for AOSP-master devices.
Some tests are broken at API level 30 on AOSP-master devices. When we
change the buildbuit to API level 30, the following tests get enabled.
They're currently broken due to various issues, and so fix up those
issues.

Reviewed By: oontvoo, eugenis

Differential Revision: https://reviews.llvm.org/D94100
2021-01-05 12:54:09 -08:00
Fangrui Song 20670ba440 [compiler-rt][test] Suppress stderr of ldd output 2021-01-01 14:09:13 -08:00
Vitaly Buka 9a0237011b [lsan] Ignore inderect leaks referenced by suppressed blocks
This makes suppression list to work similar to __lsan_ignore_object.

Existing behavior was inconsistent and very inconvenient for complex
data structures.

Example:

struct B;
struct A { B* ptr; };
A* t = makeA();
t->ptr = makeB();

Before the patch: if makeA suppressed by suppression file, lsan will
still report the makeB() leak, so we need two suppressions.

After the patch: a single makeA suppression is enough (the same as a
single __lsan_ignore_object(t)).

Differential Revision: https://reviews.llvm.org/D93884
2020-12-30 19:11:39 -08:00
Vitaly Buka 3c0d36f977 [NFC][lsan] Add nested leak in test 2020-12-29 14:01:43 -08:00
Fangrui Song a8970dff1a [ubsan][test] FLush stdout before checking interleaved stdout/stderr
Detected by musl.
2020-12-28 20:30:32 -08:00
Fangrui Song 55d13e6a86 [asan][test] Annotate glibc specific tests with REQUIRES: glibc-2.27 2020-12-28 19:56:08 -08:00
Fangrui Song 99d650b369 [compiler-rt][test] Make glibc-* feature detection work on a musl distribution
... where `ldd --version` has empty stdout and non-empty stderr.
2020-12-27 21:50:47 -08:00
Alex Richardson 6277bd75dc [compiler-rt] Fix atomic_test.c on macOS
The macOS name mangling adds another underscore. Therefore, on macOS
the __atomic_* functions are actually ___atomic_* in libcompiler_rt.dylib.
To handle this case, prepend the asm() argument with __USER_LABEL_PREFIX__
in the same way that atomic.c does.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D92833
2020-12-22 11:56:20 +00:00
Nemanja Ivanovic ba1202a1e4 [PowerPC] Restore stack ptr from base ptr when available
On subtargets that have a red zone, we will copy the stack pointer to the base
pointer in the prologue prior to updating the stack pointer. There are no other
updates to the base pointer after that. This suggests that we should be able to
restore the stack pointer from the base pointer rather than loading it from the
back chain or adding the frame size back to either the stack pointer or the
frame pointer.
This came about because functions that call setjmp need to restore the SP from
the FP because the back chain might have been clobbered
(see https://reviews.llvm.org/D92906). However, if the stack is realigned, the
restored SP might be incorrect (which is what caused the failures in the two
ASan test cases).

This patch was tested quite extensivelly both with sanitizer runtimes and
general code.

Differential revision: https://reviews.llvm.org/D93327
2020-12-22 05:44:03 -06:00
Mitch Phillips 13261f4c03 Revert "[sanitizer-common] Force pickup of llvm-symbolizer from new binaries."
This reverts commit 66ee0d3d84.

Broke the bots, reverting for full fix.
2020-12-17 16:17:56 -08:00
Mitch Phillips ab1a05d57f Revert "[sanitizer-common] Pickup llvm-symbolizer from $OUT/bin IFF exists."
This reverts commit 30d292ddbb.

Broke the bots, reverting for full fix.
2020-12-17 16:17:56 -08:00
Mitch Phillips 30d292ddbb [sanitizer-common] Pickup llvm-symbolizer from $OUT/bin IFF exists.
Fix-forward for D93352.

Slight rework of the same idea, pickup the external symbolizer from the
binary directory iff it exists.
2020-12-16 11:59:10 -08:00
Mitch Phillips 66ee0d3d84 [sanitizer-common] Force pickup of llvm-symbolizer from new binaries.
It's possible currently that the sanitizer runtimes when testing grab
the path to the symbolizer through *SAN_SYMBOLIZER_PATH=...

This can be polluted by things like Android's setup script. This patch
forces external_symbolizer_path=$new_build_out_dir/llvm-symbolizer when
%env_tool_options is used.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D93352
2020-12-16 06:36:26 -08:00
Nemanja Ivanovic eed0b9acdf [PowerPC] Temporarily disable asan longjmp tests
Commit bfdc19e778 seems to have broken
some PPC bots with a couple of asan test cases. Disable those test
cases for now until I can resolve the issue.
2020-12-14 18:22:08 -06:00
Matt Morehouse 7bc7501ac1 [DFSan] Add custom wrapper for recvmmsg.
Uses the recvmsg wrapper logic in a loop.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D93059
2020-12-11 06:24:56 -08:00
Fangrui Song f23fae29eb [test] Fix compiler-rt/test/profile/coverage_emptylines.cpp if the build directory is under /tmp
llvm-cov -path-equivalence=/tmp,... is used by some checked-in coverage mapping
files where the original filename is under /tmp. If the test itself produces the
coverage mapping file, there is no need for /tmp.

For coverage_emptylines.cpp: the source filename is under the build directory.
If the build directory is under /tmp, the path mapping will make
llvm-cov fail to find the file.
2020-12-10 16:57:10 -08:00
Xinhao Yuan 97260ab478 [llvm-cov][gcov] Optimize the cycle counting algorithm by skipping zero count cycles
This change is similar to http://gcc.gnu.org/PR90380

This reduces the complexity from exponential to polynomial of the arcs.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93036
2020-12-10 15:22:29 -08:00
Matt Morehouse 5ff35356f1 [DFSan] Appease the custom wrapper lint script. 2020-12-10 14:12:26 -08:00
Matt Morehouse 009931644a [DFSan] Add custom wrapper for pthread_join.
The wrapper clears shadow for retval.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D93047
2020-12-10 13:41:24 -08:00
Matt Morehouse fa4bd4b338 [DFSan] Add custom wrapper for getpeername.
The wrapper clears shadow for addr and addrlen when written to.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D93046
2020-12-10 12:26:06 -08:00
Matt Morehouse 72fd47b93d [DFSan] Add custom wrapper for _dl_get_tls_static_info.
Implementation is here:
https://code.woboq.org/userspace/glibc/elf/dl-tls.c.html#307

We use weak symbols to avoid linking issues with glibcs older than 2.27.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D93053
2020-12-10 11:03:28 -08:00
Matt Morehouse bdaeb82a5f [DFSan] Add custom wrapper for sigaltstack.
The wrapper clears shadow for old_ss.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D93041
2020-12-10 10:16:36 -08:00
Matt Morehouse 8a874a4277 [DFSan] Add custom wrapper for getsockname.
The wrapper clears shadow for any bytes written to addr or addrlen.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D92964
2020-12-10 08:13:05 -08:00
Matt Morehouse 4eedc2e3af [DFSan] Add custom wrapper for getsockopt.
The wrapper clears shadow for optval and optlen when written.

Reviewed By: stephan.yichao.zhao, vitalybuka

Differential Revision: https://reviews.llvm.org/D92961
2020-12-09 14:29:38 -08:00
Matt Morehouse a3eb2fb247 [DFSan] Add custom wrapper for recvmsg.
The wrapper clears shadow for anything written by recvmsg.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D92949
2020-12-09 13:07:51 -08:00
Jianzhou Zhao ea981165a4 [dfsan] Track field/index-level shadow values in variables
*************
* The problem
*************
See motivation examples in compiler-rt/test/dfsan/pair.cpp. The current
DFSan always uses a 16bit shadow value for a variable with any type by
combining all shadow values of all bytes of the variable. So it cannot
distinguish two fields of a struct: each field's shadow value equals the
combined shadow value of all fields. This introduces an overtaint issue.

Consider a parsing function

   std::pair<char*, int> get_token(char* p);

where p points to a buffer to parse, the returned pair includes the next
token and the pointer to the position in the buffer after the token.

If the token is tainted, then both the returned pointer and int ar
tainted. If the parser keeps on using get_token for the rest parsing,
all the following outputs are tainted because of the tainted pointer.

The CL is the first change to address the issue.

**************************
* The proposed improvement
**************************
Eventually all fields and indices have their own shadow values in
variables and memory.

For example, variables with type {i1, i3}, [2 x i1], {[2 x i4], i8},
[2 x {i1, i1}] have shadow values with type {i16, i16}, [2 x i16],
{[2 x i16], i16}, [2 x {i16, i16}] correspondingly; variables with
primary type still have shadow values i16.

***************************
* An potential implementation plan
***************************

The idea is to adopt the change incrementially.

1) This CL
Support field-level accuracy at variables/args/ret in TLS mode,
load/store/alloca still use combined shadow values.

After the alloca promotion and SSA construction phases (>=-O1), we
assume alloca and memory operations are reduced. So if struct
variables do not relate to memory, their tracking is accurate at
field level.

2) Support field-level accuracy at alloca
3) Support field-level accuracy at load/store

These two should make O0 and real memory access work.

4) Support vector if necessary.
5) Support Args mode if necessary.
6) Support passing more accurate shadow values via custom functions if
necessary.

***************
* About this CL.
***************
The CL did the following

1) extended TLS arg/ret to work with aggregate types. This is similar
to what MSan does.

2) implemented how to map between an original type/value/zero-const to
its shadow type/value/zero-const.

3) extended (insert|extract)value to use field/index-level progagation.

4) for other instructions, propagation rules are combining inputs by or.
The CL converts between aggragate and primary shadow values at the
cases.

5) Custom function interfaces also need such a conversion because
all existing custom functions use i16. It is unclear whether custome
functions need more accurate shadow propagation yet.

6) Added test cases for aggregate type related cases.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D92261
2020-12-09 19:38:35 +00:00
Matt Morehouse 6f13445fb6 [DFSan] Add custom wrapper for epoll_wait.
The wrapper clears shadow for any events written.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D92891
2020-12-09 06:05:29 -08:00
Adhemerval Zanella db61b1844e [compiler-rt] [builtins] Support conversion between fp16 and fp128
This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are built iff the compiler supports _Float16.

Some notes on ARM plaforms: while fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst). Also,
fp16 is a storage format and 64-bit ARM supports floating-point
convert precision to half as base armv8-a instruction.

This patch does not change the ABI for 32-bit ARM, it will continue
to pass _Float16 as uint16.

This re-enabled revert done by https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726

Differential Revision: https://reviews.llvm.org/D92242
2020-12-08 11:51:55 -03:00
Hafiz Abid Qadeer deec343bfd [compiler-rt] Allow appending to 'target_cflags' value from lit_config.
This patch is similar to D84708. When testing compiler-rt on different
baremetal targets, it helps to have the ability to pass some more parameters
at test time that allows you to build the test executable for a
given target. For an example, you may need a different linker command
file for different targets.

This patch will allows to do things like

$ llvm-lit --param=append_target_cflags="-T simulator.ld"
or
$ llvm-lit --param=append_target_cflags="-T hardware.ld"

In this way, you can run tests on different targets without having to run
cmake again.

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D91783
2020-12-08 11:46:36 +00:00
Mitch Phillips 1d03a54d94 Revert "[test] Fix asan/TestCases/Linux/globals-gc-sections-lld.cpp with -fsanitize-address-globals-dead-stripping"
This reverts commit 140808768d.

Reason: Broke the upstream bots - discussed offline.
2020-12-07 14:30:53 -08:00
Fangrui Song 140808768d [test] Fix asan/TestCases/Linux/globals-gc-sections-lld.cpp with -fsanitize-address-globals-dead-stripping
r302591 dropped -fsanitize-address-globals-dead-stripping for ELF platforms
(to work around a gold<2.27 bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19002)

Upgrade REQUIRES: from lto (COMPILER_RT_TEST_USE_LLD (set by Android, but rarely used elsewhere)) to lto-available.
2020-12-06 11:11:15 -08:00
Fangrui Song dde44f488c [test] Fix asan/TestCases/Posix/lto-constmerge-odr.cpp when 'binutils_lto' is avaiable
If COMPILER_RT_TEST_USE_LLD is not set, config.use_lld will be False.
However, if feature 'binutils_lto' is available, lto_supported can still be True,
but config.target_cflags will not get -fuse-ld=lld from config.lto_flags

As a result, we may use clang -flto with system 'ld' which may not support the bitcode file, e.g.

  ld: error: /tmp/lto-constmerge-odr-44a1ee.o: Unknown attribute kind (70) (Producer: 'LLVM12.0.0git' Reader: 'LLVM 12.0.0git')
  // The system ld+LLVMgold.so do not support ATTR_KIND_MUSTPROGRESS (70).

Just require lld-available and add -fuse-ld=lld.
2020-12-06 10:31:40 -08:00
Fangrui Song b00f345acd [asan][test] Fix odr-vtable.cpp 2020-12-05 19:30:41 -08:00
Zhuojia Shen 24333481cb [builtins][ARM] Check __ARM_FP instead of __VFP_FP__.
This patch fixes builtins' CMakeLists.txt and their VFP tests to check
the standard macro defined in the ACLE for VFP support. It also enables
the tests to be built and run for single-precision-only targets while
builtins were built with double-precision support.

Differential revision: https://reviews.llvm.org/D92497
2020-12-04 20:53:23 -08:00
Fangrui Song 190b4374c0 [asan][test] Improve -asan-use-private-alias tests
In preparation for D92078
2020-12-04 15:05:59 -08:00
Adhemerval Zanella c288715e95 [compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available
On AArch64 it allows use the native FP16 ABI (although libcalls are
not emitted for fptrunc/fpext lowering), while on other architectures
the expected current semantic is preserved (arm for instance).

For testing the _Float16 usage is enabled by architecture base,
currently only for arm, aarch64, and arm64.

This re-enabled revert done by https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92241
2020-12-03 16:08:55 -03:00
Vitaly Buka 20a2b1bf6b [NFC][sanitizer] Another attempt to fix test on arm 2020-12-02 18:36:02 -08:00
Jianzhou Zhao 6fa06628a7 [dfsan] Add test cases for struct/pair
This is a child diff of D92261.

This locks down the behavior before the change.
2020-12-02 21:25:23 +00:00
Vitaly Buka 1f3def16f6 [NFC][sanitizer] Fix test on 32bit platform 2020-12-02 07:32:40 -08:00
Ahsan Saghir 5045b831a3 [PowerPC] Mark sanitizer test case unsupported for powerpc64
The author of "https://reviews.llvm.org/D92428" marked
'resize_tls_dynamic.cpp' with XFAIL for powerpc64 since
it fails on a bunch of PowerPC buildbots. However, the
original test case passes on clang-ppc64le-rhel bot. So
marking this as XFAIL makes this bot to fail as the test
case passes unexpectedly. We are marking this unsupported
on all PowerPC64 for now until it is fixed for all the
PowerPC buildbots.
2020-12-02 09:03:28 -06:00
Vitaly Buka 3f0c4bfc64 [NFC][sanitizer] Fix ppc -> powerpc64 in XFAIL 2020-12-01 17:57:42 -08:00
Vitaly Buka bdd6718bef [NFC] Disable new test from D92428 on PPC TSAN 2020-12-01 16:54:14 -08:00
Vitaly Buka 8a300deb3e [sanitizer] Make DTLS_on_tls_get_addr signal safer
Avoid relocating DTV table and use linked list of mmap-ed pages.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D92428
2020-12-01 16:16:04 -08:00
Reid Kleckner b5af5787b3 [WinASan] Improve exception reporting accuracy
Previously, ASan would produce reports like this:
ERROR: AddressSanitizer: breakpoint on unknown address 0x000000000000 (pc 0x7fffdd7c5e86 ...)

This is unhelpful, because the developer may think this is a null
pointer dereference, and not a breakpoint exception on some PC.

The cause was that SignalContext::GetAddress would read the
ExceptionInformation array to retreive an address for any kind of
exception. That data is only available for access violation exceptions.
This changes it to be conditional on the exception type, and to use the
PC otherwise.

I added a variety of tests for common exception types:
- int div zero
- breakpoint
- ud2a / illegal instruction
- SSE misalignment

I also tightened up IsMemoryAccess and GetWriteFlag to check the
ExceptionCode rather than looking at ExceptionInformation[1] directly.

Differential Revision: https://reviews.llvm.org/D92344
2020-11-30 16:39:22 -08:00
Vy Nguyen 1b723a955d [sanitizer] Disable use_tls_dynamic on on-Android x86 Linux.
https://bugs.chromium.org/p/chromium/issues/detail?id=1153421

Differential Revision: https://reviews.llvm.org/D92273
2020-11-30 11:45:36 -05:00
Reid Kleckner b534beabee Revert builtins fp16 support: tests do not pass on Mac
Revert "[compiler-rt] [builtins] Support conversion between fp16 and fp128" & dependency

Revert "[compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available"

This reverts commit 7a94829881.

This reverts commit 1fb91fcf9c.
2020-11-25 16:12:49 -08:00
Evgenii Stepanov 237b024b06 [hwasan] Fix tests when vm.overcommit_memory=1.
Remove an invalid check from sizes.cpp that only passes when overcommit is disabled.

Fixes PR48274.

Differential Revision: https://reviews.llvm.org/D91999
2020-11-23 16:05:56 -08:00
Evgenii Stepanov 08d90f72ce [hwasan] Implement error report callback.
Similar to __asan_set_error_report_callback, pass the entire report to a
user provided callback function.

Differential Revision: https://reviews.llvm.org/D91825
2020-11-20 16:48:19 -08:00
Vitaly Buka 3b947cc8ce [msan] unpoison_file from fclose and fflash
Also unpoison IO_write_base/_IO_write_end buffer

memcpy from fclose and fflash can copy internal bytes without metadata into user memory.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D91858
2020-11-20 13:09:01 -08:00
Rainer Orth 03d593dd7e [sanitizers][test] Test sanitizer_common and ubsan_minimal on Solaris
During the initial Solaris sanitizer port, I missed to enable the
`sanitizer_common` and `ubsan_minimal` testsuites.  This patch fixes this,
correcting a few unportabilities:

- `Posix/getpass.cpp` failed to link since Solaris lacks `libutil`.
  Omitting the library lets the test `PASS`, but I thought adding `%libutil`
  along the lines of `%librt` to be overkill.
- One subtest of `Posix/getpw_getgr.cpp` is disabled because Solaris
  `getpwent_r` has a different signature than expected.
- `/dev/null` is a symlink on Solaris.
- XPG7 specifies that `uname` returns a non-negative value on success.

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

Differential Revision: https://reviews.llvm.org/D91606
2020-11-20 14:06:25 +01:00
Teresa Johnson a75b2e87e6 [MemProf] Add interface to dump profile
Add an interface so that the profile can be dumped on demand.

Differential Revision: https://reviews.llvm.org/D91768
2020-11-19 10:21:53 -08:00
Adhemerval Zanella 7a94829881 [compiler-rt] [builtins] Use _Float16 on extendhfsf2, truncdfhf2 __truncsfhf2 if available
On AArch64 it allows use the native FP16 ABI (although libcalls are
not emitted for fptrunc/fpext lowering), while on other architectures
the expected current semantic is preserved (arm for instance).

Differential Revision: https://reviews.llvm.org/D91733
2020-11-19 15:14:50 -03:00
Adhemerval Zanella 1fb91fcf9c [compiler-rt] [builtins] Support conversion between fp16 and fp128
This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are enabled iff the compiler supports _Float16.

Some notes on ARM plaforms: while __fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst).  Also,
__fp16 is a storage format and promoted to 'float' for argument passing
and 64-bit ARM supports floating-point convert precision to half as
base armv8-a instruction.

It means that although extendhfsf2, truncdfhf2 __truncsfhf2 will be
built for 64-bit ARM, they will be never used in practice (compiler
won't emit libcall to them). This patch does not change the ABI for
32-bit ARM, it will continue to pass _Float16 as uint16.

Differential Revision: https://reviews.llvm.org/D91732
2020-11-19 15:14:50 -03:00
Teresa Johnson 8f778b283d [sanitizer_common] Add facility to get the full report path
Add a new interface __sanitizer_get_report_path which will return the
full path to the report file if __sanitizer_set_report_path was
previously called (otherwise it returns null). This is useful in
particular for memory profiling handlers to access the path which
was specified at compile time (and passed down via
__memprof_profile_filename), including the pid added to the path when
the file is opened.

There wasn't a test for __sanitizer_set_report_path, so I added one
which additionally tests the new interface.

Differential Revision: https://reviews.llvm.org/D91765
2020-11-19 09:19:12 -08:00
Evgenii Stepanov 523cc097fd [hwasan] Fix Thread reuse (try 2).
HwasanThreadList::DontNeedThread clobbers Thread::next_,
Breaking the freelist. As a result, only the top of the freelist ever
gets reused, and the rest of it is lost.

Since the Thread object with its associated ring buffer is only 8Kb, this is
typically only noticable in long running processes, such as fuzzers.

Fix the problem by switching from an intrusive linked list to a vector.

Differential Revision: https://reviews.llvm.org/D91392
2020-11-18 16:04:08 -08:00
Vitaly Buka 0e2585c804 [tsan] Add pthread_cond_clockwait interceptor
Disable the test on old systems.
pthread_cond_clockwait is supported by glibc-2.30.
It also supported by Android api 30 even though we
do not run tsan on Android.

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

Reviewed By: dvyukov
2020-11-18 14:39:19 -08:00
Wolfgang Pieb 87369c6261 Revert "[tsan] Add pthread_cond_clockwait interceptor"
This reverts commit 16eb853ffd.

The test is failing on some Linux build bots. See the review for
an example.
2020-11-18 11:58:45 -08:00
Vitaly Buka 16eb853ffd [tsan] Add pthread_cond_clockwait interceptor
Fixes https://github.com/google/sanitizers/issues/1259

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D91684
2020-11-18 03:01:58 -08:00
Amy Huang bc98034040 [llvm-symbolizer] Add inline stack traces for Windows.
This adds inline stack frames for symbolizing on Windows.

Differential Revision: https://reviews.llvm.org/D88988
2020-11-17 13:19:13 -08:00
Vy Nguyen b16e4d3fc1 [sanitizers-test]add definition for %device_rm on android so it stops complaining
Differential Revision: https://reviews.llvm.org/D91570
2020-11-16 19:57:54 -05:00
Jonathan Metzman 91703085f5 [fuzzer] Disable uncaught-exception on non-Win+undo bad fix
Test is failing on non-Windows platforms. Also undo speculative
fix since it causes failures on Windows.
2020-11-16 09:35:35 -08:00
Jonathan Metzman a3be128709 [fuzzer] Add allocator_may_return_null to uncaught-exception.test.
Speculative fix for failing unittest.
2020-11-16 09:13:25 -08:00
Vitaly Buka 581ebf44d2 [sanitizer] Fix setup of android-thread-properties-api 2020-11-14 23:23:10 -08:00
Vitaly Buka dd0b8b94d0 [sanitizer] Add timeouts for adb calls 2020-11-14 18:43:45 -08:00
Vitaly Buka e51631ca4c [sanitizer] Fix Android API level parsing on arm 2020-11-14 01:54:45 -08:00
Joe Pletcher f897e82bfd [fuzzer] Add Windows Visual C++ exception intercept
Adds a new option, `handle_winexcept` to try to intercept uncaught
Visual C++ exceptions on Windows. On Linux, such exceptions are handled
implicitly by `std::terminate()` raising `SIBABRT`. This option brings the
Windows behavior in line with Linux.

Unfortunately this exception code is intentionally undocumented, however
has remained stable for the last decade. More information can be found
here: https://devblogs.microsoft.com/oldnewthing/20100730-00/?p=13273

Reviewed By: morehouse, metzman

Differential Revision: https://reviews.llvm.org/D89755
2020-11-12 13:11:14 -08:00
Nico Weber 6ab31eeb62 Revert "[hwasan] Fix Thread reuse."
This reverts commit e1eeb026e6.
Test fails: https://reviews.llvm.org/D91208#2388613
2020-11-11 09:56:21 -05:00
Evgenii Stepanov e1eeb026e6 [hwasan] Fix Thread reuse.
HwasanThreadList::DontNeedThread clobbers Thread::next_, breaking the
freelist. As a result, only the top of the freelist ever gets reused,
and the rest of it is lost.

Since the Thread object its associated ring buffer is only 8Kb, this is
typically only noticable in long running processes, such as fuzzers.

Fix the problem by switching from an intrusive linked list to a vector.

Differential Revision: https://reviews.llvm.org/D91208
2020-11-10 17:24:24 -08:00
Vy Nguyen 5cb378fab3 [sanitizers] Remove the test case involving `new int[0]`
Bionic doesn't acutally allocate any memory in this case, so there won't be a leak on Android.

Differential Revision: https://reviews.llvm.org/D90821
2020-11-05 09:16:45 -05:00
Adhemerval Zanella d025df3c1d [lsan] Disable some LSAN tests for arm-linux-gnueabi{hf}
The tests do not report the expected leak when issued with use_stack
or use_tls option equal to 0 on arm-linux-gnueabihf (ubuntu 18.04,
glibc 2.27).

This issue is being tracked by https://bugs.llvm.org/show_bug.cgi?id=48052
2020-11-05 08:32:53 -03:00
Adhemerval Zanella 0ad3cb8c26 [sanitizer] Assume getrandom might not be supported by the kernel
It was added on kernel 3.17.
2020-11-05 08:32:53 -03:00
Vitaly Buka 90e5b7b8be [NFC] Fix comment in test
Differential Revision: https://reviews.llvm.org/D90790
2020-11-04 14:02:28 -08:00
Vy Nguyen 6855a60fd6 [NFC]Remove unused variable
Accidentally committed in D89615
2020-11-04 09:54:07 -05:00
Vy Nguyen aa662f61de Disable emulated-tls for compiler-rt+tests on Android if ELF_TLS is presence.
This is necessary for enabling LSAN on Android (D89251) because:
 - LSAN will have false negatives if run with emulated-tls.
 - Bionic ELF-TLS is not compatible with Gold (hence the need for LLD)

Differential Revision: https://reviews.llvm.org/D89615
2020-11-04 09:49:45 -05:00
Vitaly Buka 985a5d970a [NFC][UBSAN] Replace "count 0" with FileCheck
Unrelated system warnings may confuse "check 0"
2020-11-04 02:36:13 -08:00
Vitaly Buka e86205680e [sanitizer] Remove ANDROID_NDK_VERSION 2020-11-04 01:15:25 -08:00
Vy Nguyen 707d69ff32 Use LLD for Android compiler-rt
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D90720
2020-11-04 00:51:18 -08:00
Alex Lorenz 701456b523 [darwin] add support for __isPlatformVersionAtLeast check for if (@available)
The __isPlatformVersionAtLeast routine is an implementation of `if (@available)` check
that uses the _availability_version_check API on Darwin that's supported on
macOS 10.15, iOS 13, tvOS 13 and watchOS 6.

Differential Revision: https://reviews.llvm.org/D90367
2020-11-02 16:28:09 -08:00
Teresa Johnson 7f32ddc99b [MemProf] Reenable test with fix for bot failures
The issue was unexpected macro expansion when the bot's test output
directory contained a token matching a build system macro (e.g.
"linux"). Switch to using a hardcoded path, which is invalid but is
sufficient for ensuring that the path is passed down to the runtime.

Differential Revision: https://reviews.llvm.org/D90466
2020-11-02 09:00:04 -08:00
Teresa Johnson 0949f96dc6 [MemProf] Pass down memory profile name with optional path from clang
Similar to -fprofile-generate=, add -fmemory-profile= which takes a
directory path. This is passed down to LLVM via a new module flag
metadata. LLVM in turn provides this name to the runtime via the new
__memprof_profile_filename variable.

Additionally, always pass a default filename (in $cwd if a directory
name is not specified vi the = form of the option). This is also
consistent with the behavior of the PGO instrumentation. Since the
memory profiles will generally be fairly large, it doesn't make sense to
dump them to stderr. Also, importantly, the memory profiles will
eventually be dumped in a compact binary format, which is another reason
why it does not make sense to send these to stderr by default.

Change the existing memprof tests to specify log_path=stderr when that
was being relied on.

Depends on D89086.

Differential Revision: https://reviews.llvm.org/D89087
2020-11-01 17:38:23 -08:00
Vitaly Buka f9dd0166f1 [sanitizer] Disabled 2 tests on Android
They block bot upgrade to NDK 21.
2020-10-31 03:56:52 -07:00
Arthur Eubanks 5c31b8b94f Revert "Use uint64_t for branch weights instead of uint32_t"
This reverts commit 10f2a0d662.

More uint64_t overflows.
2020-10-31 00:25:32 -07:00
Peter Collingbourne 3859fc653f AArch64: Switch to x20 as the shadow base register for outlined HWASan checks.
From a code size perspective it turns out to be better to use a
callee-saved register to pass the shadow base. For non-leaf functions
it avoids the need to reload the shadow base into x9 after each
function call, at the cost of an additional stack slot to save the
caller's x20. But with x9 there is also a stack size cost, either
as a result of copying x9 to a callee-saved register across calls or
by spilling it to stack, so for the non-leaf functions the change to
stack usage is largely neutral.

It is also code size (and stack size) neutral for many leaf functions.
Although they now need to save/restore x20 this can typically be
combined via LDP/STP into the x30 save/restore. In the case where
the function needs callee-saved registers or stack spills we end up
needing, on average, 8 more bytes of stack and 1 more instruction
but given the improvements to other functions this seems like the
right tradeoff.

Unfortunately we cannot change the register for the v1 (non short
granules) check because the runtime assumes that the shadow base
register is stored in x9, so the v1 check still uses x9.

Aside from that there is no change to the ABI because the choice
of shadow base register is a contract between the caller and the
outlined check function, both of which are compiler generated. We do
need to rename the v2 check functions though because the functions
are deduplicated based on their names, not on their contents, and we
need to make sure that when object files from old and new compilers
are linked together we don't end up with a function that uses x9
calling an outlined check that uses x20 or vice versa.

With this change code size of /system/lib64/*.so in an Android build
with HWASan goes from 200066976 bytes to 194085912 bytes, or a 3%
decrease.

Differential Revision: https://reviews.llvm.org/D90422
2020-10-30 12:51:30 -07:00
Arthur Eubanks 10f2a0d662 Use uint64_t for branch weights instead of uint32_t
CallInst::updateProfWeight() creates branch_weights with i64 instead of i32.
To be more consistent everywhere and remove lots of casts from uint64_t
to uint32_t, use i64 for branch_weights.

Reviewed By: davidxl

Differential Revision: https://reviews.llvm.org/D88609
2020-10-30 10:03:46 -07:00
Adhemerval Zanella f93c2b64ed [sanitizer] Disable ASLR for release_shadow_space
On aarch64 with kernel 4.12.13 the test sporadically fails with

RSS at start: 1564, after mmap: 103964, after mmap+set label: 308768, \
after fixed map: 206368, after another mmap+set label: 308768, after \
munmap: 206368
release_shadow_space.c.tmp: [...]/release_shadow_space.c:80: int \
main(int, char **): Assertion `after_fixed_mmap <= before + delta' failed.

It seems on some executions the memory is not fully released, even
after munmap.  And it also seems that ASLR is hurting it by adding
some fragmentation, by disabling it I could not reproduce the issue
in multiple runs.
2020-10-29 16:09:03 -03:00
Teresa Johnson d124ac0c22 [MemProf] Temporarily disable test failing on a couple bots
I finally see why this test is failing (on now 2 bots). Somehow the path
name is getting messed up, and the "linux" converted to "1". I suspect
there is something in the environment causing the macro expansion in the
test to get messed up:

http://lab.llvm.org:8011/#/builders/112/builds/555/steps/5/logs/FAIL__MemProfiler-x86_64-linux__log_path_test_cpp
http://lab.llvm.org:8011/#/builders/37/builds/275/steps/31/logs/stdio

On the avr bot:
-DPROFILE_NAME_VAR="/home/buildbot/llvm-avr-linux/llvm-avr-linux/stage1/projects/compiler-rt/test/memprof/X86_64LinuxConfig/TestCases/Output/log_path_test.cpp.tmp.log2"

after macros expansions becomes:
/home/buildbot/llvm-avr-1/llvm-avr-1/stage1/projects/compiler-rt/test/memprof/X86_64LinuxConfig/TestCases/Output/log_path_test.cpp.tmp.log2

Similar (s/linux/1/) on the other bot.

Disable it while I investigate
2020-10-29 11:26:21 -07:00
Teresa Johnson 240b421738 [MemProf] Augment test to debug avr bot failure
After 81f7b96ed0, I can see that the
reason this test is failing on llvm-avr-linux is that it doesn't think
the directory exists (error comes during file open for write command).
Not sure why since this is the main test Output directory and we created
a different file there earlier in the test from the same file open
invocation. Print directory contents in an attempt to debug.
2020-10-29 10:04:43 -07:00
Teresa Johnson 81f7b96ed0 [sanitizer] Print errno for report file open failure
To help debug failures, specifically the llvm-avr-linux bot failure from
5c20d7db9f2791367b9311130eb44afecb16829c:

http://lab.llvm.org:8011/#/builders/112/builds/407/steps/5/logs/FAIL__MemProfiler-x86_64-linux-dynamic__log_path_t

Also re-enable the failing test which I temporarily disabled, to
see if this change will help identify why that particular log file can't
be opened for write on that bot (when another log file in the same
directory could earlier in the test).

Differential Revision: https://reviews.llvm.org/D90120
2020-10-29 08:47:30 -07:00
Ulrich Weigand a998cae021 [compiler-rt][SystemZ] Skip fuzzer/full-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.
2020-10-28 16:39:46 +01:00
Vitaly Buka 48bc38f254 [NFC][Asan] Fix cpplint warning in test 2020-10-28 00:38:50 -07:00
Vitaly Buka 2a6b156311 [NFC][Asan] Fix cpplint warnings in tests 2020-10-28 00:32:44 -07:00
Vitaly Buka 8ecf1c4969 [NFC][UBSAN] Try to re-enable tests on IOS
Looks like the reason they were disabled is the same as for Android
and it's fixed by 776a15d8ae
2020-10-27 23:49:31 -07:00
Vitaly Buka 58828f6a93 [NFC][UBSAN] Remove XFAIL from fixed tests 2020-10-27 23:43:50 -07:00
Nico Weber 2a4e704c92 Revert "Use uint64_t for branch weights instead of uint32_t"
This reverts commit e5766f25c6.
Makes clang assert when building Chromium, see https://crbug.com/1142813
for a repro.
2020-10-27 09:26:21 -04:00
Arthur Eubanks e5766f25c6 Use uint64_t for branch weights instead of uint32_t
CallInst::updateProfWeight() creates branch_weights with i64 instead of i32.
To be more consistent everywhere and remove lots of casts from uint64_t
to uint32_t, use i64 for branch_weights.

Reviewed By: davidxl

Differential Revision: https://reviews.llvm.org/D88609
2020-10-26 20:24:04 -07:00
Vedant Kumar a77a739abc [profile] Suppress spurious 'expected profile to require unlock' warning
In %c (continuous sync) mode, avoid attempting to unlock an
already-unlocked profile.

The profile is only locked when profile merging is enabled.
2020-10-26 16:25:08 -07:00
Teresa Johnson 13c62ce99a [MemProf] Temporarily disable part of test
Disable the part of this test that started failing only on the
llvm-avr-linux bot after 5c20d7db9f.
Unfortunately, "XFAIL: avr" does not work. Still in the process of
trying to figure out how to debug.
2020-10-24 23:07:34 -07:00
Vitaly Buka 21d64c32ec [NFC][UBSAN] Refine CHECK pattern in test
As-is it was failed by unrelated linker warning with filename in the
output.
2020-10-23 21:11:03 -07:00
Vitaly Buka 776a15d8ae [NFC][UBSAN] Avoid "not FileCheck" in tests
It's not clear if "not FileCheck" succeeded because
input is empty or because input does not match "CHECK:"
pattern.
2020-10-23 19:13:01 -07:00
Max Moroz dc62d5ec97 [libFuzzer] Added -print_full_coverage flag.
-print_full_coverage=1 produces a detailed branch coverage dump when run on a single file.
Uses same infrastructure as -print_coverage flag, but prints all branches (regardless of coverage status) in an easy-to-parse format.
Usage: For internal use with machine learning fuzzing models which require detailed coverage information on seed files to generate mutations.

Differential Revision: https://reviews.llvm.org/D85928
2020-10-23 16:05:54 -07:00
Teresa Johnson eeba325b12 [MemProf] Attempt to debug avr bot failure
Reverts the XFAIL added in b67a2aef8a,
which had no effect.

Adjust the test to make sure all output is dumped to stderr, so that
hopefully I can get a better idea of where/why this is failing.

Remove some redundant checking while here.
2020-10-23 16:00:08 -07:00
Teresa Johnson b67a2aef8a [MemProf] XFAIL test on avr until issue can be debugged
For unknown reasons, this test started failing only on the
llvm-avr-linux bot after 5c20d7db9f2791367b9311130eb44afecb16829c:
http://lab.llvm.org:8011/#/builders/112/builds/365

The error message is not helpful, and I have an email out to the bot
owner to help with debugging. XFAIL it on avr for now.
2020-10-23 11:32:11 -07:00
Alex Orlov 9df832d1c3 These compiler-rt tests should be UNSUPPORTED instead of XFAIL.
These compiler-rt tests should be UNSUPPORTED instead of XFAIL, which seems to be the real intent of the authors.

Reviewed By: vvereschaka

Differential Revision: https://reviews.llvm.org/D89840
2020-10-23 20:57:18 +04:00
Teresa Johnson 5c20d7db9f [MemProf] Allow the binary to specify the profile output filename
This will allow the output directory to be specified by a build time
option, similar to the directory specified for regular PGO profiles via
-fprofile-generate=. The memory profiling instrumentation pass will
set up the variable. This is the same mechanism used by the PGO
instrumentation and runtime.

Depends on D87120 and D89629.

Differential Revision: https://reviews.llvm.org/D89086
2020-10-22 08:30:19 -07:00
Vy Nguyen 3b3aef198b [sanitizer]Update tests to be compatible with Android.
Split off from D89251

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D89884
2020-10-21 17:16:54 -07:00
Luís Marques 58f6b16c49 [compiler-rt][builtins][RISCV] Always include __mul[sd]i3 builtin definitions
The RISC-V implementations of the `__mulsi3`, `__muldi3` builtins were
conditionally compiling the actual function definitions depending on whether
the M extension was present or not. This caused Compiler-RT testing failures
for RISC-V targets with the M extension, as when these sources were included
the `librt_has_mul*i3` features were still being defined. These `librt_has_*`
definitions are used to conditionally run the respective tests. Since the
actual functions were not being compiled-in, the generic test for `__muldi3`
would fail. This patch makes these implementations follow the normal
Compiler-RT convention of always including the definition, and conditionally
running the respective tests by using the lit conditional
`REQUIRES: librt_has_*`.

Since the `mulsi3_test.c` wasn't actually RISC-V-specific, this patch also
moves it out of the `riscv` directory. It now only depends on
`librt_has_mulsi3` to run.

Differential Revision: https://reviews.llvm.org/D86457
2020-10-21 09:49:03 +01:00
Vitaly Buka 343410d1cc [LSAN][NFC] Reformat test 2020-10-20 14:16:27 -07:00
Evgenii Stepanov b3ccfa1e0c [hwasan] Increase max allocation size to 1Tb.
2Gb is unreasonably low on devices with 12Gb RAM and more.

Differential Revision: https://reviews.llvm.org/D89750
2020-10-20 14:01:48 -07:00
Martin Liska ad2be02a83 ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1
Do not crash when AsanThread::GetStackVariableShadowStart does not find
a variable for a pointer on a shadow stack.

Differential Revision: https://reviews.llvm.org/D89552
2020-10-20 19:28:12 +02:00
Jianzhou Zhao 91dc545bf2 Set Huge Page mode on shadow regions based on no_huge_pages_for_shadow
It turned out that at dynamic shared library mode, the memory access
pattern can increase memory footprint significantly on OS when transparent
hugepages (THP) are enabled. This could cause >70x memory overhead than
running a static linked binary. For example, a static binary with RSS
overhead 300M can use > 23G RSS if it is built dynamically.
/proc/../smaps shows in 6204552 kB RSS 6141952 kB relates to
AnonHugePages.

Also such a high RSS happens in some rate: around 25% runs may use > 23G RSS, the
rest uses in between 6-23G. I guess this may relate to how user memory
is allocated and distributted across huge pages.

THP is a trade-off between time and space. We have a flag
no_huge_pages_for_shadow for sanitizer. It is true by default but DFSan
did not follow this. Depending on if a target is built statically or
dynamically, maybe Clang can set no_huge_pages_for_shadow accordingly
after this change. But it still seems fine to follow the default setting of
no_huge_pages_for_shadow. If time is an issue, and users are fine with
high RSS, this flag can be set to false selectively.
2020-10-20 16:50:59 +00:00
Luís Marques fc3f9dfad3 [compiler-rt][builtins] Add tests for atomic builtins support functions
Adds some simple sanity checks that the support functions for the atomic
builtins do the right thing. This doesn't test concurrency and memory model
issues.

Differential Revision: https://reviews.llvm.org/D86278
2020-10-20 12:08:57 +01:00
Dávid Bolvanský 2554619adb [ASAN] Restore and adjust tests
There are optimized out with -fno-builtin
2020-10-18 17:28:05 +02:00
Dávid Bolvanský 65e94cc946 [InferAttrs] Add argmemonly attribute to string libcalls
Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D89602
2020-10-18 01:33:26 +02:00
Luís Marques b7ff218f1c [RISCV][ASAN] Fix passing XFAIL tests
These tests pass for RV64 Linux, but they are marked as XFAIL. This patch
fixes that.

Differential Revision: https://reviews.llvm.org/D89299
2020-10-17 16:55:11 +01:00
Richard Smith efd02c1548 Fix accidental use of VLAs that causes these tests to fail after Clang
commit 552c6c2328.
2020-10-16 15:14:28 -07:00