Commit Graph

64034 Commits

Author SHA1 Message Date
Andrew Trick
3a15cee084 -sil-print-all (et al.) should print specialized functions when they are created. 2018-02-08 11:27:46 -08:00
Jordan Rose
af67204b51 [Serialization] Handle XREFs to private types (#14352)
We can encounter these when the compiler modifies an inlinable
function to break apart a struct and the struct uses a private
type for one of its fields. It's questionable whether we /should/
handle this, but meanwhile this /is/ a non-intrusive fix that
preserves the performance of non-resilient libraries.

(That is, it appears this worked in Swift 4.0, though perhaps
not all of the same optimizations kicked in.)

https://bugs.swift.org/browse/SR-6874
2018-02-07 16:42:16 -08:00
swift-ci
573ebc5920 Merge pull request #14471 from eeckstein/compile-time-fixes 2018-02-07 16:40:18 -08:00
Erik Eckstein
9c7612f31c Cache the substituted types in the TypeSubstCloner.
This results some significant compile time wins in some cases.

rdar://problem/36887449
2018-02-07 15:02:51 -08:00
Erik Eckstein
45a480b2c6 Remove an assertion from the Projection constructor to avoid bad corner-case compile times.
The asserts call getType() which can be slow in some corner cases (it calls into the generic signature builder).
Speeds up the compilation (with an assert-compiler) of the DoubleWidth benchmark by 4x.

rdar://problem/36887449
2018-02-07 15:02:51 -08:00
swift-ci
d9067d91c5 Merge pull request #14469 from atrick/doublewidth-bench 2018-02-07 14:55:53 -08:00
Andrew Trick
0723aacb5b Disable DoubleWidthDivision.swift benchmark.
This takes more than 15 minutes to compile and makes the benchmark suite
unusable. There are multiple severe compile issues that need to be fixed
properly before we can support the DoubleWidth API.

See [SR-6947] DoubleWidth compile time.
2018-02-07 14:11:35 -08:00
swift-ci
09f6078494 Merge pull request #14467 from gottesmm/pr-82712572ff77861a0fd8e4acf9faa8680aab0a28 2018-02-07 13:17:53 -08:00
swift-ci
fe07705681 Merge pull request #14462 from gottesmm/pr-409f037bb47be562ad6e16d7e5fabf8080a92399 2018-02-07 12:41:42 -08:00
Michael Gottesman
2a6e1b32ac [dev-scripts] Add a tool called emacs-compile that runs $@ in an emacs compile session.
Something useful that I use all the time that I would like to give to others. It
enables emacs compile-mode to be used like a standalone-ish application instead
of one application with many modes, one of which is compile-mode.
2018-02-07 12:37:02 -08:00
Michael Gottesman
2108a3c5fe [silgen] When forwarding an rvalue into memory, make sure it is at plus 1.
Just another instance of these asserts finding bugs in the compiler. = ).

rdar://34222540
2018-02-07 12:12:55 -08:00
Michael Gottesman
68e2e708d0 [runtime] Add a dumping method to HeapObject when asserts are enabled.
Given any heap object, this method dumps:

* The pointer address of the heap object.
* The pointer address of the heap metadata of the object.
* The strong reference count.
* The unowned reference count.
* The weak reference count.
* Whether or not the value is in the deinit state.
* Whether or not the heap object uses swift_retain or objc_retain.
* The address of the object's side table if one exists.

This makes it really easy when debugging quickly to get all of the information
that you could possibly need from a HeapObject.
2018-02-07 11:54:48 -08:00
Pavel Yaskevich
b233f166dc Merge pull request #14441 from xedin/rdar-37160679
[CSSolver] Increment score when performing certain function conversions
2018-02-07 11:00:56 -08:00
Joe Groff
0a129fff24 Merge pull request #14450 from jckarter/open-existential-lvalue-evaluation-order
SILGen: Open existential lvalues on entry into an OpenExistentialExpr again.
swift-DEVELOPMENT-SNAPSHOT-2018-02-07-a
2018-02-07 09:45:51 -08:00
Jordan Rose
0c92fdda33 [SIL] Remove unused ResilienceExpansion from SILDeclRef (#14451)
We ended up not using this, so let's not leave it in as cruft.
No functionality change.
2018-02-07 09:41:25 -08:00
Arnold Schwaighofer
cf5b5dcb68 Merge pull request #14440 from aschwaighofer/convert_function_to_trivial
SIL: Add a convert_function_to_trivial instruction for converting escaping t…
2018-02-07 05:11:36 -08:00
Pavel Yaskevich
6cf1aa3083 Merge pull request #14399 from xedin/field-desc-for-imported-structs-2.0
[Reflection] Add support for imported structs with recorded fields (attempt #2)
2018-02-07 01:57:03 -08:00
swift-ci
fd88c72f21 Merge pull request #14456 from nkcsgexi/revert-sourcekit-client 2018-02-07 00:37:56 -08:00
Xi Ge
50cde06cf0 Revert "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" 2018-02-06 23:20:42 -08:00
Mark Lacey
6af9e64a0e Merge pull request #14449 from rudkx/fix-sr6837
Fix SR-6837 - allow function conversion for -swift-version 4 *only*
2018-02-06 22:41:01 -08:00
swift-ci
381080406a Merge pull request #14453 from gottesmm/pr-d1c58bc4a577158788cc80967f5d25326a0edd79 2018-02-06 21:59:10 -08:00
Xiaodi Wu
ef6cdd06a9 Merge pull request #14448 from xwu/itoa-reviewer-comments
[stdlib] Address reviewer comments for consolidated integer-to-string conversion
2018-02-06 23:52:14 -06:00
swift-ci
8b9e6ef1a6 Merge pull request #14452 from gottesmm/pr-f91f8046172eabfb9a8862b963dc81d7bc1f0591 2018-02-06 21:35:37 -08:00
Michael Gottesman
1aeb6d54f7 [gardening] Fix documentation thinko.
I was re-reading this documentation and noticed an obvious 'thinko'. This is NFC
since I am just updating the comment.
2018-02-06 21:21:04 -08:00
Michael Gottesman
988d4095dd [+0-all-args] When diagnosing closure escapes, look through sil borrows.
I also added an option called sil-assert-on-exclusivity-failure that causes the
optimizer to assert if an exclusivity failure is hit. This enables quicker
debugging of exclusivity violations since at the assertion point, you drop
straight down into the debugger. This is only enabled with asserts.

rdar://34222540
2018-02-06 20:44:54 -08:00
Joe Groff
742e7fc583 SILGen: Open existential lvalues on entry into an OpenExistentialExpr again.
4b25945 changed codegen for lvalue OpenExistentialExprs so that the existential was not opened until the OpaqueValue's lvalue was evaluated, but this is incorrect—we need to open the dynamic type of the existential immediately since it can be used arbitrarily within the subexpression. This caused a regression when evaluating default argument generators on protocol extension methods (rdar://problem/37031037), and would become a bigger problem when we generalize the ability to open existentials.
2018-02-06 19:44:53 -08:00
Joe Groff
f75dd6c704 Merge pull request #14391 from jckarter/too-complex-message
Reword the "expression too complex" error not to blame the user.
2018-02-06 19:43:03 -08:00
Xiaodi Wu
26dac8f5e0 Address reviewer comments for consolidated integer-to-string conversion 2018-02-06 21:40:49 -06:00
Mark Lacey
1de9897644 Fix SR-6837 - allow function conversion for -swift-version 4 *only*
We inadvertantly allowed a function conversion for Swift 4 that we did
not intend to allow.

This commit adds an extremely narrow fix to continue to allow this for
-swift-verson 4 only.

Fixes rdar://problem/36875195 / https://bugs.swift.org/browse/SR-6837
2018-02-06 19:40:25 -08:00
Xi Ge
871c9dac2a SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)
When using SwiftSyntax as a standalone tool, we invoke Swiftc
internally to get serialized syntax trees. This is not ideal for
several reasons: (1) we have to hard-code the relative path of swiftc
to invoke it; (2) we have to rely on standard input/output to pass the
tree across the process boundaries; and (3) we have to maintain two
different ways to get syntax tree (swiftc and sourcekitd).

This patch attempts to teach SwiftSyntax to use SourceKitd to get the
tree just like other clients. We first add a SourceKitd client library
written in Swift; and next teach SwiftSyntax to adopt this SourceKitd
client-side library. For platforms other than MacOS, we still use Swiftc
to get syntax trees. This client library also allows us to add 
SourceKitd tests in Swift.

This patch also re-enables several flaky tests.
2018-02-06 19:40:16 -08:00
Xiaodi Wu
22da6ddaf2 Merge pull request #14401 from xwu/itoa
[WIP] [stdlib] Consolidate integer-to-string implementations
2018-02-06 21:35:50 -06:00
swift-ci
50637d1080 Merge pull request #14439 from AndrewSB/one-tenth-the-build-time-🤦‍♂️ 2018-02-06 19:05:04 -08:00
Pavel Yaskevich
8316353e07 [CSSolver] Increment score when performing certain function conversions
Increase solution score when performing function conversions where only
one side has `@autoclosure`. That is going to help pick the best overload
when only difference lays in presence of such attribute.

e.g.

```swift
func foo(_: @autoclosure () -> Int) {}
func foo(_: () -> Int) {}
```

If the argument is itself `@autoclosure` it's preferable to use overload
with `@autoclosure` attribute, otherwise `() -> Int` should be used.

Resolves: rdar://problem/37160679
2018-02-06 18:55:10 -08:00
Arnold Schwaighofer
d51053b003 Add convert_escape_to_noescape instruction for converting escaping to noescape functions
@noescape function types will eventually be trivial. A
convert_escape_to_noescape instruction does not take ownership of its
operand. It is a projection to the trivial value carried by the closure
-- both context and implementation function viewed as a trivial value.

A safe SIL program must ensure that the object that the project value is based
on is live beyond the last use of the trivial value. This will be
achieve by means of making the lifetimes dependent.

For example:

  %e = partial_apply [callee_guaranteed] %f(%z) : $@convention(thin) (Builtin.Int64) -> ()
  %n = convert_escape_to_noescape %e : $@callee_guaranteed () -> () to $@noescape @callee_guaranteed () -> ()
  %n2 = mark_dependence %n : $@noescape @callee_guaranteed () -> () on %e : $@callee_guaranteed () -> ()
  %f2 = function_ref @use : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  apply %f2(%n2) : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  release_value %e : $@callee_guaranteed () -> ()

Note: This is not yet actually used.

Part of:
SR-5441
rdar://36116691
2018-02-06 18:01:23 -08:00
Xiaodi Wu
09f77ff58d Merge pull request #14361 from xwu/less-miscellany
[stdlib] Remove outdated miscellaneous functions
2018-02-06 19:49:56 -06:00
Michael Ilseman
b1f1e98a63 [string] Clean up StringObject; Clarify its tagged BridgeObjects. (#14425)
[string] Clean up StringObject; Clarify its tagged BridgeObjects.

Bifurcate StringObjects raw bit-pattern initializers to expose whether
the caller is passing a value rather than a reference. This way,
StringObject can call the approprite BridgeObject helper and
participate in upcoming peephole optimizations like retains of
known-values. This is all meant to be a NOP.

Additionally, do some cleanup while we're at it.
2018-02-06 17:36:32 -08:00
Pavel Yaskevich
8f05d64770 [Reflection] Add support for imported structs with recorded fields
Update IRGen to trigger generation of type metadata for foreign
struct types found in fields. And fix TypeRefBuilder to handle
the case where struct has fields but at the same time has opaque
metadata.
2018-02-06 15:50:52 -08:00
Pavel Yaskevich
478ba2693a [IRGen] Emit type field descriptors for imported structs 2018-02-06 15:50:52 -08:00
Greg Parker
3df5928122 Merge pull request #14417 from dcci/wallruntime
[Runtime] Enable -Wall for the builds.
2018-02-06 15:27:11 -08:00
swift-ci
348f347022 Merge pull request #14443 from AndrewSB/typos-after-review-🙁 2018-02-06 15:22:54 -08:00
vkalintiris
4146d11ac0 Fix the "tail" command to be compatible with coreutils. NFC. (#14408)
I had builds failing during testing because the tail command inside:

test/IDE/print_clang_bool_bridging.swift,
test/IDE/print_clang_swift_name.swift

did not use the -n option. This should make the invocation of the
default tail command compatible with the one provided by coreutils.
2018-02-06 14:38:20 -08:00
swift-ci
9f9b41748b Merge pull request #14437 from gottesmm/pr-b71f0e1f265a5e9eb05dc7d52f66b5b02dceca44 2018-02-06 12:08:59 -08:00
swift-ci
229be6b360 Merge pull request #14436 from vedantk/disable-unit-test swift-DEVELOPMENT-SNAPSHOT-2018-02-06-a 2018-02-06 11:16:54 -08:00
Andrew Breckenridge
063849d520 [docs][Windows] Build clang in Release mode instead of Debug
Should result in ~10x faster build times.
2018-02-06 11:16:04 -08:00
Andrew Breckenridge
5218326b27 [docs][Windows] Add forgotten ^ to LLVM_TARGETS_TO_BUILD 2018-02-06 11:07:16 -08:00
Michael Gottesman
40ef5b1a63 Add lldbToolBox.py scaffolding in ./utils for adding lldb python helpers to use when debugging swift.
Currently this file just imports lldbDataFormatters.py from llvm without the
user needing to know about it. I want to begin adding more utility (for
instance, graphing an assembly CFG without needing to copy/paste) to this file.

To use this in lldb run:

command script import $SWIFT_DIR/utils/lldbToolBox.py
2018-02-06 11:03:24 -08:00
Ben Langmuir
c03533314d Merge pull request #14366 from benlangmuir/sourcekit-driver
[sourcekit] Use the driver to parse command line arguments
2018-02-06 10:16:28 -08:00
Vedant Kumar
4d5684ba0b [build-script] Disable lldb unit tests in PR testing
There is some unresolved flakiness with the unit tests on Linux, which
we don't want interfering with PR testing. See:
https://github.com/apple/swift-lldb/pull/306
2018-02-06 10:07:54 -08:00
Arnold Schwaighofer
12da08d0cd Merge pull request #14428 from aschwaighofer/mangle_escapeness
Mangling: noescape functions will be trivial and no longer compatible…
2018-02-06 09:56:26 -08:00
Arnold Schwaighofer
d981bb1d96 Mangling: noescape functions will be trivial and no longer compatible with escape function types.
Mangle escapeness as part of the type.

Part of:
SR-5441
rdar://36116691
2018-02-06 08:51:43 -08:00