Commit Graph

6297 Commits

Author SHA1 Message Date
Adhemerval Zanella f2d3dbfaca [compiler-rt] [dfsan] Unify aarch64 mapping
This patch reorganize the platform specific mapping information to
export the application mask on a external variable. This exported
variable will be used by intrumentation phase to create code to be
used on architecture with multiple VMA range.
    
The patch creates a new header, dfsan_platform.h, and move all the
mapping information and also create function accessors to the
mapping value.

Also for aarch64 it initialize application exported mask to the 
value based on runtime VMA detection.

llvm-svn: 254197
2015-11-27 12:43:33 +00:00
Adhemerval Zanella 066c5f0f92 [compiler-rt] [tsan] Unify aarch64 mapping
This patch unify the 39 and 42-bit support for AArch64 by using an external
memory read to check the runtime detected VMA and select the better mapping
and transformation.  Although slower, this leads to same instrumented binary
to be independent of the kernel.

Along with this change this patch also fix some 42-bit failures with
ALSR disable by increasing the upper high app memory threshold and also
the 42-bit madvise value for non large page set.

llvm-svn: 254151
2015-11-26 13:10:47 +00:00
Xinliang David Li 463e5ab205 Sync up with master InstrProfData.inc
llvm-svn: 254113
2015-11-26 00:03:34 +00:00
Ivan Krasin 00de6bc9b7 sanitizer_common: remove noisy warning about symbolizer not found.
Summary:
In r251553, I added a warning that proved to be super noisy,
especially in case of MSan. Removing it for now, and I will
probably add some additional diagnostics for symbolizer, when
I better understand how to make it properly.

Reviewers: eugenis

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

llvm-svn: 254102
2015-11-25 22:00:20 +00:00
Chris Bieneman f1f46b5766 [CMake] [Darwin] libclang_rt.eprintf should be built with the same CFLAGS as the other darwin builtin libraries.
llvm-svn: 254082
2015-11-25 19:32:32 +00:00
Kuba Brecka 4aa4a73f17 [sanitizer] Fix a crash with DlAddrSymbolizer and unnamed symbols
Apparently, dladdr() can succeed but return a NULL pointer, in which case strdup will crash.  Let's not call strdup on NULL pointers.

llvm-svn: 254068
2015-11-25 13:11:38 +00:00
Kuba Brecka ad986d5141 [asan] Fix the atos-symbolizer-dyld-root-path.cc test case
Due to a typo, atos-symbolizer-dyld-root-path.cc is currently being skipped all the time. There's a few more typos/copy-paste-errors. Let's fix them and enable this test.

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

llvm-svn: 254058
2015-11-25 07:59:00 +00:00
Adhemerval Zanella 29ffb68259 [compiler-rt] [msan] Couple of fixes for msan with libc++
This patch adds some fixes for MSAN with libc++ for aarch64:

1. Adds the libmsan_loadable name for aarch64.
2. Fixes some pthread_attr_setstacksize for aarch64, since glibc sets
   the mininum stack size to be higher than the x86_64 default (16KB
   vs 128KB).
3. Fixes a swprintf null char constant definition.

llvm-svn: 254015
2015-11-24 20:28:48 +00:00
Kuba Brecka 8443d187e6 [tsan] Fix signal number definitions for OS X
On OS X, SIGBUS is 10 and SIGSYS is 12.

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

llvm-svn: 253983
2015-11-24 13:44:54 +00:00
Kuba Brecka 440d08600b [tsan] Implement basic GCD interceptors for OS X
We need to intercept libdispatch APIs (dispatch_sync, dispatch_async, etc.) to add synchronization between the code that submits the task and the code that gets executed (possibly on a different thread). This patch adds release+acquire semantics for dispatch_sync, and dispatch_async (plus their "_f" and barrier variants). The synchronization is done on malloc'd contexts (separate for each submitted block/callback). Added tests to show usage of dispatch_sync and dispatch_async, for cases where we expect no warnings and for cases where TSan finds races.

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

llvm-svn: 253982
2015-11-24 13:36:06 +00:00
Kuba Brecka 6cb7f7a923 [tsan] Fix stack_sync_reuse.cc test on OS X
The test relies on two variables in different frames to end up being on the same address. For some reason, this isn't true on OS X. This patch adds `__attribute__((aligned(64)))` to the variables, which actually makes the variables occupy the same address. This is still not a guarantee, but it's more likely to work (the test looks very fragile already).

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

llvm-svn: 253981
2015-11-24 13:29:15 +00:00
Kuba Brecka 941d0a756a [tsan] Replace pthread semaphore in signal_cond.cc with barrier_wait
Pthread semaphores are not available on OS X. Let's replace sem_wait/sem_post with barrier_wait, which makes the test pass on OS X. I know that sem_wait/sem_post is intercepted by TSan, whereas barrier_wait is TSan-invisible, but the purpose of the test is not affected by this.

Also, let's properly initialize the mutex and cond variables.

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

llvm-svn: 253980
2015-11-24 13:28:27 +00:00
Kuba Brecka 377cafbbbc [tsan] Fix CallocOverflow unit test on OS X
On OS X, interceptors don't work in unit tests, so calloc() calls the system allocator. We need to use user_calloc() instead.

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

llvm-svn: 253979
2015-11-24 13:27:33 +00:00
Xinliang David Li bd1e84bc84 sync up InstrProfData.inc with master
llvm-svn: 253943
2015-11-24 00:37:45 +00:00
Xinliang David Li 39f4c2ca3b [PGO] sync up target instrument decl between runtime and llvm (NFC)
llvm-svn: 253911
2015-11-23 20:07:09 +00:00
Xinliang David Li d200b27f08 [PGO] Unify section name, section symbol definitions (Darwin)
Replace hard-coded references to names to key section and section
 symbols with common macro definitions.

llvm-svn: 253907
2015-11-23 19:48:25 +00:00
Xinliang David Li 7c7f120178 [PGO] Unify section name, section symbol definitions (Linux)
Replace hard-coded references to names to key section and section
 symbols with common macro definitions.

llvm-svn: 253897
2015-11-23 18:56:03 +00:00
Xinliang David Li 6376db52fe [PGO] Unify raw profile header definition
Replace duplicate definition raw header with
 common definition in InstrProfData.inc.

llvm-svn: 253896
2015-11-23 18:36:40 +00:00
Xinliang David Li 66c32f0183 [PGO] Use the alignment macro newly introduced (NFC)
llvm-svn: 253895
2015-11-23 18:09:18 +00:00
Xinliang David Li ac604eeff1 Sync up template file with master (NFC)
llvm-svn: 253894
2015-11-23 18:03:25 +00:00
Xinliang David Li a1bebf2987 [PGO] Unify per-function control data definition
Replace duplicate definition per-func profile control data
 with common definition in InstrProfData.inc.

llvm-svn: 253891
2015-11-23 17:50:53 +00:00
Xinliang David Li 5c7fa27b00 [PGO] Use common definition of value profile kind
Replace duplicate definition value profile kind definitions
 with common definition in InstrProfData.inc.

llvm-svn: 253890
2015-11-23 17:43:10 +00:00
Xinliang David Li e95d7fac58 [PGO] Use common definition of raw magic and version
- Replace duplicate definition and use of magic in profile runtime
- Replace hard coded version reference in profile runtime

llvm-svn: 253885
2015-11-23 17:26:53 +00:00
Xinliang David Li 0ca5bd4a46 [PGO] Start use InstrProf template file in compiler-rt/lib/profile
- Replace use of __llvm_profile_value_data with common data structure.
- Remve duplicate InstrProfValueNode

llvm-svn: 253883
2015-11-23 17:09:40 +00:00
Xinliang David Li 19c1922c04 Sync up InstrProfData.inc with master
llvm-svn: 253881
2015-11-23 17:06:44 +00:00
Kuba Brecka 2f8d345adc [tsan] Modify the tls_race.cc and tls_race2.cc tests to pass on OS X
On OS X, __thread variables are lazily heap-allocated (with malloc). Therefore, they're recognized as heap blocks (which is what they are) and not as TLS variables in TSan reports. Figuring out if a heap block is a TLS or not is difficult (in malloc interceptor we could analyze the caller and then mark the object), so let's instead modify the tests so that we expect the report to say "Location is heap block" instead of "Location is TLS".

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

llvm-svn: 253858
2015-11-23 08:17:17 +00:00
Xinliang David Li e90daa1dac [PGO] Make InstrProfData.inc available to compiler-rt.
This will enable a series of cleanup/refactoring.

llvm-svn: 253852
2015-11-23 05:47:05 +00:00
Xinliang David Li ab94e71dc6 Fix a bug introduced in cleanup
llvm-svn: 253847
2015-11-23 05:16:28 +00:00
Xinliang David Li 6fe18f4fba [PGO] Compiler-rt cleanup -- introduces macros for various macros
This makes code more readable and be made more portable in the future.
There is no functional change.

llvm-svn: 253845
2015-11-23 04:38:17 +00:00
Joerg Sonnenberger 47174a5a2c Add a generic version of __divtc3.c for long double complex division.
Mark the unit test as applying to all platforms.

llvm-svn: 253831
2015-11-22 19:13:49 +00:00
Joerg Sonnenberger 6719bd7d2a Use cabsl for long double, not cabs.
llvm-svn: 253829
2015-11-22 18:53:43 +00:00
Joerg Sonnenberger 132069c167 Move prototypes for the double-double helpers into the common header.
llvm-svn: 253828
2015-11-22 18:49:56 +00:00
Joerg Sonnenberger 0a22a96dc6 Don't use implementation namespace for include guard. Fix spacing.
llvm-svn: 253827
2015-11-22 18:48:32 +00:00
Kuba Brecka 6bbb8519e2 [tsan] Fix __cxa_guard_* interceptors on OS X
This patch fixes the __cxa_guard_acquire, __cxa_guard_release and __cxa_guard_abort interceptors on OS X. They apparently work on Linux just by having the same name, but on OS X, we actually need to use TSAN_INTERCEPTOR.

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

llvm-svn: 253776
2015-11-21 12:53:34 +00:00
Kuba Brecka 5cbe122439 [tsan] Fix detached threads in unit tests on OS X
We need to call the intercepted version of pthread_detach. Secondly, PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED are not 0 and 1 on OS X, so we need to properly pass these constants and not just a bool.

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

llvm-svn: 253775
2015-11-21 12:41:36 +00:00
Kuba Brecka 4e6adaac4c [tsan] Make tsan_test_util_posix.cc call pthread interceptors on OS X
The tsan_test_util_posix.cc implementation of mutexes call pthread APIs directly, which on OS X don't end up calling the intercepted versions and we miss the synchronization. This patch changes the unit tests to directly call the intercepted versions. This fixes several test failures on OS X.

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

llvm-svn: 253774
2015-11-21 12:38:54 +00:00
Xinliang David Li f7185dcccd Fix -Wpointer-sign warning
llvm-svn: 253770
2015-11-21 07:26:46 +00:00
Xinliang David Li 2d5bf07c1d [PGO] Implement a more robust/readable Writer callback interface
(patch suggested by silvas)

With this patch, the IO information is wrapped in struct
ProfDataIOVec, and interface of writerCallback takes a vector
of IOVec and a pointer to writer context pointer.

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

llvm-svn: 253764
2015-11-21 04:16:42 +00:00
Matthias Braun b6a9fee9da Mention new InstrProfilingWriter file in clang_{darwin|linux}.mk
I hope this fixes our internal buildbots (rdar://23614130)

llvm-svn: 253735
2015-11-20 23:09:49 +00:00
Anna Zaks f30f351faf [asan] Disable the test on i386 Darwin.
This test checks if we can print a backtrace from the death callback. On old
OS X versions, backtrace is not able to symbolicate the trace past the ASan
runtime because we build with -fomit-frame-pointer.

llvm-svn: 253729
2015-11-20 22:55:22 +00:00
Peter Collingbourne d198896240 Re-enable CFI tests on Windows.
Clang driver was fixed in r253707.

llvm-svn: 253712
2015-11-20 21:16:00 +00:00
Chris Bieneman 01ec64499c [CMake] Add iOS simulator to the supported OS list for the profile library.
We already support this in autoconf and it ships in Apple Clang.

llvm-svn: 253709
2015-11-20 20:56:02 +00:00
Xinliang David Li bc6d21d990 [PGO] Fix buildbot failure on FreeBSD (when building __x86_64__ lib)
There seems to be a problem in system header (stdint.h) of FreeBSD
where uint8_t nor uint16_t are defined.  Explicitly define the key
types as done for FreeBSD i386. 

llvm-svn: 253703
2015-11-20 20:28:38 +00:00
Anna Zaks a44def276c [compiler-rt] Do not pull in min and max macros from windows.h
This should fix Windows buildbot breakage triggered by r253690.

llvm-svn: 253701
2015-11-20 20:18:06 +00:00
Xinliang David Li 78c4a44d36 [PGO] Profile runtime name cleanups
Value profile enumerator change to match LLVM code
ProfData new member field name change to match LLVM code
ProfData member type change to match LLVM code
Do not use lower case for types that are internal to implementation (not exposed to APIs)
There is no functional change. This is a preparation patch to enable more code sharing
in follow up patches

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

llvm-svn: 253700
2015-11-20 19:41:02 +00:00
Chris Bieneman 8085475db2 [compiler-rt][cmake] Fix not lipo libclang_rt.cc_kext.a when building on OS X
Summary:

Fix r252525 - cmake configure failed to connect target builtins to target compiler-rt  because of early return call.

Patch by: Jacky Tsao (cao.zhong1)

Reviewers: beanz

Subscribers: llvm-commits

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

llvm-svn: 253692
2015-11-20 18:45:42 +00:00
Anna Zaks e310f11223 [asan] On OS X, write error reports into Crash Report.
The Crash Report is going to add app specific info if it is stored in the magical buffer.

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

llvm-svn: 253691
2015-11-20 18:42:07 +00:00
Anna Zaks c54cf07fd7 [compiler-rt] Add internal implementations for strlcat and strlcpy
The compiler-rt should make use of strlcpy() rather than strncpy(). Using internal_strncpy() may be fine with appropriate bounds checking or enforcement of nul-termination elsewhere, but it's just good practice these days to avoid using strncpy() in new code.

A patch by Jeremy Sequoia!

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

llvm-svn: 253690
2015-11-20 18:42:05 +00:00
Anna Zaks 8d225205e3 [asan] Fix the deadlocks introduced by "On OS X, log reports to syslog and os_trace" commit
[asan] On OS X, log reports to syslog and os_trace, has been reverted in r252076 due to deadlocks on earlier versions of OS X. Alexey has also noticed deadlocks in some corner cases on Linux. This patch, if applied on top of the logging patch (http://reviews.llvm.org/D13452), addresses the known deadlock issues.

(This also proactively removes the color escape sequences from the error report buffer since we have to copy the buffer anyway.)

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

llvm-svn: 253689
2015-11-20 18:42:01 +00:00
Anna Zaks 2ce9f9447c Reapply: [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
of the report to stderr. This patch changes this behavior and writes the full
text of the report to syslog before we terminate the process. It also calls
os_trace (Activity Tracing available on OS X and iOS) with a message saying
that the report is available in syslog. This is useful, because this message
will be shown in the crash log.

For this to work, the patch makes sure we store the full report into
error_message_buffer unconditionally, and it also strips out ANSI escape
sequences from the report (they are used when producing colored reports).

I've initially tried to log to syslog during printing, which is done on Android
right now. The advantage is that if we crash during error reporting or the
produced error does not go through ScopedInErrorReport, we would still get a
(partial) message in the syslog. However, that solution is very problematic on
OS X. One issue is that the logging routine uses GCD, which may spawn a new
thread on its behalf. In many cases, the reporting logic locks threadRegistry,
which leads to deadlocks.

Reviewed at http://reviews.llvm.org/D13452

(In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid
build failures on Linux.)

llvm-svn: 253688
2015-11-20 18:41:44 +00:00