Commit Graph

7907 Commits

Author SHA1 Message Date
Weiming Zhao adf4258f50 builtins: Add ARM Thumb1 implementation for uidiv and uidivmod
Summary:
The current uidiv supports archs without clz. However, the asm is for thumb2/arm.
For uidivmod, the existing code calls the C version of uidivmodsi4, which then calls uidiv. The extra push/pop/bl makes it less efficient.

Reviewers: jmolloy, jroelofs, joerg, compnerd, rengolin

Subscribers: llvm-commits, aemerson

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

llvm-svn: 288710
2016-12-05 21:40:36 +00:00
Kuba Mracek c14916dae7 [compiler-rt] Remove duplicates from COMPILER_RT_SUPPORTED_ARCH
Since we’re adding an entry into COMPILER_RT_SUPPORTED_ARCH for all architectures of all Darwin platforms, COMPILER_RT_SUPPORTED_ARCH often ends up having duplicate items. Let’s remove them.

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

llvm-svn: 288681
2016-12-05 17:52:45 +00:00
Daniel Jasper 724df6e8b7 Remove a couple of memset usages from TSan, introduced in r288624.
TSan runtime shouldn't contain memset, so internal_memset is used
instead and syntax that emits memset is avoided.

This doesn't fail in-tree due to TSan being build with -03, but it fails
when TSan is built with -O0, and is (I think) a true positive.

Patch by Sam McCall, review: https://reviews.llvm.org/D27407

llvm-svn: 288672
2016-12-05 14:37:42 +00:00
Kuba Mracek 8f34233318 [sanitizer] Make atos stdin a non-tty pipe to make sure it's not stuck waiting for user input
On macOS, we often symbolicate using atos (when llvm-symbolizer is not found). The current way we invoke atos involves creating a pseudo-terminal to make sure atos doesn't buffer its output. This however also makes atos think that it's stdin is interactive and in some error situations it will ask the user to enter some input instead of just printing out an error message. For example, when Developer Mode isn't enabled on a machine, atos cannot examine processes, and it will ask the user to enter an administrator's password, which will make the sanitized process get stuck. This patch only connects the pseudo-terminal to the stdout of atos, and uses a regular pipe as its stdin.

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

llvm-svn: 288624
2016-12-04 21:52:21 +00:00
Kuba Mracek 3eb98a1318 [sanitizer] Track architecture and UUID of modules in LoadedModule
When we enumerate loaded modules, we only track the module name and base address, which then has several problems on macOS. Dylibs and executables often have several architecture slices and not storing which architecture/UUID is actually loaded creates problems with symbolication: A file path + offset isn't enough to correctly symbolicate, since the offset can be valid in multiple slices. This is especially common for Haswell+ X86_64 machines, where x86_64h slices are preferred, but if one is not available, a regular x86_64 is loaded instead. But the same issue exists for i386 vs. x86_64 as well.

This patch adds tracking of arch and UUID for each LoadedModule. At this point, this information isn't used in reports, but this is the first step. The goal is to correctly identify which slice is loaded in symbolication, and also to output this information in reports so that we can tell which exact slices were loaded in post-mortem analysis.

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

llvm-svn: 288537
2016-12-02 21:27:14 +00:00
Filipe Cabecinhas 8c1c8e5d7c Revert "Compiler-rt part of D26230: Add (constant) masked load/store support (Try #2)"
This reverts commit r288504.

clang-bpf-build fails with no details:
******************** TEST 'AddressSanitizer-x86_64-linux ::
TestCases/masked-ops.cpp' FAILED ********************
Script:
--
/mnt/buildbot/slave-root/clang-bpf-build/stage1/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -o /mnt/buildbot/slave-root/clang-bpf-build/stage1/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/masked-ops.cpp.tmp /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp -mavx -O1
not /mnt/buildbot/slave-root/clang-bpf-build/stage1/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/masked-ops.cpp.tmp l1 2>&1 | FileCheck -check-prefix=CHECK-L1 /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp
/mnt/buildbot/slave-root/clang-bpf-build/stage1/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/masked-ops.cpp.tmp l6 2>&1 | FileCheck -check-prefix=CHECK-L6 /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp
/mnt/buildbot/slave-root/clang-bpf-build/stage1/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/masked-ops.cpp.tmp la 2>&1 | FileCheck -check-prefix=CHECK-LA /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp
not /mnt/buildbot/slave-root/clang-bpf-build/stage1/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/masked-ops.cpp.tmp s1 2>&1 | FileCheck -check-prefix=CHECK-S1 /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp
/mnt/buildbot/slave-root/clang-bpf-build/stage1/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/masked-ops.cpp.tmp s6 2>&1 | FileCheck -check-prefix=CHECK-S6 /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp
/mnt/buildbot/slave-root/clang-bpf-build/stage1/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/masked-ops.cpp.tmp sa 2>&1 | FileCheck -check-prefix=CHECK-SA /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp
--
Exit Code: 2

Command Output (stderr):
--
FileCheck error: '-' is empty.
FileCheck command line:  FileCheck -check-prefix=CHECK-L6 /mnt/buildbot/slave-root/clang-bpf-build/llvm/projects/compiler-rt/test/asan/TestCases/masked-ops.cpp

--

********************

llvm-svn: 288507
2016-12-02 16:19:14 +00:00
Filipe Cabecinhas 2f461bf24a Compiler-rt part of D26230: Add (constant) masked load/store support (Try #2)
Summary:
Unfortunately, there is no way to emit an llvm masked load/store in
clang without optimizations, and AVX enabled. Unsure how we should go
about making sure this test only runs if it's possible to execute AVX
code.

Reviewers: kcc, RKSimon, pgousseau

Subscribers: kubabrecka, dberris, llvm-commits

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

llvm-svn: 288504
2016-12-02 15:33:04 +00:00
NAKAMURA Takumi 5ce101a848 compiler-rt/test/profile/Linux/lit.local.cfg: [Py3] Use text mode (universal_newlines=True).
llvm-svn: 288490
2016-12-02 08:17:17 +00:00
Maxim Ostapenko 6bdcb1f0e9 [sanitizer] Add a bunch of ifdefs for sparc targets to avoid build failures.
Differential Revision: https://reviews.llvm.org/D27301

llvm-svn: 288488
2016-12-02 08:07:35 +00:00
Stephan Bergmann 612d8c66f4 Don't include system header inside namespace
...causes build failure at least with GCC 6.2.1, as smmintrin.h indirectly
includes cstdlib, which then runs into problems.

llvm-svn: 288486
2016-12-02 08:03:57 +00:00
Saleem Abdulrasool aba0edb340 build: fix building for Windows after SVN r287465
The previous change for enabling MinGW did not preserve the Win32 check and
added the EABI specific routines to a Windows build which does not use the EABI
routines.  Correct the conditional check for that.

llvm-svn: 288422
2016-12-01 22:00:54 +00:00
Evgeniy Stepanov e109ef854a Release memory to OS only when the requested range covers the entire page
Summary:
The current code was sometimes attempting to release huge chunks of
memory due to undesired RoundUp/RoundDown interaction when the requested
range is fully contained within one memory page.

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

Patch by Aleksey Shlyapnikov.

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

llvm-svn: 288271
2016-11-30 20:41:59 +00:00
Kostya Kortchinsky 1148dc5274 [scudo] 32-bit and hardware agnostic support
Summary:
This update introduces i386 support for the Scudo Hardened Allocator, and
offers software alternatives for functions that used to require hardware
specific instruction sets. This should make porting to new architectures
easier.

Among the changes:
- The chunk header has been changed to accomodate the size limitations
  encountered on 32-bit architectures. We now fit everything in 64-bit. This
  was achieved by storing the amount of unused bytes in an allocation rather
  than the size itself, as one can be deduced from the other with the help
  of the GetActuallyAllocatedSize function. As it turns out, this header can
  be used for both 64 and 32 bit, and as such we dropped the requirement for
  the 128-bit compare and exchange instruction support (cmpxchg16b).
- Add 32-bit support for the checksum and the PRNG functions: if the SSE 4.2
  instruction set is supported, use the 32-bit CRC32 instruction, and in the
  XorShift128, use a 32-bit based state instead of 64-bit.
- Add software support for CRC32: if SSE 4.2 is not supported, fallback on a
  software implementation.
- Modify tests that were not 32-bit compliant, and expand them to cover more
  allocation and alignment sizes. The random shuffle test has been deactivated
  for linux-i386 & linux-i686 as the 32-bit sanitizer allocator doesn't
  currently randomize chunks.

Reviewers: alekseyshl, kcc

Subscribers: filcab, llvm-commits, tberghammer, danalbert, srhines, mgorny, modocache

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

llvm-svn: 288255
2016-11-30 17:32:20 +00:00
Maxim Ostapenko d136340166 [asan] Avoid redundant poisoning checks in __sanitizer_contiguous_container_find_bad_address.
__sanitizer_contiguous_container_find_bad_address computes three regions of a
container to check for poisoning: begin, middle, end. The issue is that in current
design the first region can be significantly larger than kMaxRangeToCheck.

Proposed patch fixes a typo to calculate the first region properly.

Patch by Ivan Baravy.

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

llvm-svn: 288234
2016-11-30 09:11:47 +00:00
Kuba Mracek 4edffbd28c [asan] Allow re-exec in instrumented unit tests on Darwin (fix unit tests on macOS <=10.10)
This fixes https://llvm.org/bugs/show_bug.cgi?id=30285. On macOS 10.10 and lower, instrumented unit tests still need to be able to re-exec to make interceptors work.

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

llvm-svn: 288224
2016-11-30 00:46:04 +00:00
Xinliang David Li 8b19a0a100 [Profile] Fix value profiler eviction bug
Differential Revision: https://reviews.llvm.org/D27224

llvm-svn: 288204
2016-11-29 22:00:54 +00:00
Kuba Mracek ff1bd20ded [sanitizer] Add macOS minimum deployment target to all compiler invocations in lit tests
The Clang driver on macOS decides the deployment target based on various things, like your host OS version, the SDK version and some environment variables, which makes lit tests pass or fail based on your environment. Let's make sure we run all lit tests with `-mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}` (10.9 unless overriden).

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

llvm-svn: 288186
2016-11-29 19:25:53 +00:00
Filipe Cabecinhas c707bbf081 Revert "Compiler-rt part of D26230: Add (constant) masked load/store support"
This reverts commit r288162. Buildbot clang-bpf-build fails running tests.

llvm-svn: 288173
2016-11-29 18:08:24 +00:00
Filipe Cabecinhas bca5fd4f81 Compiler-rt part of D26230: Add (constant) masked load/store support
Summary:
Unfortunately, there is no way to emit an llvm masked load/store in
clang without optimizations, and AVX enabled. Unsure how we should go
about making sure this test only runs if it's possible to execute AVX
code.

Reviewers: kcc, RKSimon, pgousseau

Subscribers: kubabrecka, dberris, llvm-commits

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

llvm-svn: 288162
2016-11-29 16:56:59 +00:00
Bob Haarman 9ee65aca3d [profile] use GetComputerNameExW instead of gethostname on Windows
Summary: In profile data paths, we replace "%h" with the hostname of the machine the program is running on. On Windows, we used gethostname() to obtain the hostname. This requires linking with ws2_32. With this change, we instead get the hostname from GetComputerNameExW(), which does not require ws2_32.

Reviewers: rnk, vsk, amccarth

Subscribers: zturner, ruiu, hans

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

llvm-svn: 288146
2016-11-29 15:24:00 +00:00
Marcin Koscielnicki 3089884bcf Revert "Revert "[ASan] Enable on SystemZ.""
This reverts commit r287767.

Hopefully, the tests should be fixed by D27118.

llvm-svn: 288116
2016-11-29 08:25:00 +00:00
Saleem Abdulrasool f9d34dfbe4 builtins: switch to c11 from c99
This fixes an incorrect standard usage of GNU99 when the compiler check was for
the ISO standard C99.  Furthermore, bump the dependency up to C11.  The
motivation for this change is ARM EHABI compatibility with clang 3.8.  We rely
on a type definition redefinition which causes an error with -Werror builds.
This is problematic for FreeBSD builds.  Switching to C11 allows the
compatibility without the unnecessary pedantic warning.  The alternative would
be to clutter the support header with a `pragma clang diagnostic ignore`.  GCC
4.8+ and the supported clang revisions along with MSVC support enough of C11 to
allow building the builtins in C11 mode.  No functional change intended.

llvm-svn: 288099
2016-11-29 02:31:40 +00:00
Evgeniy Stepanov d3305afc75 Return memory to OS right after free (not in the async thread).
Summary:
In order to avoid starting a separate thread to return unused memory to
the system (the thread interferes with process startup on Android,
Zygota waits for all threads to exit before fork, but this thread never
exits), try to return it right after free.

Reviewers: eugenis

Subscribers: cryptoad, filcab, danalbert, kubabrecka, llvm-commits

Patch by Aleksey Shlyapnikov.

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

llvm-svn: 288091
2016-11-29 00:22:50 +00:00
Kuba Mracek 87b3634615 [asan] Refactor shadow memory initialization out of AsanInitInternal [NFC]
Differential Revision: https://reviews.llvm.org/D27137

llvm-svn: 288072
2016-11-28 21:40:41 +00:00
Kuba Mracek 809dea2aeb [asan] Attempt to fix the debug_double_free.cc testcase on Windows after r288065.
llvm-svn: 288067
2016-11-28 21:28:41 +00:00
Kuba Mracek 48090f5b82 [asan] Provide bug descriptions for all reports (not just ErrorGeneric)
Differential Revision: https://reviews.llvm.org/D27012

llvm-svn: 288065
2016-11-28 21:18:15 +00:00
Marcin Koscielnicki b3d93889f5 [sanitizers] Get the proper printf/scanf version when long double transition is involved.
See D19555 for rationale.  As it turns out, this treatment is also necessary
for scanf/printf.

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

llvm-svn: 288064
2016-11-28 21:15:19 +00:00
Kuba Mracek 3a481cf0bd [tsan] Fix the lit expansion of %deflake not to eat a space
The lit expansion of "%deflake " (notice the space after) expands in a way that the space is removed, this fixes that.

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

llvm-svn: 287989
2016-11-26 19:09:32 +00:00
Kuba Mracek 23551fa811 [asan] Support handle_sigill on Darwin
Handling SIGILL on Darwin works fine, so let's just make this feature work and re-enable the ill.cc testcase.

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

llvm-svn: 287959
2016-11-26 01:30:31 +00:00
Kuba Mracek 073cea6128 [asan] Add a "dump_registers" flag to print out CPU registers after a SIGSEGV
This patch prints out all CPU registers after a SIGSEGV. These are available in the signal handler context. Only implemented for Darwin. Can be turned off with the dump_registers flag.

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

llvm-svn: 287957
2016-11-26 00:50:08 +00:00
Dean Michael Berris 291d74bdb4 Revert "[XRay][compiler-rt] XRay Buffer Queue"
Broke the build on arm7 and aarch64.

llvm-svn: 287911
2016-11-25 03:54:45 +00:00
Dean Michael Berris 47119579c8 [XRay][compiler-rt] XRay Buffer Queue
Summary:
This implements a simple buffer queue to manage a pre-allocated queue of
fixed-sized buffers to hold XRay records. We need this to support
Flight Data Recorder (FDR) mode. We also implement this as a sub-library
first to allow for development before actually using it in an
implementation.

Some important properties of the buffer queue:

- Thread-safe enqueueing/dequeueing of fixed-size buffers.
- Pre-allocation of buffers at construction.

Reviewers: majnemer, rSerge, echristo

Subscribers: mehdi_amini, mgorny, llvm-commits

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

llvm-svn: 287910
2016-11-25 03:14:10 +00:00
Kuba Mracek b59118f6ec [tsan] Add support for GCD dispatch_suspend and dispatch_resume
GCD queues can be suspended and resumed with dispatch_suspend and dispatch_resume. We need to add synchronization between the call to dispatch_resume and any subsequent executions of blocks in the queue that was resumed. We already have an Acquire(q) before the block executes, so this patch just adds the Release(q) in an interceptor of dispatch_resume.

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

llvm-svn: 287902
2016-11-24 21:24:54 +00:00
Vedant Kumar 3ac1d4dc10 [test] Use a helper macro to refer to MAP_ANON (NFC)
Some of our internal bots use old SDK's which don't define MAP_ANON.
Use a helper macro to pass the right flag into mmap().

llvm-svn: 287833
2016-11-23 22:23:42 +00:00
Reid Kleckner 3c3fe5d885 [asan/win] Skip incremental linker padding during unregistration
Should fix issues that came up while testing Win64 ASan.

llvm-svn: 287791
2016-11-23 18:28:04 +00:00
Reid Kleckner ff8f2b8f89 [asan/win] Check assumptions about the incremental linker more
Remove a needless cast as well.

llvm-svn: 287785
2016-11-23 18:02:16 +00:00
Reid Kleckner f174a0bbd2 [asan/win] Fix incremental linking vs. global registration
The MSVC incremental linker pads every global out to 256 bytes in case
it changes size after an incremental link. So, skip over null entries in
the DSO-wide asan globals array. This only works if the global padding
size is divisible by the size of the asan global object, so add some
defensive CHECKs.

llvm-svn: 287780
2016-11-23 17:37:00 +00:00
Marcin Koscielnicki 441dd21da9 Revert "[ASan] Enable on SystemZ."
This reverts commit r287764.

Two tests broke on the clang-s390x-linux buildbot:
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/1293.

llvm-svn: 287767
2016-11-23 16:07:07 +00:00
Marcin Koscielnicki 9a02c55edf [ASan] Enable on SystemZ.
Differential Revision: http://reviews.llvm.org/D21831

llvm-svn: 287764
2016-11-23 15:47:41 +00:00
Marcin Koscielnicki 5bdf70f410 [profile] Enable on SystemZ.
Differential Revision: http://reviews.llvm.org/D21738

llvm-svn: 287748
2016-11-23 08:28:42 +00:00
Dean Michael Berris 3076d43f9a [XRay][compiler-rt] Add newlines to error messages (NFC).
This goes through all the calls to `Report(...)` to make sure that each
one would have a newline at the end of the message for readability.

llvm-svn: 287736
2016-11-23 04:47:41 +00:00
Kuba Mracek e99e8d345c [sanitizer] Fix the dedup_token_length_test.cc testcase to not fail when user's home directory contains "bar"
Differential Revision: https://reviews.llvm.org/D24605

llvm-svn: 287696
2016-11-22 20:24:26 +00:00
Dmitry Vyukov 9c5bab23ee tsan: fix build after 287632
1. Mac does not have MAP_32BIT.
Define it to 0 if it is not defined.

2. We are lacking nolibc stub for ListOfModules::init.
Add it.

llvm-svn: 287634
2016-11-22 11:09:35 +00:00
Dmitry Vyukov 5c5d4766f8 tsan: switch libignore from /proc/self/maps to dl_iterate_phdr
/proc/self/maps can't be read atomically, this leads to episodic
crashes in libignore as it thinks that a module is loaded twice.
See the new test for an example.
dl_iterate_phdr does not have this problem.
Switch libignore to dl_iterate_phdr.

llvm-svn: 287632
2016-11-22 09:49:11 +00:00
Dmitry Vyukov 8b2ddfeb0b tsan: mark cur_thread_placeholder definition as initial-exec
See https://sourceware.org/bugzilla/show_bug.cgi?id=20805 and
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78294 for context.
Previously we marked only declaration as initial-exec. But compilers treat
initial-exec attribute somewhat differently. Mark definition as well.

llvm-svn: 287629
2016-11-22 08:59:17 +00:00
Kuba Mracek d692ea1e87 [asan] Specialize the initialization-bug.cc testcase for Darwin (it needs a deployment target of 10.11+)
The ODR detection in initialization-bug.cc now works on Darwin (due to the recently enabled "live globals" on-by-default), but only if the deployment target is 10.11 or higher. Let's adjust the testcases.

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

llvm-svn: 287581
2016-11-21 21:48:25 +00:00
Ivan Krasin 694c28495a Add a test for vcall on a null ptr.
Summary:
Turns out that in the case of -fsanitize=null and a virtual call,
the type check was generated *after* reading from vtable, which
causes a non-interpretable segfault. The check has been moved up
in https://reviews.llvm.org/D26559 and this CL adds a test for this case.

Reviewers: pcc

Subscribers: cfe-commits, kubabrecka

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

llvm-svn: 287578
2016-11-21 21:23:56 +00:00
Reid Kleckner 7a7477c71f [asan] Un-XFAIL Windows global dead stripping test cases
Test update for r287576

llvm-svn: 287577
2016-11-21 20:40:56 +00:00
Dean Michael Berris bad8f0feb4 [XRay] Support AArch64 in compiler-rt
This patch adds XRay support in compiler-rt for AArch64 targets.
This patch is one of a series:

LLVM: https://reviews.llvm.org/D26412
Clang: https://reviews.llvm.org/D26415

Author: rSerge

Reviewers: rengolin, dberris

Subscribers: aemerson, mgorny, llvm-commits, iid_iunknown

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

llvm-svn: 287517
2016-11-21 03:20:43 +00:00
Martin Storsjo 8c59680ac2 builtins: Allow building windows arm functions for mingw
When building with clang/LLVM in MSVC mode, the msvcrt libraries contain
these functions.

When building in a mingw environment, we need to provide them somehow,
e.g. via compiler-rt.

The aeabi divmod functions work in the same way as the corresponding
__rt_*div* functions for windows, but their parameters are swapped.
The functions for converting float to integer and vice versa are the
same as their aeabi equivalents, only with different function names.

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

llvm-svn: 287465
2016-11-19 21:22:38 +00:00