Commit Graph

8257 Commits

Author SHA1 Message Date
Dean Michael Berris c6ee33852b [XRay] [compiler-rt] Refactor logic for xray fdr logging. NFC.
Summary:
Separated the IO and the thread local storage state machine of logging
from the writing of log records once the contents are deterministic.

Finer granularity functions are provided as inline functions in the same
header such that stack does not grow due to the functions being separated.

An executable utility xray_fdr_log_printer is also implemented to use the
finest granularity functions to produce binary test data in the FDR format
with a relatively convenient text input.

For example, one can take a file with textual contents layed out in rows
and feed it to the binary to generate data that llvm-xray convert can then
read. This is a convenient way to build a test suite for llvm-xray convert
to ensure it's robust to the fdr format.

Example:

$cat myFile.txt
NewBuffer : { time = 2 , Tid=5}
NewCPU : { CPU =1 , TSC = 123}
Function : { FuncId = 5, TSCDelta = 3, EntryType = Entry }
Function : { FuncId = 5, TSCDelta = 5, EntryType = Exit}
TSCWrap : { TSC = 678 }
Function : { FuncId = 6, TSCDelta = 0, EntryType = Entry }
Function : { FuncId = 6, TSCDelta = 50, EntryType = Exit }
EOB : { }
$cat myFile.txt | ./bin/xray_fdr_log_printer > /tmp/binarydata.bin
$./bin/llvm-xray convert -output-format=yaml -output=- /tmp/binarydata.bin

yaml format comes out as expected.

Reviewers: dberris, pelikan

Reviewed By: dberris

Subscribers: llvm-commits, mgorny

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

llvm-svn: 297801
2017-03-15 03:12:01 +00:00
Dean Michael Berris 66443d80f1 [XRay][compiler-rt] Support TSC emulation even for x86_64
Summary:
Use TSC emulation in cases where RDTSCP isn't available on the host
running an XRay instrumented binary. We can then fall back into
emulation instead of not even installing XRay's runtime functionality.
We only do this for now in the naive/basic logging implementation, but
should be useful in even FDR mode.

Should fix http://llvm.org/PR32148.

Reviewers: pelikan, rnk, sdardis

Subscribers: llvm-commits

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

llvm-svn: 297800
2017-03-15 02:28:00 +00:00
Dean Michael Berris 601afaf089 Fix a build break with xray
Summary: Building compiler-rt with clang 3.7 broken, could not find mkstemp

Reviewers: dberris, bkramer

Reviewed By: dberris

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

llvm-svn: 297794
2017-03-14 23:49:12 +00:00
Evgeniy Stepanov a4238e4cdb [msan] Intercept wcsncpy, wcsnlen.
llvm-svn: 297793
2017-03-14 23:48:37 +00:00
Evgeniy Stepanov 32f6b5129f [cfi] Disable bad-split test on win32.
It appears that the fix only helped Itanium ABI.

llvm-svn: 297775
2017-03-14 20:02:42 +00:00
Evgeniy Stepanov dd913de968 [cfi] Add test for type metadata split issue.
https://reviews.llvm.org/D30716

llvm-svn: 297771
2017-03-14 19:33:44 +00:00
Dimitry Andric e773b2d341 After rL297370 and rL297383, instead of a platform check, explicitly
check for the existence of RTLD_DEEPBIND, since this constant is only
supported for glibc >= 2.3.4.  This fixes builds for FreeBSD and other
platforms that do not have RTLD_DEEPBIND.

llvm-svn: 297763
2017-03-14 18:18:14 +00:00
Alex Lorenz ca1fab5d66 [compiler-rt][builtins] __isOSVersionAtLeast should load CoreFoundation
symbols dynamically

The CoreFoundation symbols uses by __isOSVersionAtLeast should be loaded at
runtime to ensure that the programs that don't use @available won't have to be
linked to CoreFoundation.

The Clang frontend IRGen library will need to emit a CoreFoundation symbol
when @available is used to ensure that programs that actually use @available
are linked to CoreFoundation.

rdar://31039554

llvm-svn: 297760
2017-03-14 17:53:37 +00:00
Vedant Kumar c5d628400f [ubsan] Add nullability handlers to interface file
llvm-svn: 297749
2017-03-14 16:36:03 +00:00
Vedant Kumar f2d04e628d [ubsan] Add diagnostic handlers for nullability errors
Add 'nullability_arg' and 'nullability_return' diagnostic handlers, and
also add a TypeCheckKind for null assignments to _Nonnull. With this in
place, we can update clang to use the nicer handlers for nullability
diagnostics.

The alternative to this approach is to update the existing 'nonnull_arg'
and 'nonnull_return' handlers to accept a boolean parameter. However,
versioning the existing handlers would cause code size bloat, and the
complexity cost of introducing new handlers into the runtime is low.

I will add tests for this, and all of -fsanitize=nullability, into
check-ubsan once the clang side of the changes is in.

llvm-svn: 297748
2017-03-14 16:32:27 +00:00
Filipe Cabecinhas 51c5396de8 Some ASan bots (AArch64 at least) use SEGV for a unit test error instead of SIGBUS
llvm-svn: 297728
2017-03-14 10:26:37 +00:00
Weiming Zhao 4f821702ec [Builtin][AArch64] Fix build errors of test cases
Summary:
{mul,sub}tf3_test.c have build errors [1] because macro "COMPILER_RT_ABI" is defined in "int_lib.h", which should be included in test cases.

[1] http://lab.llvm.org:8011/builders/clang-cmake-aarch64-39vma/builds/4861/steps/ninja%20check%201/logs/FAIL%3A%20Builtins-aarch64-linux%3A%3A%20multf3_test.c

Reviewers: rengolin, sdmitriev, dschuff, compnerd, jroelofs

Reviewed By: jroelofs

Subscribers: llvm-commits, aemerson

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

llvm-svn: 297697
2017-03-14 00:44:15 +00:00
Filipe Cabecinhas f7c7c11312 [asan] Split SIGSEGV / SIGBUS handling so we can handle only one of them and not the other.
Summary: This is useful in some platforms where one of these signals is special.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 297665
2017-03-13 21:06:41 +00:00
Alex Lorenz c630f349b8 [compiler-rt][builtins] Ignore the deprecated warning for
CFPropertyListCreateFromXMLData that's used in __isOSVersionAtLeast

llvm-svn: 297613
2017-03-13 11:00:44 +00:00
Weiming Zhao 4451a33442 Revert "[Builtin] Implement lit-test support"
Due to test failure of check-builtins for aarch64 and armhf.
This reverts commit r297566.

llvm-svn: 297569
2017-03-11 20:53:01 +00:00
Weiming Zhao e0004f9215 [Builtin] Implement lit-test support
Summary:
This patch implements a initial support of lit test for builtins.
Unit/arm/call_apsr.S is updated to support thumb1.
It also fixes a bug in arm/aeabi_uldivmod_test.c
gcc_personality_test is XFAILED as the framework cannot handle it so far.
cpu_model_test is also XFAILED for now as it is expected to return non-zero.

Reviewers: rengolin, compnerd, jroelofs, erik.pilkington, arphaman

Reviewed By: jroelofs

Subscribers: jroelofs, aemerson, srhines, nemanjai, llvm-commits, mgorny

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

llvm-svn: 297566
2017-03-11 19:40:24 +00:00
Erik Pilkington eea05ec3f3 Silence a pedantic warning, NFC
llvm-svn: 297515
2017-03-10 21:38:59 +00:00
Weiming Zhao 9dd49054fa [Builtin][ARM] Fix test case for uldivmod
Summary: the inline asm should set those clobbered registers.

Reviewers: rengolin, compnerd, jroelofs

Reviewed By: jroelofs

Subscribers: aemerson, llvm-commits

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

llvm-svn: 297487
2017-03-10 18:21:34 +00:00
Erik Pilkington 0490e1c5f4 Reapply r297382: "[compiler-rt][builtins] Add __isOSVersionAtLeast()"
Looks like the problem was a case-insensitive include of dispatch/dispatch.h.

llvm-svn: 297392
2017-03-09 17:02:16 +00:00
Erik Pilkington 4d297df95c Revert "[compiler-rt][builtins] Add __isOSVersionAtLeast()"
This reverts r297382, it was causing build failures.

llvm-svn: 297388
2017-03-09 15:58:26 +00:00
Maxim Ostapenko c206800218 [sanitizer] Fix android buildbots after r297370
llvm-svn: 297383
2017-03-09 14:40:15 +00:00
Erik Pilkington 6fa97926e9 [compiler-rt][builtins] Add __isOSVersionAtLeast()
This predicate compares the host's marketing OS version to one passed as
argument. Currently, only darwin targets are supported. This is done by parsing
the SystemVersion.plist file.

Also added in this patch is some lit testing infrastructure for builtins, which
previously had none. This part of the patch was written by Alex Lorenz (with
some minor modifications).

This patch is part of a feature I proposed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

Differential revision: https://reviews.llvm.org/D30136

llvm-svn: 297382
2017-03-09 14:17:36 +00:00
Maxim Ostapenko 76630d43f6 [sanitizer] Bail out with warning if user dlopens shared library with RTLD_DEEPBIND flag
People keep hitting on spurious failures in malloc/free routines when using sanitizers
with shared libraries dlopened with RTLD_DEEPBIND (see https://github.com/google/sanitizers/issues/611 for details).
Let's check for this flag and bail out with warning message instead of failing in random places.

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

llvm-svn: 297370
2017-03-09 10:47:38 +00:00
Francis Ricci 0504863383 Use correct function signature for strerror_r interceptor
There are two possible return values for strerror_r:

On OS X, the return value is always `int`.
On Linux, the return value can be either `char *` or `int`, depending
on the value of:
`(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE`

Because OS X interceptors require a matching function signature,
split out the two cases into separate interceptors, using the above
information to determine the correct signature for a given build.

llvm-svn: 297315
2017-03-08 22:51:03 +00:00
Dean Michael Berris 05641ca556 [XRay] [compiler-rt] Mark arg1 logging test as failing on !x86_64.
Summary:
rL297000 and rL297003 implemented arg1 logging on amd64 and made
other architectures build.  We need to blacklist the new test as well.

Reviewers: dberris, timshen

Reviewed By: dberris

Subscribers: sdardis, llvm-commits

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

llvm-svn: 297238
2017-03-07 23:07:03 +00:00
Bill Seurer fe53fdb873 [PowerPC] mark xray test as unsupported on powerpcle in testsuite
Temporarily mark the test as unsupported so the powerpc le buildbot
testers can get back to work.

There was a brief discussion of this on the mailing list for r296998.

llvm-svn: 297184
2017-03-07 18:52:54 +00:00
Tim Shen 0243eac2d8 [XRay] [compiler-rt] Stub out architectures we don't do arg1 logging on.
rL297000 forgot to include code for three architectures that appeared
since I wrote the first version. This gives them the same treatment as ARMs
have for now - write stubs and wait for someone to actually implement it.

Patched by pelikan (Martin Pelikán)!

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

llvm-svn: 297003
2017-03-06 08:26:21 +00:00
Dean Michael Berris a814c94163 [XRay] [compiler-rt] Allow logging the first argument of a function call.
Summary:
Functions with the LOG_ARGS_ENTRY sled kind at their beginning will be handled
in a way to (optionally) pass their first call argument to your logging handler.

For practical and performance reasons, only the first argument is supported, and
only up to 64 bits.

Reviewers: javed.absar, dberris

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 297000
2017-03-06 07:25:41 +00:00
Etienne Bergeron 4edb9fd3c8 [compiler-rt][asan] Turn on ASAN unittests for win64.
Summary:
Asan is now working on windows 64-bit.
This patch is turning on the unittest.

Reviewers: rnk

Reviewed By: rnk

Subscribers: kubamracek, dberris, beanz, mgorny, llvm-commits, chrisha

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

llvm-svn: 296878
2017-03-03 16:35:46 +00:00
Evgeniy Stepanov b6fe13f26b [msan] Test for _mm_getcsr and _mm_setcsr (r296848).
llvm-svn: 296849
2017-03-03 01:13:23 +00:00
Francis Ricci 7cd7d9bc8e Revert "Use pthreads for thread-local lsan allocator cache on darwin"
Reverting due to revert of prerequisite patch r296706

This reverts commit 6e1f23078c1acc44295065d28167043c4d31ddd1.

llvm-svn: 296720
2017-03-02 00:12:58 +00:00
Francis Ricci ddee63ffb2 Revert "Increase stack size for stack-use-after-return test"
Reverting due to failures on aarch64

This reverts commit f8ff7e585134196e8482e4dd8752cd4c22cf027a.

llvm-svn: 296719
2017-03-02 00:12:56 +00:00
Francis Ricci 923a320441 Use pthreads for thread-local lsan allocator cache on darwin
Summary:
This patch allows us to move away from using __thread on darwin,
which is requiring for building lsan for darwin on ios version 7
and on iossim i386.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 296707
2017-03-01 23:18:15 +00:00
Francis Ricci bdc963a98c Increase stack size for stack-use-after-return test
Summary:
The current size is flaky, as revealed by checking
the stack size attr after setting it.

Reviewers: kubamracek, rnk

Subscribers: llvm-commits

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

llvm-svn: 296706
2017-03-01 23:18:13 +00:00
Filipe Cabecinhas 9a563daff5 Restrict usage of MemoryMappingLayout to platforms which support it
llvm-svn: 296657
2017-03-01 19:20:13 +00:00
Filipe Cabecinhas 74ad311556 Reapply r296419: [asan] Print a "PC is at a non-executable memory region" message if that's the case
Summary: Points the user to look at function pointer assignments.

Reviewers: kcc, eugenis, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 296653
2017-03-01 18:52:11 +00:00
Dean Michael Berris fbe64b65a8 [XRay] [compiler-rt] [NFC] Annotate unused variables for the compiler.
Summary:
Use a common definition of a "this variable is unused" annotation for useless
variables only present for their lambda global initializers, to silence gcc's
warning.

Reviewers: dberris

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 296449
2017-02-28 08:48:46 +00:00
Dean Michael Berris 427215ce5e [XRay][compiler-rt] Switch default XRay 'patch_premain' to false
Summary:
Currently, we assume that applications built with XRay would like to
have the instrumentation sleds patched before main starts. This patch
changes the default so that we do not patch the instrumentation sleds
before main. This default is more helpful for deploying applications in
environments where changing the current default is harder (i.e. on
remote machines, or work-pool-like systems).

This default (not to patch pre-main) makes it easier to selectively run
applications with XRay instrumentation enabled, than with the current
state.

Reviewers: echristo, timshen

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 296445
2017-02-28 08:10:01 +00:00
Filipe Cabecinhas 6e36c11d2a Revert r296419 since the strings appear to need some tweaking.
llvm-svn: 296428
2017-02-28 02:45:46 +00:00
Filipe Cabecinhas f1d4ae579d [non-executable-pc.cpp] Try to fix clang-ppc64be buildbot.
llvm-svn: 296424
2017-02-28 02:05:53 +00:00
Filipe Cabecinhas cd643f6324 [asan] Print a "PC is at a non-executable memory region" message if that's the case
Summary: Points the user to look at function pointer assignments.

Reviewers: kcc, eugenis, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 296419
2017-02-28 00:56:43 +00:00
Evgeniy Stepanov acc8ebb8e3 [msan] Test for alloca handling.
llvm-svn: 296051
2017-02-24 00:13:28 +00:00
Filipe Cabecinhas 3f4181db66 [test] Use @LINE macro
llvm-svn: 295995
2017-02-23 17:23:28 +00:00
Benjamin Kramer 782e98e8aa [xray] Unbreak unittest after r295967.
llvm-svn: 295969
2017-02-23 13:13:27 +00:00
Benjamin Kramer 7654191e70 [Xray] fix building the runtime with GCC.
GCC has a warning about enum bitfields that cannot be disabled. Do the
ugly thing and go through uint8_t for all the values.

llvm-svn: 295967
2017-02-23 12:49:41 +00:00
Kuba Mracek c90b79c585 Re-commit of r295318, which was reverted due to AArch64 flakiness. Moving the test to Darwin only.
llvm-svn: 295801
2017-02-22 01:13:34 +00:00
Tim Shen 01fb2c87b9 [XRay] Change the ppc trampoline asm file into a different name, to not collide with the cc file. NFC.
llvm-svn: 295795
2017-02-22 00:19:43 +00:00
Vitaly Buka 5d6631d8b4 [compiler-rt] Prevent symbolizer from starting itself.
Summary:
If symbolizer was instrumented with sanitizer and crash, it may
try to call itself again causing infinite recursion of crashing processes.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits, dberris

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

llvm-svn: 295771
2017-02-21 21:39:24 +00:00
Anna Zaks aacf7958c5 [asan] Re-enable a test on i386-darwin.
This test has been reverted in r279918 due to flaky atos support in the OS
some machines in the buildbot fleet were running. This should not be a
problem anymore.

llvm-svn: 295766
2017-02-21 20:46:50 +00:00
Etienne Bergeron 0eec53cb41 [compiler-rt][asan] Fix incorrect macro preventing ICF with MSVC
Summary:
The DLL thunks are stubs added to an instrumented DLL to redirect ASAN API calls
to the real ones in the main executable. These thunks must contain dummy
code before __asan_init got called. Unfortunately, MSVC linker is doing ICF and is
merging functions with the same body.


In our case, this two ASAN thunks were incorrectly merged:
```
asan_interface.inc:16
INTERFACE_FUNCTION(__asan_before_dynamic_init)
```
```
sanitizer_common_interface.inc:16
INTERFACE_FUNCTION(__sanitizer_verify_contiguous_container)
```

The same thunk got patched twice. After the second patching, calls to
`__asan_before_dynamic_init` are redirected to `__sanitizer_verify_contiguous_container`
and trigger a DCHECK on incorrect operands/

The problem was caused by the macro that is only using __LINE__ to prevent
collapsing code.
```
 #define INTERCEPT_SANITIZER_FUNCTION(name)
   extern "C" __declspec(noinline) void name() {
   volatile int prevent_icf = (__LINE__ << 8); (void)prevent_icf;
```

The current patch is adding __COUNTER__ which is safer than __LINE__.

Also, to precent ICF (guarantee that code is different), we are using a unique attribute:
  - the name of the function

Reviewers: rnk

Reviewed By: rnk

Subscribers: llvm-commits, kubamracek, chrisha, dberris

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

llvm-svn: 295761
2017-02-21 20:04:47 +00:00