Commit Graph

8573 Commits

Author SHA1 Message Date
Alex Shlyapnikov 05bf27ac3f Avoid calling SizeClassMap::MaxCachedHint on hot path, it's not free.
Summary: Remove unecessary SizeClassMap::MaxCachedHint call.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 300103
2017-04-12 20:51:42 +00:00
Francis Ricci e9438b35aa Fix memory leaks in address sanitizer darwin tests
Summary: These leaks are detected by leak sanitizer for darwin.

Reviewers: glider, kubamracek, kcc, alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 300080
2017-04-12 17:31:41 +00:00
Francis Ricci f518c75641 Use 0-padding for i386 and arm print format specifiers
Summary:
This is used for the other architectures in print_address, but is
missing from i386 and arm.

Reviewers: m.ostapenko, spetrovic

Subscribers: aemerson, rengolin, llvm-commits, kubamracek

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

llvm-svn: 300065
2017-04-12 14:25:28 +00:00
Renato Golin baf04f92bc [LSAN] Disable on ARM/Thumb for good
I didn't pay enough attention to the patch I reverted, now I'm going to
hit it with a bigger hammer until we can understand what the problems
are.

llvm-svn: 300044
2017-04-12 10:12:49 +00:00
Renato Golin c6c8f09e49 Revert "[lsan] Fix typo in test/lsan/lit.common.cfg"
This reverts commit r299957. It broke the Thumb bots. We need to make
sure why and maybe stop it from being tested on Thumb environments. But
for now, let's get the bots green.

llvm-svn: 300042
2017-04-12 09:45:08 +00:00
Ismail Donmez d063db71e3 Fix compile error
llvm-svn: 300041
2017-04-12 09:42:46 +00:00
Martin Pelikan 75ed0acf97 [XRay] [compiler-rt] Refactor rewinding FDR logging.
Summary:
While there, make the threshold in ticks for the rewind computed only
once and not per function, unify the two versions we had and slightly
reformat bits according to coding standards.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 300028
2017-04-12 05:30:35 +00:00
Martin Pelikan bb1147317a [XRay] [compiler-rt] Simplify FDR logging handler. [NFC]
Summary:
Not repeating screamy failure paths makes the 300+ line function a bit shorter.
There's no need to overload the variable name "Buffer" if it only works on the
thread local buffer.  Fix some comments while there.

I plan to move the rewinding logic into a separate function too, but in this
diff it would be too much of a mess to comprehend.  This is trivially NFC.

Reviewers: kpw, dberris

Subscribers: llvm-commits

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

llvm-svn: 300018
2017-04-12 01:31:17 +00:00
Douglas Yung bcfc9d9b38 [XRay][compiler-rt] Add another work-around to XRay FDR tests when TSC emulation is needed
This patch applies a work-around to the XRay FDR tests when TSC emulation is 
needed because the processor frequency cannot be determined.

This fixes PR32620 using the suggestion given by Dean in comment 1.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 300017
2017-04-12 01:24:48 +00:00
Kostya Serebryany 13c8daf57a [msan] fix iconv interceptor. before the fix the interceptor failed to mark memory as initialized if iconv returned -1. Found in a hard way while fuzzing libxml2 :(
llvm-svn: 300010
2017-04-12 00:12:34 +00:00
Francis Ricci 03b2a8e47e Implement standalone lsan interceptors for OS X
Summary:
Mimicks the existing tsan and asan implementations of
Darwin interception.

Reviewers: kubamracek, kcc, glider

Subscribers: llvm-commits, mgorny

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

llvm-svn: 299979
2017-04-11 20:05:02 +00:00
Francis Ricci 84f17f32ad Don't delete lsan thread-local data until it's no longer required
Summary:
The routines for thread destruction in the thread registry require
the lsan thread index, which is stored in pthread tls on OS X.
This means that we need to make sure that the lsan tls isn't destroyed
until after the thread registry tls. This change ensures that we
don't delete the lsan tls until we've finished destroying the thread
in the registry, ensuring that the destructor for the lsan tls runs
after the destructor for the thread registry tls.

This patch also adds a check to ensure that the thread ID is valid before
returning it in GetThreadID(), to ensure that the above behavior
is working correctly.

Reviewers: dvyukov, kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 299978
2017-04-11 19:57:12 +00:00
Xinliang David Li 577b9d41d6 Revert 299954 : test failure needs to be fixed
llvm-svn: 299960
2017-04-11 16:27:26 +00:00
Maxim Ostapenko 83d37dc066 [lsan] Fix typo in test/lsan/lit.common.cfg
llvm-svn: 299957
2017-04-11 16:22:19 +00:00
Xinliang David Li a53e6702d2 [Profile] PE binary coverage bug fix
PR/32584

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

llvm-svn: 299954
2017-04-11 15:51:39 +00:00
Maxim Ostapenko de3b9a2ecc Reapply "Enable LSan for arm Linux"
This patch reapplies r299923 with typo fixed in BLX macros.

llvm-svn: 299948
2017-04-11 14:58:26 +00:00
Nico Weber 7124b5f6f9 Revert r299923, it doesn't build in bootstrap builds.
FAILED: lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.arm.dir/sanitizer_linux.cc.o 
lib/sanitizer_common/sanitizer_linux.cc:1340:24: error: invalid instruction
                       BLX(ip)
                       ^
lib/sanitizer_common/sanitizer_linux.cc:1313:19: note: expanded from macro 'BLX'
#  define BLX(R) "mov lr, pc; bx" #R "\n"
                  ^
<inline asm>:6:13: note: instantiated into assembly here
mov lr, pc; bxip
            ^~~~

llvm-svn: 299943
2017-04-11 14:28:49 +00:00
Catherine Moore 82525903a4 This patch causes the installation of headers for the sanitizer and/or xray to be disabled when COMPILER_RT_BUILD_SANITIZERS=OFF and/or COMPILER_RT_BUILD_XRAY=OFF.
Reviewer: dberris

Subscribers: dberris, mgorny, llvm-commits, clm

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

llvm-svn: 299940
2017-04-11 13:45:05 +00:00
Maxim Ostapenko 950d2809d5 [lsan] Enable LSan for arm Linux
This patch enables LSan for arm Linux.

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

llvm-svn: 299923
2017-04-11 08:13:38 +00:00
Douglas Yung c79031b2e9 [XRay][compiler-rt] Add support for TSC emulation for x86_64 to xray_fdr_logging.cc
Previously in r297800, a work-around was created to use TSC emulation on x86_64 when RDTSCP was not available on the host. A similar change was needed in the file xray_fdr_logging.cc which this patch ports over to that file.

Eventually the code should be refactored as there will be 3 locations with the same code, but that can be done as a separate step. This patch is just to keep the test from failing on my machine due to an illegal instruction since RDTSCP is not available on my x86_64 linux VM.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 299922
2017-04-11 07:45:16 +00:00
Dean Michael Berris 7b0ad61eaa [XRay][compiler-rt] Remove the xray_fdr_log_printer_tool
Summary:
We can move this functionality into LLVM's tools instead, as it no
longer is strictly required for the compiler-rt testing infrastructure.
It also is blocking the successful bootstrapping of the clang compiler
due to a missing virtual destructor in one of the flag parsing library.

Since this binary isn't critical for the XRay runtime testing effort
anymore (yet), we remove it in the meantime with the hope of moving the
functionality in LLVM proper instead.

Reviewers: kpw, pelikan, rnk, seurer, eugenis

Subscribers: llvm-commits, mgorny

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

llvm-svn: 299916
2017-04-11 06:04:08 +00:00
Alex Shlyapnikov 4d240da94b [PPC64, Sanitizers] Proper stack frame for the thread spawned in internal_clone
Summary:
Set up the proper stack frame for the thread spawned in internal_clone,
the current code does not follow ABI (and causes SEGV trying to use this
malformed frame).

Reviewers: wschmidt

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 299896
2017-04-10 23:24:50 +00:00
Vitaly Buka 2bca1a9f40 [tsan] Fall-back to IPv6 if IPv4 is not available.
Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 299885
2017-04-10 21:03:21 +00:00
Vitaly Buka c5e73d6e24 [msan] Choose in runtime if IPv4 or IPv6 are supported.
Summary: This reverts commit cab5051c691ce27a7ffac41e8e76ceb222ad9549.

Reviewers: eugenis

Subscribers: mgorny, llvm-commits

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

llvm-svn: 299884
2017-04-10 21:03:18 +00:00
Evgeniy Stepanov 2384165155 Revert "[asan] Fix dead stripping of globals on Linux (compiler-rt)."
This reverts r299698, which caused a big increase in object file size.

llvm-svn: 299881
2017-04-10 20:36:43 +00:00
Ivan A. Kosarev ec4880905d [Asan] Eliminate SHADOW_TO_MEM() macro
Differential Revision: https://reviews.llvm.org/D31592

llvm-svn: 299867
2017-04-10 19:13:47 +00:00
Vitaly Buka 59d309c7b5 [msan] Make test to fall-back to IPv6 if IPv4 is not available.
Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 299862
2017-04-10 17:59:07 +00:00
Vitaly Buka 08582c8e50 [msan] Replace AF_INET with AF_UNIX to avoid IPv4 vs IPv6 issues.
Summary: This reverts commit 79cf16bf224d6ac9fb9e0356c5947ebc4fd6ff92.

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 299860
2017-04-10 17:58:03 +00:00
Vitaly Buka 30b4cfab1b [msan] Wrap sockaddr_in and socket for future IPv6 support.
Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 299859
2017-04-10 17:56:37 +00:00
Vitaly Buka 9804c81c55 [msan] Reorder unittests for future parametrization.
Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 299858
2017-04-10 17:22:06 +00:00
Evgeniy Stepanov bacee5c04f [cfi] Accept weak definition of __cfi_check.
https://reviews.llvm.org/D31796 results in LLD emitting __cfi_check
as a weak symbol, while Gold keeps it strong. Accept both.

llvm-svn: 299804
2017-04-07 22:52:08 +00:00
Rafael Espindola fc20b2b4ad Use a temp file to avoid Process Substitution.
Thanks to Reid Kleckner for the suggestion.

llvm-svn: 299794
2017-04-07 18:55:03 +00:00
Reid Kleckner 8cdfed7c9d [builtins] Remove stray quotes to fix check-builtins on non-Windows :(
llvm-svn: 299790
2017-04-07 17:40:25 +00:00
Reid Kleckner bfad55fbc0 [builtins] Make some ISA macro checks work with MSVC
llvm-svn: 299786
2017-04-07 17:18:43 +00:00
Reid Kleckner 3ae87c4650 [builtins] Fix MSVC build
Avoid __attribute__((constructor)) in cpu_model.c.

Use more C99 _Complex emulation in divtc3.c. Joerg Sonnenberger added
this builtin just after the last round of C99 _Complex emulation landed
in r249514 (Oct 2015).

llvm-svn: 299784
2017-04-07 16:54:32 +00:00
Reid Kleckner 8c78ca2e8f [builtins] Get the builtins tests passing on Windows
Many things were broken:

- We stopped building most builtins on Windows in r261432 for reasons
  that are not at all clear to me. This essentially reverts that patch.

- Fix %librt to expand to clang_rt.builtins-$arch.lib on Windows instead
  of libclang_rt.builtins-$arch.a.

- Fix memory protection tests (trampoline, enable executable, clear
  cache) on Windows. One issue was that the MSVC incremental linker
  generates ILT thunks for functions with external linkage, so memcpying
  the functions into the executable stack buffer wasn't working. You
  can't memcpy an RIP-relative jump without fixing up the offset.

- Disable tests that rely on C99 complex library functions when using
  the MSVC CRT, which isn't compatible with clang's C99 _Complex.

In theory, these could all be separate patches, but it would not green
the tests, so let's try for it all at once. Hopefully this fixes the
clang-x64-ninja-win7 bot.

llvm-svn: 299780
2017-04-07 16:35:09 +00:00
Reid Kleckner 78495ea7c0 Add missing import
llvm-svn: 299739
2017-04-07 01:24:48 +00:00
Reid Kleckner f6e857c402 [lit] Fix Darwin pickling errors with process pools
For a function to be pickle-able, it has to be in the top-level of a
real Python module. So, I made one for this code snippet.

llvm-svn: 299738
2017-04-07 01:23:15 +00:00
Evgeniy Stepanov 0680968ff3 [asan] Fix dead stripping of globals on Linux (compiler-rt).
This is a re-land of r298173, r298169, r298159.

llvm-svn: 299698
2017-04-06 19:55:52 +00:00
Rafael Espindola 8024cac19a Replace a few uses of basename.
This replaces a few uses of basename with the recently introduced lit
replacements.

llvm-svn: 299693
2017-04-06 19:38:24 +00:00
Ivan Krasin e63dccd98d Revert r299672: Add a virtual destructor to a class with virtual methods.
Reason: breaks sanitizers builds.

Original Differential Revision: https://reviews.llvm.org/D317

llvm-svn: 299679
2017-04-06 18:22:25 +00:00
Dimitry Andric 01220bf9d2 Add __ffssi2 implementation to compiler-rt builtins
Summary:
During MIPS implementation work for FreeBSD, John Baldwin (jhb@FreeBSD.org)
found that gcc 6.x emits calls to __ffssi2() when compiling libc and some
userland programs in the base system.

Add it to compiler-rt's builtins, based off of the existing __ffsdi2()
implementation.  Also update the CMake files and add a test case.

Reviewers: howard.hinnant, weimingz, rengolin, compnerd

Reviewed By: weimingz

Subscribers: dberris, mgorny, llvm-commits, emaste

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

llvm-svn: 299675
2017-04-06 18:12:02 +00:00
Ivan Krasin 547aadcba8 Add a virtual destructor to a class with virtual methods.
Summary:
Recently, Clang enabled the check for virtual destructors
in the presence of virtual methods. That broke the bootstrap
build. Fixing it.

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 299672
2017-04-06 17:58:45 +00:00
Francis Ricci 4cce35f0ce Enable builds of darwin lsan by default
Summary: Testing and asan leak detection are disabled by default.

Reviewers: kubamracek, kcc

Subscribers: srhines, llvm-commits, mgorny

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

llvm-svn: 299669
2017-04-06 17:41:26 +00:00
Craig Topper d3115972bf [TSan] Adjust expectation for check_analyze.sh
r299658 fixed a case where InstCombine was replicating instructions instead of combining. Fixing this reduced the number of pushes and pops in the __tsan_read and __tsan_write functions.

Adjust the expectations to account for this after talking to Dmitry Vyukov.

llvm-svn: 299661
2017-04-06 17:09:08 +00:00
Dean Michael Berris d41c5ffc3e [XRay][compiler-rt] Remove unused local variable
The local was only referenced in assertions.

Follow-up to D31345.

llvm-svn: 299644
2017-04-06 11:27:53 +00:00
Maxim Ostapenko e6b81315f7 Try to fix MAC buildbot after r299630
llvm-svn: 299632
2017-04-06 08:17:09 +00:00
Maxim Ostapenko 18afec1ba6 Try to fix windows buildbot after r299630
llvm-svn: 299631
2017-04-06 07:53:26 +00:00
Maxim Ostapenko fe863a6510 [lsan] Avoid segfaults during threads destruction under high load
This patch addresses two issues:

	* It turned out that suspended thread may have dtls->dtv_size == kDestroyedThread (-1)
	and LSan wrongly assumes that DTV is available. This leads to SEGV when LSan tries to
	iterate through DTV that is invalid.
	* In some rare cases GetRegistersAndSP can fail with errno 3 (ESRCH). In this case LSan
	assumes that the whole stack of a given thread is available. This is wrong because ESRCH
	can indicate that suspended thread was destroyed and its stack was unmapped. This patch
	properly handles ESRCH from GetRegistersAndSP in order to avoid invalid accesses to already
	unpapped threads stack.

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

llvm-svn: 299630
2017-04-06 07:42:27 +00:00
Dean Michael Berris 895171e6ee [XRay] [compiler-rt] Unwriting FDR mode buffers when functions are short.
Summary:
"short" is defined as an xray flag, and buffer rewinding happens for both exits
 and tail exits.

 I've made the choice to seek backwards finding pairs of FunctionEntry, TailExit
 record pairs and erasing them if the FunctionEntry occurred before exit from the
 currently exiting function. This is a compromise so that we don't skip logging
 tail calls if the function that they call into takes longer our duration.

 This works by counting the consecutive function and function entry, tail exit
 pairs that proceed the current point in the buffer. The buffer is rewound to
 check whether these entry points happened recently enough to be erased.

 It is still possible we will omit them if they call into a child function that
 is not instrumented which calls a fast grandchild that is instrumented before
 doing other processing.

Reviewers: pelikan, dberris

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 299629
2017-04-06 07:14:43 +00:00
Weiming Zhao fbe67da29b [Builtins] Fix div0 error in udivsi3
Summary: Need to save `lr` before bl to aeabi_div0

Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: llvm-commits

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

llvm-svn: 299628
2017-04-06 06:13:39 +00:00
Evgeniy Stepanov 7e94d38374 [cfi] Fix symbol lookup hack in cross-dso cfi to handle LLD binaries.
llvm-svn: 299604
2017-04-06 00:34:45 +00:00
Rafael Espindola 03994b814d Simplify test a bit.
There are two cases to consider:

We are using the internal shell. This will still fail because of
ulimit.
We are using an external shell. In this case the difference is that we
now also constrain FileCheck to use less than 4 MB of of stack, which
it should :-)

llvm-svn: 299586
2017-04-05 20:26:33 +00:00
Rafael Espindola 69a9e931ce Avoid calling basename to compute xdynamiclib_namespec.
This also exposes a xdynamiclib_filename that can be used to simplify
a few tests.

llvm-svn: 299478
2017-04-04 22:33:02 +00:00
Rafael Espindola f58991b7a4 Don't remove the cwd.
This works with a regular shell since the kernel can keep track of a
deleted cwd. Since we just keep a path string, the following
subprocess invocations fail.

I think this would also fail on windows.

llvm-svn: 299471
2017-04-04 21:42:59 +00:00
Rafael Espindola 01a8db64b1 Avoid sub shell.
Another step in getting these tests to run with the integrated one.

llvm-svn: 299452
2017-04-04 17:49:45 +00:00
Rafael Espindola 5b32f8e6bc Replace wc -l with count.
This is a far more common way in llvm of counting lines in tests.

llvm-svn: 299231
2017-03-31 16:49:37 +00:00
Rafael Espindola ebb4a918b5 Simplify test.
We don't need && since that is how various run lines are combined.
The redirects were not being used.

llvm-svn: 299215
2017-03-31 13:35:37 +00:00
Sam McCall 61dc7c0790 Remove unused variable.
llvm-svn: 299206
2017-03-31 12:07:58 +00:00
Maxim Ostapenko f73b73d04d [asan] Move AsanCheckDynamicRTPrereqs check under flag
The patch addresses https://github.com/google/sanitizers/issues/786. Currently AsanCheckDynamicRTPrereqs prevents
dynamic ASan runtime from running in some important environments e.g. cowbuilder and fakeroot that may also work with interposition.
Let's allow users to switch off the check given that they know what they do.

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

llvm-svn: 299188
2017-03-31 06:36:37 +00:00
Kuba Mracek b2e2634510 [asan] Turn -fsanitize-address-use-after-scope on by default [compiler-rt part]
AddressSanitizer has an optional compile-time flag, -fsanitize-address-use-after-scope, which enables detection of use-after-scope bugs. We'd like to have this feature on by default, because it is already very well tested, it's used in several projects already (LLVM automatically enables it when using -DLLVM_USE_SANITIZER=Address), it's low overhead and there are no known issues or incompatibilities.

This patch enables use-after-scope by default via the Clang driver, where we set true as the default value for AsanUseAfterScope. This also causes the lifetime markers to be generated whenever fsanitize=address is used. This has some nice consequences, e.g. we now have line numbers for all local variables.

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

llvm-svn: 299175
2017-03-31 03:00:29 +00:00
Kuba Mracek f1980a6305 Fixup for r299085: Keep the scribble.cc test on Darwin only, while I investigate why this test sometimes fails on Linux.
llvm-svn: 299130
2017-03-30 23:34:44 +00:00
Kuba Mracek 21e8ce398d Fixup for r299085: Disable the scribble.cc test on AArch64.
llvm-svn: 299099
2017-03-30 19:36:49 +00:00
Kuba Mracek 48c74b35d1 Fixup for r299085: On Windows %p doesn't print 0x prefix.
llvm-svn: 299092
2017-03-30 17:48:41 +00:00
Kuba Mracek c45f1e3134 Fixup for r299085: Print all output to stderr.
llvm-svn: 299090
2017-03-30 17:21:51 +00:00
Kuba Mracek 152dbcac82 Fixup for r299085: Include stdint.h in scribble.cc to make uintptr_t available.
llvm-svn: 299089
2017-03-30 17:01:35 +00:00
Kuba Mracek 0bf5ec2812 [tsan] Add interceptor for xpc_connection_cancel to avoid false positives
TSan reports a false positive when using xpc_connection_cancel. We're missing a happens-before edge from xpc_connection_cancel to the event handler on the same connection.

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

llvm-svn: 299086
2017-03-30 15:48:25 +00:00
Kuba Mracek fe7e91b003 [asan] Implement "scribble" flags, which overwrite free'd memory with 0x55
This patch implements "Malloc Scribble" in ASan via "max_free_fill_size" and "free_fill_byte" flags, which can be used to overwrite free()'d memory. We also match the behavior of MallocScribble and MallocPreScribble env vars on macOS (see https://developer.apple.com/library/content/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html), which is a helpful tool to detect use-after-free bugs that happen in non-instrumented code.

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

llvm-svn: 299085
2017-03-30 15:44:57 +00:00
Rafael Espindola 281979b12d avoid a subshell.
Instead of using grep -v we can just expand the globs a bit.

llvm-svn: 299084
2017-03-30 15:02:24 +00:00
Francis Ricci 2aa23e892c Enable leak detection on linux-i686 by default
Summary:
This is already assumed by the test suite, and by
asan_flags.cc.

Reviewers: m.ostapenko, vitalybuka, kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 299082
2017-03-30 14:05:46 +00:00
Rafael Espindola bc16aa9551 Use FileCheck instead of [.
llvm-svn: 299081
2017-03-30 14:02:08 +00:00
Rafael Espindola 41ca83f811 Add LIT_USE_INTERNAL_SHELL to compiler-rt tests.
I am working on improving our internal bot infrastructure. One thing
that is unique to the ps4 is that we want to run the posix tests, but
have to execute them on windows.

We currently have a local hack to use a shell on windows, but it is
pretty much impossible to get all all the tools to play nice with all
the heuristics for what is a path and what is a command line option.

This adds support LIT_USE_INTERNAL_SHELL and I will then try to fix
the tests that fail with it but adding the missing features.

llvm-svn: 299077
2017-03-30 13:33:22 +00:00
Rafael Espindola be927f586d Use count instead of grep -c.
Using count is more common in llvm and avoids a subshell.

llvm-svn: 299076
2017-03-30 13:22:30 +00:00
Maxim Ostapenko f29aec76dd [sanitizer] Move fread and fwrite interceptors to sanitizer_common
{M, T, E}San have fread and fwrite interceptors, let's move them to sanitizer_common to enable ASan checks as well.

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

llvm-svn: 299061
2017-03-30 07:25:33 +00:00
Dean Michael Berris d7b2aafcfc [XRay][compiler-rt] Spell REQUIRES properly for x86_64-linux
Until llvm-xray starts running/supporting binaries that are not ELF64 we
only run the FDR tests on x86_64-linux. Previous changes caused the
tests to not actually run on x86_64.

Follow-up on D31454.

llvm-svn: 299050
2017-03-30 03:50:56 +00:00
Dean Michael Berris c8381a8ad4 [XRay][compiler-rt] Only run tests using llvm-xray in x86_64 for now
Followup on D31454.

llvm-svn: 299049
2017-03-30 03:18:48 +00:00
Dean Michael Berris fecffaf87a [XRay][compiler-rt] XFAIL the FDR mode tests on aarch64-42vma
Followup on D31454.

llvm-svn: 299048
2017-03-30 02:48:50 +00:00
Kuba Mracek 8ed2928d2c [asan] Support line numbers in StackVarDescr
When -fsanitize-address-use-after-scope is used, the instrumentation produces line numbers in stack frame descriptions. This patch make sure the ASan runtime supports this format (ParseFrameDescription needs to be able to parse "varname:line") and prepares lit tests to allow line numbers in ASan report output.

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

llvm-svn: 299043
2017-03-30 00:41:09 +00:00
Dean Michael Berris 51c1365501 [XRay][compiler-rt] Use llvm-xray in FDR mode tests
Summary:
This change allows us to do an end-to-end test of the FDR mode
implementation that uses the llvm-xray tooling to verify that what we
are both writing and reading the data in a consistent manner.

Reviewers: kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 299042
2017-03-30 00:35:58 +00:00
Kostya Serebryany 2203ee08dd [sanitizers] Fix get_groups interceptor in sanitizer (https://reviews.llvm.org/D31332, patch by Martin Liška)
llvm-svn: 299036
2017-03-29 22:59:28 +00:00
Francis Ricci a79b8a22b4 Move current thread data out of lsan_common on linux
Summary:
Now that we have a platform-specific non-common lsan file, use
it to store non-common lsan data.

Reviewers: kubamracek

Subscribers: llvm-commits

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

llvm-svn: 299032
2017-03-29 21:49:47 +00:00
Francis Ricci 1aa20001ed Remove failing check from platform specific darwin lsan initializer
Summary:
We currently don't have any platform specific darwin
lsan modules, don't force failure if they don't exist.

Reviewers: kubamracek

Subscribers: llvm-commits

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

llvm-svn: 299031
2017-03-29 21:49:13 +00:00
Filipe Cabecinhas e144b72372 Add allocator_frees_and_returns_null_on_realloc_zero=false flag for compatibility with allocators which allow a realloc(p, 0) and don't free the pointer.
Summary:
I know of two implementations that do this (ASan is not protecting against accessing the returned memory for now, just like malloc(0)):
SIE libc on the PS4
dlmalloc has a flag for this

This allows us to properly support this behaviour.

Reviewers: vsk, kcc

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 299016
2017-03-29 18:17:22 +00:00
Weiming Zhao 182db30842 [Builtins] Mark mulsc3_test as UNSUPPORTED for armhf; NFC
The same test fails on clang-cmake-armv7-a15-full biuld bot
but passes the clang-cmake-thumbv7-a15-full.

For now, we mark it as UNSUPPORTED for armhf target.
Bug 32457 tracks it.

llvm-svn: 299005
2017-03-29 16:59:09 +00:00
Weiming Zhao ce957f9070 [Compiler-RT][Builtins] Remove XFAIL for mulsc3; NFC
It was XFAILed in r298974. However, the problem was not exposed on
the buildbot because hardfp flag was not passed during the test.

We can fix the CMAKE to pass the same flag as building the lib to the
RUN line to see if the problem is still there. For now, we remove the
XFAIL.

llvm-svn: 298997
2017-03-29 14:55:51 +00:00
Dean Michael Berris 9b57ca171d [XRay] [compiler-rt] Write buffer length to FDR log before writing buffer.
Summary:
Currently the FDR log writer, upon flushing, dumps a sequence of buffers from
its freelist to disk. A reader can read the first buffer up to an EOB record,
but then it is unclear how far ahead to scan to find the next threads traces.

There are a few ways to handle this problem.
1. The reader has externalized knowledge of the buffer size.
2. The size of buffers is in the file header or otherwise encoded in the log.
3. Only write out the portion of the buffer with records. When released, the
   buffers are marked with a size.
4. The reader looks for memory that matches a pattern and synchronizes on it.

2 and 3 seem the most flexible and 2 does not rule 3 out.

This is an implementation of 2.

In addition, the function handler for fdr more aggressively checks for
finalization and makes an attempt to release its buffer.

Reviewers: pelikan, dberris

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 298982
2017-03-29 05:56:37 +00:00
Dean Michael Berris cf791cf389 [XRay][compiler-rt] Add an end-to-end test for FDR Logging
Summary:
This change exercises the end-to-end functionality defined in the FDR
logging implementation. We also prepare for being able to run traces
generated by the FDR logging implementation from being analysed with the
llvm-xray command that comes with the LLVM distribution.

This also unblocks D31385, D31384, and D31345.

Reviewers: kpw, pelikan

Subscribers: llvm-commits, mgorny

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

llvm-svn: 298977
2017-03-29 05:19:24 +00:00
Weiming Zhao d8ca74176e [Builtin] Unxfail tests for armhf
Summary:
Originally, a few tests fail for armhf target due to:
1) COMPILER_RT_ARMHF_TARGET was not set when building the lib
2) COMPILER_RT_ABI should not be defined as `__attribute__((pcs("aapcs")))` for armhf when building for both lib and tests

This address https://bugs.llvm.org//show_bug.cgi?id=32261

mulsc3_test.c is a newly exposed issue, which will be addressed separately.

Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: aemerson, llvm-commits, mgorny

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

llvm-svn: 298974
2017-03-29 03:36:46 +00:00
Francis Ricci 99a84b163f Postpone lsan tls allocation until required
Summary:
This prevents InternalAlloc from being called before the sanitizers
are fully initialized.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 298947
2017-03-28 21:56:45 +00:00
Francis Ricci ab85292261 Enable i386 builds for darwin lsan
Summary:
Now that __thread is no longer used for lsan on darwin, i386 builds
can be enabled.

Reviewers: kcc, kubamracek

Subscribers: danalbert, srhines, mgorny, llvm-commits

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

llvm-svn: 298946
2017-03-28 21:56:44 +00:00
Weiming Zhao 3a6951250c Reland "[Compiler-rt][Builtins] Implement lit-test support (part 2 of 2)"
Re-land of r298714 which got reverted in r298868.
It looks like the current lit tests won't run for Apple.
Possible reason is the libname is different. (need to update
the base_lib variable of lit.cfg)

llvm-svn: 298892
2017-03-27 23:57:44 +00:00
Francis Ricci f1c2f2a668 Fix missing sanitizer platform include
llvm-svn: 298884
2017-03-27 20:22:02 +00:00
Francis Ricci 2609fd319f Fix comment in lsan_linux.cc
llvm-svn: 298879
2017-03-27 19:44:11 +00:00
Francis Ricci 3e564e985f Move lsan allocator cache from lsan_common_linux to lsan_linux
Having this function in common seems to trigger a lot of unrelated
test failures. Given that this isn't really common code anyway,
move this to a new linux-specific lsan file.

llvm-svn: 298878
2017-03-27 19:42:37 +00:00
Bill Seurer 467afc5f84 [powerpc] deactivate ManyThreadsTest asan test on powerpc64
This test case occassionally hangs when run on powerpc.  This is also a
problem on AArch64 (see https://bugs.llvm.org/show_bug.cgi?id=24389).
Reactivate this when the problem is fixed.

This could also be related to the same problem as with the tests
ThreadedOneSizeMallocStressTest, ThreadedMallocStressTest, and several
others that do not run reliably on powerpc.

llvm-svn: 298873
2017-03-27 18:36:06 +00:00
Juergen Ributzka 3d1d9f4ced Revert "[Compiler-rt][Builtins] Implement lit-test support (part 2 of 2)"
This broke GreenDragon: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/29505/consoleFull

llvm-svn: 298868
2017-03-27 18:08:37 +00:00
Kuba Mracek ded235a141 [sanitizers] Upgrade ios min version to 8
Differential Revision: https://reviews.llvm.org/D29787

llvm-svn: 298860
2017-03-27 17:16:47 +00:00
Kuba Mracek 90caf899eb [sanitizers] Avoid using -fomit-frame-pointer on Darwin
On Darwin, we're having multiple issues with using -fomit-frame-pointer in the AddressSanitizer and ThreadSanitizer runtimes, so we're actually not using -fomit-frame-pointer in the our builds of the sanitizer dylibs. This patch just pushes our internal change upstream.

The issues are usually with debuggers, profilers and other tools that unwind the stack (crash reporter), which are often simply not able to get a stack trace. And crashlogs that don't contain a stack trace are a huge problem.

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

llvm-svn: 298859
2017-03-27 17:14:48 +00:00
Francis Ricci d668a018f7 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/D31291

llvm-svn: 298848
2017-03-27 14:07:50 +00:00
Francis Ricci 0add37927c Disable use_tls_dynamic on 32-bit linux
Summary:
This test fails with a false negative due to an unrelated change.
Since we expect a number of false negatives on 32-bit lsan,
disable this test on linux-i386 and linux-i686.

Reviewers: kubamracek, m.ostapenko, kcc

Subscribers: llvm-commits

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

llvm-svn: 298847
2017-03-27 14:06:49 +00:00
Ismail Donmez a2e33e60d2 Fix build error:
In file included from /home/abuild/rpmbuild/BUILD/llvm/projects/compiler-rt/lib/xray/tests/unit/xray_fdr_log_printer_tool.cc:15:
../projects/compiler-rt/lib/xray/tests/../xray_fdr_logging_impl.h:221:21: error: use of undeclared identifier 'CLOCK_MONOTONIC'
  wall_clock_reader(CLOCK_MONOTONIC, &TS);
                    ^
1 error generated.

llvm-svn: 298837
2017-03-27 10:17:03 +00:00
Sam McCall cf95f24a07 Add --std=c++11 to tests that #include <atomic>
llvm-svn: 298836
2017-03-27 09:45:38 +00:00
Dean Michael Berris 1dcec25487 [XRay][compiler-rt] Use sanitizer_common's atomic ops
Instead of std::atomic APIs for atomic operations, we instead use APIs
include with sanitizer_common. This allows us to, at runtime, not have
to depend on potentially dynamically provided implementations of these
atomic operations.

Fixes http://llvm.org/PR32274.

llvm-svn: 298833
2017-03-27 07:13:35 +00:00
Kuba Mracek 0b16ae5090 [asan] Remove column numbers from test expectations in invalid-pointer-pairs.cc
This is failing on some of our internal bots because we're using different symbolizers. It doesn't seem important and we never test for column numbers in any other tests, so let's just remove it.

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

llvm-svn: 298822
2017-03-26 21:20:42 +00:00
Kuba Mracek a1737293fc [tsan] Only Acquire/Release GCD queues if they're not NULL
While it's usually a bug to call GCD APIs, such as dispatch_after, with NULL as a queue, this often "somehow" works and TSan should maintain binary compatibility with existing code. This patch makes sure we don't try to call Acquire and Release on NULL queues, and add one such testcase for dispatch_after.

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

llvm-svn: 298820
2017-03-26 20:59:23 +00:00
Dmitry Vyukov 8096a8c86f tsan: add new mutex annotations
There are several problems with the current annotations (AnnotateRWLockCreate and friends):
- they don't fully support deadlock detection (we need a hook _before_ mutex lock)
- they don't support insertion of random artificial delays to perturb execution (again we need a hook _before_ mutex lock)
- they don't support setting extended mutex attributes like read/write reentrancy (only "linker init" was bolted on)
- they don't support setting mutex attributes if a mutex don't have a "constructor" (e.g. static, Java, Go mutexes)
- they don't ignore synchronization inside of lock/unlock operations which leads to slowdown and false negatives
The new annotations solve of the above problems. See tsan_interface.h for the interface specification and comments.

Reviewed in https://reviews.llvm.org/D31093

llvm-svn: 298809
2017-03-26 15:27:04 +00:00
Evgeniy Stepanov 656bc5bb5c Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.
Only depend on LLD if it is going to be built.

Re-land of r298174 which got reverted in r298287.

llvm-svn: 298753
2017-03-25 00:42:25 +00:00
Alex Shlyapnikov f51fafde1e Fix flaky strtok.c test.
Asserting the result of strtok when we expect delimiter overflow is
flaky, the result depends on the random state of memory right after the
delimiters.

llvm-svn: 298743
2017-03-24 21:43:56 +00:00
Kuba Mracek e598c0d8e1 Follow-up for r298738: Use "0" instead of "false" because the variable is uptr.
llvm-svn: 298741
2017-03-24 21:12:24 +00:00
Kuba Mracek 44df297598 Fix an uninitialized field in tsan_block_context_t/AllocContext in tsan_libdispatch_mac.cc.
llvm-svn: 298738
2017-03-24 20:57:33 +00:00
Weiming Zhao a78ae8a172 Revert "builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA."
This reverts commit c3709191b6d36c4c936173f4a9a29a734b12cb15.
(commit by mistake)

llvm-svn: 298715
2017-03-24 17:08:35 +00:00
Weiming Zhao 2dff98414f [Compiler-rt][Builtins] Implement lit-test support (part 2 of 2)
Summary:
Original r297566 (https://reviews.llvm.org/D30802) is splitted into two parts.
This part adds CMakefile/lit.cfg support.

Reviewers: rengolin, compnerd, jroelofs, erik.pilkington

Subscribers: srhines, dberris, mgorny

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

llvm-svn: 298714
2017-03-24 17:06:05 +00:00
Weiming Zhao 19bf8bfa15 builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA.
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.

Due to this:
 - use  __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB
 - use '.thumb' directive consistently  in all affected files
 - decorate all thumb functions using
   DEFINE_COMPILERRT_THUMB_FUNCTION()

---------
Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 !

Reviewers: weimingz, rengolin, compnerd

Subscribers: aemerson, dim

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

llvm-svn: 298713
2017-03-24 17:06:00 +00:00
Kuba Mracek d8789fdf0b Update debug_external.cc testcase to use TSan-invisible barriers to reduce flakiness.
llvm-svn: 298707
2017-03-24 16:37:02 +00:00
Martin Pelikan 1730dc789e [XRay] [compiler-rt] Plug a file descriptor leak in a failure case.
Summary: Fd needs to be closed before the number gets out of scope.

Reviewers: dberris

Subscribers: llvm-commits

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

llvm-svn: 298685
2017-03-24 05:02:51 +00:00
Kuba Mracek 1082904d20 Fix a warning when running the GotsanRuntimeCheck test on Darwin.
llvm-svn: 298684
2017-03-24 03:57:27 +00:00
Kuba Mracek 38ded5a37f Update the Darwin/external.cc testcase to use rpath. This means we can move the test output executables and still be able to run them.
llvm-svn: 298682
2017-03-24 03:53:44 +00:00
Alex Shlyapnikov d6848fc58f Add strtok interceptor for ASAN for Windows.
Summary: Fixes test broken by D30384

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 298658
2017-03-23 23:20:47 +00:00
Alex Shlyapnikov 4ab77b9f28 [asan] Add an interceptor for strtok
Summary:
This change addresses https://github.com/google/sanitizers/issues/766. I
tested the change with make check-asan and the newly added test case.

Reviewers: ygribov, kcc, alekseyshl

Subscribers: kubamracek, llvm-commits

Patch by mrigger

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

llvm-svn: 298650
2017-03-23 21:39:52 +00:00
Kostya Kortchinsky 69d458fa55 [scudo] Add test exercising pthreads
Summary: Scudo didn't have any test using multiple threads. Add one, borrowed from lsan.

Reviewers: kcc, alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 298636
2017-03-23 19:21:10 +00:00
Alex Shlyapnikov 86abf9aeb3 Bypass potential libc's sysconf interceptors
Summary:
sysconf(_SC_PAGESIZE) is called very early during sanitizer init and
any instrumented code (sysconf() wrapper/interceptor will likely be
instrumented) calling back to sanitizer before init is done will
most surely crash.

2nd attempt, now with glibc version checks (D31092 was reverted).

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 298613
2017-03-23 15:57:58 +00:00
Reid Kleckner 731bc9d2fe Use lld-link /nopdb to suppress PDB generation when DWARF is required
Fixes cfi/stats.cpp and asan/fuse-lld.cc on Windows.

llvm-svn: 298545
2017-03-22 19:49:29 +00:00
Nico Weber 082f922e9d Make nullability test pass on Windows, which evaluates parameters right-to-left.
llvm-svn: 298539
2017-03-22 19:15:24 +00:00
Francis Ricci dc13921fbc Factor lsan allocator cache accesses into a function
Summary:
This patch is the first step towards allows us to move away from using
__thread for the allocator cache on darwin,
which is requiring for building lsan for darwin on ios version 7
and on iossim i386.

This will be followed by patches to move the function into OS-specific files.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 298537
2017-03-22 18:42:43 +00:00
Bob Haarman 1012fe8a54 [compiler-rt] build compiler-rt runtimes without LTO
Summary: Currently, we build the compiler-rt runtimes with link-time optimization if LTO is configured for the LLVM project. This will break external programs that don't invoke the linker in such a way that it supports LLVM's LTO. To avoid this, this change causes the compiler-rt runtimes to be compiled with -fno-lto. This also makes the check-profile tests work on systems when doing a lld LTO build on a system where the system linker does not support LLVM LTO.

Reviewers: rnk, davidxl

Reviewed By: davidxl

Subscribers: dberris, mgorny, llvm-commits, mehdi_amini

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

llvm-svn: 298525
2017-03-22 17:25:49 +00:00
Dmitry Vyukov 28264edea3 tsan: fix a typo
s/covert_morder/convert_morder/

llvm-svn: 298492
2017-03-22 09:31:17 +00:00
Dean Michael Berris 6ba6673dfd [XRay][compiler-rt] Remove dependency on <system_error>
Summary:
Depending on C++11 <system_error> introduces a link-time requirement to
C++11 symbols. Removing it allows us to depend on header-only C++11 and
up libraries.

Partially fixes http://llvm.org/PR32274 -- we know there's more invasive work
to be done, but we're doing it incrementally.

Reviewers: dblaikie, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 298480
2017-03-22 04:40:32 +00:00
Reid Kleckner 81ee1a59ef XFAIL CFI stats test while LLD produces corrupt PDBs that confuse DIA
llvm-svn: 298476
2017-03-22 01:45:08 +00:00
Reid Kleckner 2b19203e19 Revert "[compiler-rt][asan] Turn on ASAN unittests for win64."
This reverts commit r296878.

These test still require too much swap to pass reliably.

llvm-svn: 298450
2017-03-21 22:07:06 +00:00
Bob Haarman ccd6ae25f4 [compiler-rt] respect CMAKE_EXE_LINKER_FLAGS in compiler and library tests
Summary: check_cxx_compiler_flag and check_library_exists could fail because they ignored CMAKE_EXE_LINKER_FLAGS and therefore would always fail to produce executables. Cmake policy CMP0056 fixes this, but was explicitly set to OLD in our CMakeLists because it caused problems with test_target_arch. This change sets the policy to NEW to fix the problem with the compiler and library tests, and temporarily clears CMAKE_EXE_LINKER_FLAGS inside test_target_arch to emulate the old behavior there. This allows, for example, LTO builds that require lld to succeed.

Reviewers: davidxl, beanz

Reviewed By: beanz

Subscribers: fjricci, dberris, mgorny, mehdi_amini, tejohnson, rnk, llvm-commits

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

llvm-svn: 298413
2017-03-21 18:25:35 +00:00
Dmitry Vyukov 3bf24449b0 tsan: fix pie_no_aslr test
It failed on clang-cmake-aarch64-39vma.
Restrict it to x86_64 only.

llvm-svn: 298383
2017-03-21 15:37:48 +00:00
Chandler Carruth 985f1a9417 Revert r298274: "Use pthreads for thread-local lsan allocator cache on darwin"
This fixes a failure currently present on the upstream linux boxes (and
reproduces for me as well):
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/1130/steps/64-bit%20check-asan-dynamic/logs/stdio

llvm-svn: 298382
2017-03-21 15:31:15 +00:00
Dmitry Vyukov de033e6cdb tsan: support __ATOMIC_HLE_ACQUIRE/RELEASE flags
HLE flags can be combined with memory order in atomic operations.
Currently tsan runtime crashes on e.g. IsStoreOrder(mo) in atomic store
if any of these additional flags are specified.

Filter these flags out.
See the comment as to why it is safe.

llvm-svn: 298378
2017-03-21 14:28:55 +00:00
Dmitry Vyukov ae9f13855b tsan: add test for pie/no aslr
Just ensure that such combination works.

llvm-svn: 298372
2017-03-21 13:44:01 +00:00
Vitaly Buka 40b0b46746 Revert "Bypass potential libc's sysconf wrappers for sysconf(_SC_PAGESIZE) call"
Bot can't find <sys/auxv.h>

This reverts commit r298305.

llvm-svn: 298343
2017-03-21 06:55:32 +00:00
Weiming Zhao 9b7bbeca48 [Builtin] Implement lit-test support (part 1 of 2: test cases update)
Original r297566 is splitted into two parts.
This is part one, which adds "RUN" command for test cases.
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.

TODO: A few tests are XFAILed for armhf and aarch64.
We need further investigating.  [1,2] Tracks the issue.

[1] https://bugs.llvm.org//show_bug.cgi?id=32260
[2] https://bugs.llvm.org//show_bug.cgi?id=32261

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: 298339
2017-03-21 05:32:51 +00:00
Alex Shlyapnikov a7291b3730 Bypass potential libc's sysconf wrappers for sysconf(_SC_PAGESIZE) call
Summary:
sysconf(_SC_PAGESIZE) is called very early, during sanitizer init and
any instrumented code (a wrapper/interceptor will likely be instrumented)
calling back to sanitizer before init is done will most surely crash.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 298305
2017-03-20 21:03:28 +00:00
Evgeniy Stepanov 3bf85d3124 Revert r298174, r298173, r298169, r298159.
Revert "Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF."
Revert "[asan] Remove gc-sections test with bfd."
Revert "[asan] Disable globals-gc test with ld.bfd."
Revert "[asan] Fix dead stripping of globals on Linux (compiler-rt)"

OOM in gold linker.

llvm-svn: 298287
2017-03-20 18:45:27 +00:00
Francis Ricci b91a5eabb3 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: 298274
2017-03-20 17:06:42 +00:00
Kuba Mracek 5971469566 Disable stack-use-after-return.cc on AArch64. The test was not testing the right thing before (the call to pthread_attr_setstacksize wasn't doing anything) anyway, and now it's running out of stack due to an unrelated change.
llvm-svn: 298267
2017-03-20 16:36:34 +00:00
Francis Ricci d7b08a6c73 Revert "Use pthreads for thread-local lsan allocator cache on darwin"
This is still failing stack-use-after-return on linux-aarch64.

This reverts commit 5b350130fc4bf6f70c078a5d97096df98a17a057.

llvm-svn: 298246
2017-03-20 13:45:29 +00:00
Francis Ricci 9971b76d20 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: 298214
2017-03-19 15:02:43 +00:00
Kuba Mracek 662c9b1e81 Re-commit of r296706 ("Increase stack size for stack-use-after-return test"). Hopefully the recent changes in the test will make it not flaky anymore.
Differential Revision: https://reviews.llvm.org/D30267

llvm-svn: 298200
2017-03-19 00:59:08 +00:00
Kuba Mracek 61f8bca7c5 Apparently, PTHREAD_STACK_MIN can be in limits.h on some systems...
llvm-svn: 298196
2017-03-18 22:01:33 +00:00
Kuba Mracek 0d9b01fb95 Change stack-use-after-return.cc to respect PTHREAD_STACK_MIN before calling pthread_attr_setstacksize. To investigate <https://reviews.llvm.org/D30267>. NFC.
llvm-svn: 298195
2017-03-18 21:35:12 +00:00
Kuba Mracek 07183b4a82 Add extra return value checks into stack-use-after-return.cc to help diagnose AArch64 test failures for <https://reviews.llvm.org/D30267>. NFC.
llvm-svn: 298193
2017-03-18 20:39:31 +00:00
Evgeniy Stepanov 0e6cb1925c Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.
Only depend on LLD if it is going to be built.

llvm-svn: 298174
2017-03-18 00:25:43 +00:00
Evgeniy Stepanov 7453bb7940 [asan] Remove gc-sections test with bfd.
It used to be XFAIL: *, but with the new implementation it passes in some cases
and fails in other. There are similar tests for gold and lld that are not
flaky, and a positive test for bfd that makes sure that were are not breaking
existing functionality.

llvm-svn: 298173
2017-03-18 00:25:40 +00:00
Evgeniy Stepanov 9424af1b30 [asan] Disable globals-gc test with ld.bfd.
Fails on clang-cmake-armv7-a15-full.

llvm-svn: 298169
2017-03-17 23:40:50 +00:00
Evgeniy Stepanov 79ee0c1813 [asan] Fix dead stripping of globals on Linux (compiler-rt)
Runtime support for the new instrumentation of globals based on !associated, and a bunch of tests.

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

llvm-svn: 298159
2017-03-17 22:17:38 +00:00
Vedant Kumar eb44542f69 [ubsan] Add e2e test for -fsanitize=nullability
llvm-svn: 298117
2017-03-17 20:27:33 +00:00
Rong Xu cf1f6fb1b2 Resubmit r295469 [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write
And also r295364 [PGO] remove unintended debug trace. NFC
I removed the test case: it's hard to write synchronized test b/w processes
in this framework. I will revisit the test-case later.

llvm-svn: 298113
2017-03-17 18:41:33 +00:00
Dean Michael Berris 4cb8e11884 [XRay][compiler-rt] Add missing include to <string>
Fixes a build break when using clang-3.9.1 (reported upstream,
post-commit review of D30850).

llvm-svn: 298039
2017-03-17 03:38:12 +00:00
Dean Michael Berris edb0b93bad [XRay][compiler-rt] Add missing include for <functional>
Fixes http://llvm.org/PR32313

llvm-svn: 298037
2017-03-17 02:36:17 +00:00
Juergen Ributzka eecb0ec2ea Revert "[PowerPC] Fix sanitizer frame unwind on 32-bit ABIs"
This broke GreenDragon:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/29210/

llvm-svn: 298029
2017-03-17 01:15:39 +00:00
Kuba Mracek 720883520d Fix macOS version detection to also allow missing 3rd part of the version number.
llvm-svn: 298008
2017-03-16 22:35:34 +00:00
Bill Seurer 6c0f69da68 [PowerPC] Fix sanitizer frame unwind on 32-bit ABIs
This fixes many sanitizer problems with -m32.  It is really intended
for gcc but patches to the sanitizers make their way through llvm
first.

ref:  https://gcc.gnu.org/ml/gcc-patches/2017-02/msg00855.html
llvm-svn: 297995
2017-03-16 21:14:13 +00:00
Vitaly Buka bccdba0c1d [compiler-rt] Add undefined "dup" symbol into internal symbolizer white-list.
llvm-svn: 297924
2017-03-16 01:17:31 +00:00
Evgeniy Stepanov d3332fc92f [msan] Intercept getloadavg.
llvm-svn: 297923
2017-03-16 01:06:22 +00:00
Kostya Serebryany ec3ceb1ce5 [asan] trying to fix the windows build
llvm-svn: 297918
2017-03-15 23:53:12 +00:00
Kostya Serebryany 82a41dd6c4 [asan] add one more argument to __sanitizer_print_memory_profile, remove a redundant weak definition.
llvm-svn: 297914
2017-03-15 23:27:14 +00:00
Rong Xu b85cc09329 [PGO] Value profile support for value ranges
This patch adds profile run time support to profile a range of values.
This interface will be used in profiling the size of memory intrinsic calls.

Differential Revision: http://reviews.llvm.org/D28964

llvm-svn: 297895
2017-03-15 21:46:31 +00:00
Dean Michael Berris 5d892ab02e Add NO_EXEC_STACK_DIRECTIVE to xray assembly files.
Summary: Add NO_EXEC_STACK_DIRECTIVE to xray assembly files

Reviewers: dberris, javed.absar

Reviewed By: dberris

Subscribers: llvm-commits

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

llvm-svn: 297894
2017-03-15 21:18:47 +00:00
Reid Kleckner 029dbd5e97 Fix -Wstring-conversion instance
llvm-svn: 297879
2017-03-15 19:50:02 +00:00
Eric Liu fd89ed8ed2 [msan] Relax lit check in wcsncpy.cc
Summary: The CHECK failed when the name is __interceptor_wcsncpy

Reviewers: bkramer, eugenis

Subscribers: llvm-commits

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

llvm-svn: 297828
2017-03-15 12:14:32 +00:00
Alex Lorenz d2677c8ed5 [compiler-rt][builtins] Ignore the deprecated warning for
CFPropertyListCreateFromXMLData that's used in __isOSVersionAtLeast

I forgot to add the pragmas in r297760.

llvm-svn: 297827
2017-03-15 12:13:20 +00:00
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