Commit Graph

629 Commits

Author SHA1 Message Date
Dan Liew
63e72909b5 [Sanitizers] Add Driver/Frontend option to enable sanitizer instrumentation that supports error recovery.
The new option `-sanitize-recover=` takes a list of sanitizers that
recovery instrumentation should be enabled for. Currently we only
support it for Address Sanitizer.

If the option is not specified then the generated instrumentation does
not allow error recovery.

This option mirrors the `-fsanitize-recover=` option of Clang.

We don't enable recoverable instrumentation by default because it may
lead to code size blow up (control flow has to be resumable).

The motivation behind this change is that today, setting
`ASAN_OPTIONS=halt_on_error=0` at runtime doesn't always work. If you
compile without the `-sanitize-recover=address` option (equivalent to
the current behavior of the swift compiler) then the generated
instrumentation doesn't allow for error recovery. What this means is
that if you set `ASAN_OPTIONS=halt_on_error=0` at runtime and if an ASan
issue is caught via instrumentation then the process will always halt
regardless of how `halt_on_error` is set. However, if ASan catches an
issue via one of its interceptors (e.g. memcpy) then `the halt_on_error`
runtime option is respected.

With `-sanitize-recover=address` the generated instrumentation allows
for error recovery which means that the `halt_on_error` runtime option
is also respected when the ASan issue is caught by instrumentation.

ASan's default for `halt_on_error` is true which means this issue only
effects people who choose to not use the default behavior.

rdar://problem/56346688
2019-11-12 11:33:58 -08:00
Nathan Lanza
e170f43d6f [IRGen] Change a pass to agree with a merged pair of passes upstream
SanitizerCoveragePass was meerged with ModuleSanitizerCoverage upstream
and thus this usage needs to agree.
2019-09-05 11:31:53 -07:00
Arnold Schwaighofer
20efacf2d6 Merge remote-tracking branch 'upstream/master' into master-next 2019-08-26 13:30:41 -07:00
swift-ci
ff7d2c2503 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-26 13:04:27 -07:00
Arnold Schwaighofer
af0247e92c Disable this check for now some bots are failing
rdar://54708850
2019-08-26 12:45:28 -07:00
Arnold Schwaighofer
2b41f8d8d5 Merge remote-tracking branch 'origin/master' into master-next 2019-08-26 08:57:42 -07:00
swift-ci
86e95c23aa Merge remote-tracking branch 'origin/master' into master-rebranch 2019-08-23 17:43:50 -07:00
Brent Royal-Gordon
f61dd7bc1a [NFC] Hash LLVM options more robustly
Replaces getLLVMCodeGenOptionsHash(), which combined a bunch of individual bits into a string, with writeLLVMCodeGenOptionsTo(), which writes each one separately into a raw_ostream.

This is intended to be make the hashing more future-proof. The current design needs to know exactly how many bits each of the values needs; if any of the values grew and you forgot to update this function, its bits would interfere with those of an earlier value in the hash. This new design is expected to be slightly slower, but more robust to future change in the compiler.
2019-08-23 15:17:11 -07:00
Brent Royal-Gordon
413e718811 Assert correctness of performLLVM() incremental builds
In assert builds, when performLLVM() would normally skip invoking LLVM because it believes it would generate the same code, it now generates code into a temporary file and compares it to the output. This should catch mistakes where Swift configures LLVM in ways which affect the output, but which the incremental logic doesn’t account for.
2019-08-22 19:38:08 -07:00
Brent Royal-Gordon
5cd505ae1a [NFC] Extract helper from performLLVM()
We do a particular dance to diagnose errors twice, and we’re about to do it three times.
2019-08-22 16:02:02 -07:00
Alex Langford
04c5ceb18c Adjust for svn r368826
LLVM svn r368826 changed the SectionRef::getName() interface to return an
Expected<StringRef> instead of filling out one that is passed to it.
Adjust accordingly.
2019-08-15 10:56:06 -07:00
Vedant Kumar
65c5ca4fc2 [SanitizerCoverage] Adopt new API to construct a pass instance for the legacy PM
<rdar://problem/53676581> [master-next] error: use of undeclared identifier 'createSanitizerCoverageModulePass'
2019-07-29 13:39:35 -07:00
Saleem Abdulrasool
d4af68c234 Revert "Updating usage of SanitizerCoverage."
This reverts commit 913977bfb1.
SVN r366153 reverts the necessary LLVM changes.
2019-07-16 15:18:10 -07:00
Puyan Lotfi
913977bfb1 Updating usage of SanitizerCoverage. 2019-07-12 11:53:56 -07:00
Gwen Mittertreiner
67cfef2d60 SectionRef::getContents() now returns Expected
Updated uses of object::SectionRef::getContents() since it now returns
an Expected<StringRef> instead of modifying the one it's passed.

See also: git-svn-id:
https://llvm.org/svn/llvm-project/llvm/trunk@360892
91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-20 16:02:41 -07:00
swift-ci
f01b166f3d Merge remote-tracking branch 'origin/master' into master-next 2019-03-13 20:49:17 -07:00
Arnold Schwaighofer
c2aab0018f Merge pull request #23214 from aschwaighofer/remove_heap_allocation_of_std_thread
IRGen: Remove heap allocation of std::thread
2019-03-13 20:34:16 -07:00
Saleem Abdulrasool
b97857e99f IRGen: adjust for SVN r355989
SVN r355989 adds support for the XCOFF file format.  For now, treat it as a COFF
target, though XCOFF and COFF are different.
2019-03-13 13:31:24 -07:00
swift-ci
e106bdaa17 Merge remote-tracking branch 'origin/master' into master-next 2019-03-12 09:09:02 -07:00
Arnold Schwaighofer
4682caa292 IRGen: Move coroutine passes to be scheduled before tsan
The coroutine transformation passes can't seem to handle tsan'ified
code.

My attempt at reducing a test case failed.

rdar://48719789
2019-03-11 14:30:01 -07:00
Arnold Schwaighofer
76bf9f4ffa IRGen: Remove heap allocation of std::thread 2019-03-11 12:42:22 -07:00
swift-ci
cf177cc3eb Merge remote-tracking branch 'origin/master' into master-next 2019-03-06 07:49:31 -08:00
Arnold Schwaighofer
38063aa96a Increase the stack size limit for running llvm codegen threads to 8MB
Without this compilation may fail in llvm because we run out of stack space. The
limit for the main thread is 8MB on mac osx but 512KB for other threads.

rdar://47787344
2019-03-05 09:50:16 -08:00
Saleem Abdulrasool
e800003c7a IRGen: adjust for SVN r353985
Adjust for ASAN being ported to the new pass manager.
2019-02-19 09:30:53 -08:00
swift-ci
6c6c3f6cbc Merge remote-tracking branch 'origin/master' into master-next 2019-01-16 11:30:02 -08:00
Davide Italiano
3ae1a05584 [IRGen] Catch up with API changes in the sanitizer passes. 2019-01-16 10:41:51 -08:00
Slava Pestov
77e5b44560 IRGen: Ensure that default witness thunks are emitted in the same thread as the protocol descriptor
Protocol descriptors for resilient protocols relatively-reference
default witness thunks, so when using -num-threads N with N > 1,
we must ensure the default witness thunk is emitted in the same
LLVM module.
2019-01-15 21:42:24 -05:00
Slava Pestov
152fab22a1 Revert "IRGen: Ensure that default witness thunks are emitted in the same thread as the protocol descriptor" 2019-01-15 01:05:06 -05:00
Slava Pestov
50465688f8 IRGen: Ensure that default witness thunks are emitted in the same thread as the protocol descriptor
Protocol descriptors for resilient protocols relatively-reference
default witness thunks, so when using -num-threads N with N > 1,
we must ensure the default witness thunk is emitted in the same
LLVM module.
2019-01-14 16:26:07 -05:00
Daniel Dunbar
8980213f7c Merge pull request #20687 from ddunbar/swasm-allow-wasm-object-format
[Swift+WASM] Allow Wasm object format.
2019-01-04 08:34:43 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Daniel Dunbar
1efee0c27a [Swift+WASM] Allow Wasm object format.
- This currently does nothing more than adopt the ELF conventions, but for the
   Wasm object file format.
2018-11-20 15:22:26 -07:00
Han Sang-jin
577ffabc0b [IRGen] Modifications for Cygwin
- Cygwin 64 bit uses the LP64 model and differs from the LLP64 model used on Windows 64 bit.
  On Cygwin 64 bit, CLong is imported as Int. Therefore, no manual mapping is required.
- On Cygwin 64 bit, dlls are loaded above the max address for 32 bits.
  This means that the default CodeModel causes generated code to segfault when run.
2018-11-10 05:34:54 +09:00
Arnold Schwaighofer
152e8db8bb IRGen and runtime implementation for dynamic replacements 2018-11-06 09:58:36 -08:00
Jordan Rose
de07fdfb04 Remove "StartElem" from perform{SIL,IR}Generation
This was only used by the integrated REPL, and is now a dead option.

The "StartElem" option for performTypeChecking is still used for
reading SIL files, which have AST and SIL blocks alternate.
2018-09-25 09:13:52 -07:00
Jordan Rose
71760bcc4e Replace StringMap with DenseMap when the keys don't need to be owned
StringMap always copies its strings into its own storage. A DenseMap
of StringRefs has the same caveats as any other use of StringRef, but
in the cases I've changed the string has very clear ownership that
outlives the map.

No functionality change, but should reduce memory usage and malloc
traffic a little.
2018-09-13 15:15:27 -07:00
Vedant Kumar
c76494b02e Use atomic profile counter updates when TSan is enabled
This suppresses TSan diagnostics about racy profile counter updates.

rdar://40477803
2018-08-16 16:23:25 -07:00
swift-ci
0d5cb630cc Merge remote-tracking branch 'origin/master' into master-next 2018-07-28 10:09:14 -07:00
Erik Eckstein
aafb780d83 IRGen: add an option -align-module-to-page-size for benchmarking
The option aligns all modules to the page size. This help giving more consistent results when doing performance testing with the swift benchmark suite.
It solves the problem that benchmarks which compile down to identical code give different runtime data because of different alignment of the code within a page.
2018-07-27 17:15:14 -07:00
Bob Wilson
ffa88c3d28 Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 14:38:55 -07:00
Bob Wilson
8e330ee344 NFC: Fix indentation around the newly renamed LLVM_DEBUG macro.
Jordan used a sed command to rename DEBUG to LLVM_DEBUG. That caused some
lines to wrap and messed up indentiation for multi-line arguments.
2018-07-21 00:56:18 -07:00
Jordan Rose
cefb0b62ba Replace old DEBUG macro with new LLVM_DEBUG
...using a sed command provided by Vedant:

$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
2018-07-20 14:37:26 -07:00
swift-ci
fdbcfbca65 Merge remote-tracking branch 'origin/master' into master-next 2018-05-30 10:29:01 -07:00
Saleem Abdulrasool
477d43ef1c Merge pull request #16142 from compnerd/irgen-dllstorage
IRGen: the runtime is compacted into the stdlib
2018-05-30 10:27:29 -07:00
Saleem Abdulrasool
7324046d02 IRGen: add swift module metadata into the LLVM module
Introduce new named metadata in the LLVM module (swift.module.flags)
that is used to identify if the module is the standard library.  This
will be used to correct the DLL Storage for runtime functions.
2018-05-29 15:39:32 -07:00
swift-ci
376c6e3f88 Merge remote-tracking branch 'origin/master' into master-next 2018-05-25 14:09:11 -07:00
Arnold Schwaighofer
81a15fbe19 IRGen: Use clangs's LLVM datalayout
It knows better ...

rdar://40275689
2018-05-25 11:19:01 -07:00
Vedant Kumar
105a61e50d Use LLVM_DEBUG() instead of DEBUG()
Upstream has renamed the DEBUG() macro to LLVM_DEBUG. This updates swift
accordingly:

$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
2018-05-24 13:10:45 -07:00
Saleem Abdulrasool
ec4ec6b1f9 IRGen: adjust for LLVM API change
SVN r332881 introduced an additional parameter to emit a DWO file.
2018-05-23 08:48:42 -07:00
swift-ci
6f2b0080fc Merge remote-tracking branch 'origin/master' into master-next 2018-05-15 17:49:17 -07:00