Commit Graph

3719 Commits

Author SHA1 Message Date
Graydon Hoare
cc16ddfd13 Revert "[SILOptimizer] Don't diagnose infinite recursion if a branch terminates (#19724)"
This reverts commit e94450e840.

rdar://45080912
2018-10-07 23:54:33 -07:00
Harlan
e94450e840 [SILOptimizer] Don't diagnose infinite recursion if a branch terminates (#19724)
This patch augments the infinite recursion checker to not warn if a
branch terminates, but still warns if a branch calls into something with
`@_semantics("arc.programtermination_point")`. This way, calling `fatalError`
doesn't disqualify you for the diagnostic, but calling `exit` does.

This also removes the warning workaround in the standard library, and
annotates the internal _assertionFailure functions as
`programtermination_point`s, so they get this treatment too.
2018-10-05 19:15:26 -07:00
Erik Eckstein
506a14b9f0 COWArrayOpts: make the optimization work again for two-dimensional arrays.
With removing of pinning and with addressors, the pattern matching did not work anymore.
The good thing is that the SIL is now much simpler and we can handle the 2D case without pattern matching at all.
This removes a lot of code from COWArrayOpts.

rdar://problem/43863081
2018-10-05 08:26:14 -07:00
Jordan Rose
c3b1143b15 Merge pull request #19607 from Kaiede/debianHost
Enable i686 as a Host Platform
2018-10-02 16:24:58 -07:00
Michael Gottesman
18f118abfc Merge pull request #19445 from gottesmm/ownership-kind-set-classifer
[ownership] Extract out from SILOwnershipVerifier the OperandOwnershi…
2018-10-02 08:03:15 -07:00
Michael Gottesman
157091d5c6 [ownership] Extract out from SILOwnershipVerifier the OperandOwnershipKindMapClassifier
NOTE: This is not the final form of how operand ownership restraints will be
represented. This patch is instead an incremental change that extracts out this
functionality from the ownership verifier as a pure refactor.

rdar://44667493
2018-10-01 22:14:41 -07:00
Michael Gottesman
2e63b4c830 [semantic-arc-opts] Change Semantic ARC Opts to run only on the stdlib so it only sees ownership verified SIL.
The reason why I am doing this is now that once we have the
OperandOwnershipKindMap I can write this optimization in a more robust,
aggressive manner. My hope is that I can eliminate all copy_value of guaranteed
parameters all of whose uses could accept a guaranteed parameter. This is given
to me by the OperandOwnershipKindMap.

Additionally, I found that the way the analysis was using the OwnershipVerifier
was not sound on non-ownership verified SIL. Rather than fix it, I just turned
it off for that case.

rdar://44667493
2018-10-01 22:14:41 -07:00
Adam Thayer
073905b573 [32-bit Linux] Handle size_t/uint64_t assumptions
There’s a few places where size_t is used for a field/parameter when constructing an array for types. Unfortunately, the Bitfields that were backing the inputs to these at some point after 4.1 grew past 32 bits and are now backed by a uint64_t. Even though the slice of the bitfield is small enough for 32-bit, clang sees these slices as 64-bit and complains if there isn’t a cast involved.
2018-09-28 10:14:44 -07:00
Slava Pestov
ce770cdf4e AST: Introduce GenericSignature::forEachParam()
This replaces the inefficient pattern:

  for (auto param : sig->getGenericParams()) {
    if (sig->isCanonicalTypeInContext(param)) {
      ...
    } else {
      ...
    }
  }
2018-09-27 21:28:36 -07:00
Slava Pestov
07217b403a Merge pull request #19580 from slavapestov/fewer-gsb-part-1
Preliminary cleanups for creating fewer GenericSignatureBuilders
2018-09-27 14:53:33 -07:00
Slava Pestov
21bcf3fdef SIL: Remove GenericEnvironment from SILConstantInfo
Most of the time we don't need it, and accessing a generic environment
on a deserialized declaration creates a GenericSignatureBuilder.
2018-09-27 09:08:43 -07:00
Slava Pestov
ebe769a58c SIL: Stop imploding parameter list into a single value with opaque abstraction pattern
The constraint solver support for the Swift 3 function type behavior
has been removed, so it's no longer possible to pun the same value as
both a function taking multiple parameters and a function taking a
single tuple argument.

This means the entire parameter list is no longer a target for
substitution as a single value, so the most general form of a function
value passes each parameter indirectly instead of passing a single
tuple parameter indirectly.
2018-09-26 23:20:54 -07:00
Michael Gottesman
b100306f7f Merge pull request #19569 from gottesmm/pr-5c220285592e7beca2f16605797f3f1e5c1a1ef1
[sil] Create SILArgumentKind for allowing for one to exhaustively swi…
2018-09-26 16:46:43 -07:00
Michael Gottesman
f196fc09e0 [sil] Create SILArgumentKind for allowing for one to exhaustively switch over all arguments.
This ensures that we can use exhaustive switches over arguments and thus get
missing case warnings when we add new argument types.

rdar://44807744
2018-09-26 14:27:33 -07:00
Slava Pestov
de697dcae1 Merge pull request #19384 from slavapestov/remove-function-input-abstraction-pattern
SILGen: Port reabstraction thunks to the new function type representation
2018-09-26 11:04:47 -07:00
Jordan Rose
bf5133d986 Merge pull request #19485 from jrose-apple/disintegrated
Rework the integrated REPL to use separate modules for every line
2018-09-26 09:04:50 -07:00
Slava Pestov
e7b911e3fe SIL: Remove no longer used AbstractionPattern kinds 2018-09-25 23:13:07 -07:00
Slava Pestov
e8bb14c106 SIL: Remove AbstractionPattern::getFunctionInputType() 2018-09-25 23:13:07 -07:00
Slava Pestov
c99c0c52fb SIL: Remove AbstractionPattern::getWithoutSpecifierType() 2018-09-25 23:13:07 -07:00
Slava Pestov
c8a4939f16 SIL: Factor out shouldExpandParams() from DestructureInputs
I'm going to need this when emitting reabstraction thunks using
the new function pointer representation.
2018-09-25 23:13:07 -07:00
Michael Gottesman
d57a88af0d [gardening] Rename references to SILPHIArgument => SILPhiArgument. 2018-09-25 22:23:34 -07:00
Michael Gottesman
3cd1b7bedc [sil] Extract out ApplySite/FullApplySite into their own header.
I believe that these were in SILInstruction for historic reasons. This is a
separate API on top of SILInstruction so it makes sense to pull it out into its
own header.
2018-09-25 13:32:59 -07:00
Jordan Rose
a9bbaf751f Assume a SILModule is whole-module when SILGen-ing from a ModuleDecl
No functionality change. Unfortunately we still need the flag in
SILModule itself because of the ability to create an empty SILModule
and parse SIL into it incrementally, which can happen before there's
a FileUnit to use as the associated DeclContext instead of a
CompilerInstance's main module.
2018-09-25 09:13:52 -07: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
Slava Pestov
55814b530d SIL: Remove AbstractionPattern::getTupleElements() 2018-09-24 22:59:07 -07:00
Slava Pestov
c70f9396c2 SIL: Add AbstractionPattern::getNumFunctionParams() 2018-09-24 22:59:07 -07:00
Jason Mittertreiner
8ac9a657a8 Fix 'operator ==' is ambiguous with MSVC (#19501)
When compiling with MSVC on Windows, this error among other similar
conflicts with AnyValue occur:

Defined the overloads so it selects the correct one.
2018-09-24 12:39:44 -07:00
Michael Gottesman
57b8247ba6 Merge pull request #19455 from gottesmm/pr-d827497ab8ae7a9987fd554c3687f92f8554ae91
[sil] Add convenience method TermInst::getSuccessorBlockArguments().
2018-09-21 14:56:54 -07:00
Michael Gottesman
2d6106aaa7 [sil] Add convenience method TermInst::getSuccessorBlockArguments().
This convenience API enables one to iterate over the array of arguments of each
successor of the terminator.

To implement this I needed to implement SILBasicBlock::getPHIArguments(), so I
also implemented SILBasicBlock::getFunctionArguments().

rdar://44667493
2018-09-21 10:01:35 -07:00
Michael Gottesman
af7d301512 [sil] Make ValueOwnershipKind(unsigned) explicit to prevent implicit casts from ints/bools to ValueOwnershipKind.
I hit this problem while splitting classifying operand ownership from the
ownership verifier itself. There is no reason to allow for this implicit
conversion. Just makes updating code more error prone.

rdar://44667493
2018-09-21 09:58:02 -07:00
Michael Gottesman
e919de9797 [closure-spec] Do not try to process begin_apply. It is not supported now.
We were crashing when we saw this.

rdar://44612356
2018-09-20 20:42:28 -07:00
Michael Gottesman
e3eb9aecb4 [sil] Introduce FullApplySiteKind and ApplySiteKind to allow for exhaustive switching over FullApplySites and ApplySiteKind.
Currently there is a bug in the closure specializer that was caused by
BeginApply not being handled correctly. Rather than just fixing that and leaving
the badness, I am instead in this commit introducing enums for apply sites so we
can avoid this problem in the future by using exhaustive switches to guide
developers adding new types of apply sites in the future.

rdar://44612356
2018-09-20 19:19:02 -07:00
Doug Gregor
4ed973329a [SIL] Unify default witness table entries with witness table entries.
SILWitnessTable::Entry already contains a superset of what was supported
by SILDefaultWitnessTable::Entry, the latter of which only had “no entry”
and “method” states. Make SILDefaultWitnessTable::Entry an alias for
SILWitnessTable::Entry, and unify all of the parsing/printing/
(de)serialization logic.
2018-09-15 22:04:46 -07:00
Doug Gregor
78f3017436 Merge pull request #19266 from DougGregor/associated-type-resilience
Associated type resilience
2018-09-15 21:03:13 -07:00
Doug Gregor
cab6bfa6af [ABI] Emit associated type witnesses resiliently.
Emit associated type witnesses into resilient conformance tables, so they
can be re-ordered within the protocol without breaking clients. This will
(eventually) permit adding new, defaulted associated types to protocols
resiliently.
2018-09-14 20:59:03 -07:00
Slava Pestov
a64521e77e SIL: Remove AbstractionPattern::transformType() 2018-09-14 13:37:43 -07:00
Slava Pestov
a323fd8f31 SIL: Remove AbstractionPattern::dropLastTupleElement() 2018-09-14 13:37:43 -07:00
Saleem Abdulrasool
4baa775726 Merge pull request #19297 from compnerd/unreachable
litter the tree with `llvm_unreachable`
2018-09-14 09:04:56 -07:00
Saleem Abdulrasool
d281b98220 litter the tree with llvm_unreachable
This silences the instances of the warning from Visual Studio about not all
codepaths returning a value.  This makes the output more readable and less
likely to lose useful warnings.  NFC.
2018-09-13 15:26:14 -07:00
Jordan Rose
2d1c305e04 Merge pull request #19290 from jrose-apple/serial-eyes
[Serialization] Handful of cleanups and possibly memory usage improvements
2018-09-13 15:22:47 -07:00
Joe Groff
8665342877 Merge pull request #19151 from jckarter/allocating-convenience-initializers
Dispatch initializers by their allocating entry point
2018-09-13 15:17:34 -07:00
Joe Groff
77a0923ca6 SILGen: Emit convenience initializers as allocating entry points.
And only dispatch designated inits by their allocating entry points. rdar://problem/29634243
2018-09-13 12:31:23 -07:00
Jordan Rose
5fe5391dae [Serialization] Remove the last use of Identifiers for SIL names
The string-keyed tables don't actually need Identifier keys on the
serialization side -- no reason to persist these in the ASTContext's
string table either.
2018-09-13 09:01:08 -07:00
swift-ci
cc329fee03 Merge pull request #19141 from aschwaighofer/remove_constant_string_literal 2018-09-10 15:51:47 -07:00
Joe Groff
351808920a SIL: Don't include convenience initializers in vtables.
They should never be dynamically dispatched (unless `required`), so this entry should never be used.
We were accidentally dynamically dispatching to them in convenience-to-convenience `self.init`
delegations; fix that.
2018-09-10 15:15:38 -07:00
Doug Gregor
2246e2bf60 [SILGen] Cope with protocol requirement overrides for keypaths.
When emitting accessor calls for keypaths, make sure that we reference
protocol requirements that introduce witness table entries. Other
protocol requirements don't have the necessary dispatch thunks,
resulting in linker errors.

Fixes rdar://problem/44187969.
2018-09-09 20:13:54 -07:00
Jordan Rose
737a405596 Add ModuleDecl::isOnoneSupportModule, and use it
A few places around the compiler were checking for this module by its
name. The implementation still checks by name, but at least that only
has to occur in one place.

(Unfortunately I can't eliminate the string constant altogether,
because the implicit import for SwiftOnoneSupport happens by name.)

No functionality change.
2018-09-06 16:05:16 -07:00
swift-ci
5e2b705f6d Merge pull request #19131 from gottesmm/pr-67d16ab8862dce3cff561b2a4dbee16514133383 2018-09-06 15:02:39 -07:00
Michael Gottesman
0290cd4323 [sil] Eliminate end_borrow_argument now that end_borrow has a single operand.
I changed all of the places that used end_borrow_argument to use end_borrow.

NOTE: I discovered in the process of this patch that we are not verifying
guaranteed block arguments completely. I disabled the tests here that show this
bad behavior and am going to re-enable them with more tests in a separate PR.
This has not been a problem since SILGen does not emit any such arguments as
guaranteed today. But once I do the SILGenPattern work this will change.

rdar://33440767
2018-09-06 14:04:57 -07:00
Doug Gregor
cffe3869a6 Merge pull request #19034 from DougGregor/protocol-override
Introduce overrides of protocol members and drop them from witness tables
2018-09-05 20:57:21 -07:00