Commit Graph

2768 Commits

Author SHA1 Message Date
Slava Pestov
16d5716e71 SIL: Use the best resilience expansion when lowering types
This is a large patch; I couldn't split it up further while still
keeping things working. There are four things being changed at
once here:

- Places that call SILType::isAddressOnly()/isLoadable() now call
  the SILFunction overload and not the SILModule one.

- SILFunction's overloads of getTypeLowering() and getLoweredType()
  now pass the function's resilience expansion down, instead of
  hardcoding ResilienceExpansion::Minimal.

- Various other places with '// FIXME: Expansion' now use a better
  resilience expansion.

- A few tests were updated to reflect SILGen's improved code
  generation, and some new tests are added to cover more code paths
  that previously were uncovered and only manifested themselves as
  standard library build failures while I was working on this change.
2019-04-26 22:47:59 -04:00
Slava Pestov
472787bab7 SIL: isNonThrowing parameter of SILBuilder::create{Begin,}Apply() defaults to false
Also remove the overload of createApply() that does not take a SubstitutionMap.
It accomplishes nothing except creating ambiguity.
2019-04-25 22:27:38 -04:00
swift-ci
d24bc38797 Merge pull request #23701 from DougGregor/property-delegates-as-custom-attributes 2019-04-24 22:51:18 -07:00
Erik Eckstein
2e01b0edeb SIL: add assign_by_delegate instruction
Used for property delegates.
2019-04-23 11:32:28 -07:00
Ravi Kandhadai
d9a3f9c1b8 [const evaluator] Improving diagnostics generation for
unknown symbolic values by renaming some diagnostics and
creating new unknown reasons for each type of failure that
can happen during constant evaluation.
2019-04-18 13:17:17 -07:00
Ravi Kandhadai
55e82004a2 [const evaluator] Expose the step-wise constant evaluation mode
(also referred to as flow-sensitive mode) so that the evaluator
can be used by clients to constant evaluate instructions in a
SILFunction body one by one following the flow of control.
2019-04-17 18:12:17 -07:00
Slava Pestov
5062a81e3d AST: Start returning SelfProtocolConformances from ModuleDecl::lookupConformance()
Fixes <rdar://problem/49241923>, <https://bugs.swift.org/browse/SR-10015>.
2019-04-16 23:02:50 -04:00
swift-ci
4dc763aa4b Merge pull request #23964 from atrick/fix-prespecialize 2019-04-16 16:57:57 -07:00
Andrew Trick
60ee010e13 Force-link the prespecialized body. Remove extraneous linkage logic.
A prespecialized function may reference a non-public stdlib
symbols. Force link the function body when it is
specialized. Normally, the SILLinker does this, but it cannot see
through the prespecialize proxy function.

All symbols that must be prespecialized are now explicitly
requested. There's no accidental prespecialization, so there's no need
for special logic to adjust the specialized function linkage. Remove
all of that.
2019-04-15 20:51:35 -07:00
Michael Gottesman
1983368057 [cast-opt] Create an ownership version of bridged_cast_folding.sil and fix the cast optimizer so we can optimize it correctly. 2019-04-14 01:06:03 -07:00
Michael Gottesman
4304732553 Merge pull request #24020 from gottesmm/pr-435183b51ab766a85b8b66a35286dbc6f1d0e6fa
[cast-opt] Eliminate a leak along the cast failure path when bridging…
2019-04-14 00:28:02 -07:00
Michael Gottesman
de021aa32b [cast-opt] Eliminate a leak along the cast failure path when bridging from a swift to ns object derived class.
I added an interpreter test that exercises this code path using LifetimeTracked
to make sure we do not regress again.

rdar://49882071
2019-04-13 20:10:24 -07:00
ravikandhadai
10a7229bd6 Merge pull request #23877 from ravikandhadai/constexpr-refactoring
[const evaluator] Refactoring: exposing functions to look up symbolic values and to flow-sensitively evaluate possibly branching instructions.
2019-04-13 19:28:29 -07:00
Michael Gottesman
13a3dbbba0 [cast-opt] Simplify some code by hoisting some code/early exiting.
Importantly this lets us know further on in the function that as an invariant we
only can have checked_cast_addr_br.
2019-04-13 17:45:45 -07:00
Michael Gottesman
9caeaafd80 [cast-optimizer] Add some file level flags to section out the file into chunks. 2019-04-13 14:57:28 -07:00
Ravi Kandhadai
6d373750ef [const evaluator] Refactoring: exposing functions to look up the
symbolic value bound to a SIL value from the state, and to
flow-sensitively evaluate a single instruction regardless of
whether or not it is a branch.
2019-04-12 15:39:02 -07:00
Michael Gottesman
b6611eee35 [cast-opt] Combine two blocks with the same condition and invert that condition to eliminate a level of indentation.
NFCI.
2019-04-12 14:47:38 -07:00
Michael Gottesman
98c20d4946 [cast-opt] Slim down a large function by extracting out a part of it into a subroutine.
I also added documentation around what the code is actually trying to do/invariants/etc.

NFCI.
2019-04-12 12:23:28 -07:00
Michael Gottesman
d1389aded6 [cast-opt] Refactor some code onto SILDynamicCast and delete dead code.
NFC.
2019-04-12 12:23:28 -07:00
swift-ci
c6f7f97ba1 Merge pull request #23981 from gottesmm/pr-d8251fee09379fbd0cee5696f7b97a85ca886cb2 2019-04-12 12:17:36 -07:00
Michael Gottesman
f7b014b95c [cast-opt] Rename CastOptimizer member vars to match the rest of the CastOptimizer.
Done using Xcode's refactoring engine.
2019-04-12 11:09:29 -07:00
ravikandhadai
28efe03fab Merge pull request #23456 from ravikandhadai/constexpr-local-allocation
[const evaluator] Parameterize allocation of symbolic values in the constant interpreter.
2019-04-11 15:14:09 -07:00
Erik Eckstein
8f47439148 PerformanceInliner: disable shortest-path-analysis for huge functions.
As the complexity of the analysis is more than linear with the number of blocks, disable it for functions with > 2000 basic blocks.
In this case inlining will be less aggressive.

SR-10209
rdar://problem/49522869
2019-04-10 10:37:37 -07:00
Ravi Kandhadai
bb7363da2e [const evaluator] Parameterize allocation of symbolic values in the
constant interpreter. Based on this, change to a short-lived bump
allocator for storing symbolic values in the pass that checks #assert.
2019-04-09 13:56:21 -07:00
Michael Gottesman
8feb1a1000 [sil] Replace some nstances of SILBuilder(...) with SILBuilderWithScope(...).
The main thing to notice about these changes is that I always picked the debug
scope associated with the location we were using. They should always be in
sync.
2019-04-05 12:32:31 -07:00
Joe Shajrawi
de0287d96c [SILOptimizer] Constant Folding - Style modifications based on MichaelG’s review 2019-04-02 11:32:59 -07:00
swift-ci
f8e4c75453 Merge pull request #23720 from shajrawi/cttz 2019-04-01 19:19:56 -07:00
Joe Shajrawi
1d7f98f3e3 [SILOptimizer] Add ‘llvm.cttz.*’ Intrinsic support to Constant Folding
rdar://problem/29522851
2019-04-01 16:09:27 -07:00
Michael Gottesman
57b923b983 [cast-opt] Add a long comment explaining how bridging cast opt from ObjC->Swift modifies the CFG.
I also renamed some variables to match the comment.
2019-03-31 13:43:13 -07:00
Erik Eckstein
00599eeb3c Check for completeness of the SwiftOnoneSupport library
When compiling SwiftOnoneSupport, issue errors for missing functions which are expected in the module.
This ensures ABI compatibility.

rdar://problem/48924409
2019-03-25 14:57:03 -07:00
Erik Eckstein
17aa1c0c20 SILOptimizer: add a mechanism to pre-specialize internal stdlib symbols for OnoneSupport.
When compiling the OnoneSupport library, the compiler checks for @_semantics("prespecialize.X") attributes to pre-specialize function X.

rdar://problem/48924409
2019-03-25 14:57:03 -07:00
Erik Eckstein
39e681c965 OnoneSupport: hard-code the ABI of libswiftSwiftOnoneSupport into the compiler.
Add the list of symbols from the swift-5.0 release and only use that symbols to refer to pre-specializations in a Onone build.
This ensures that future Onone executables can link to an old swift 5.0 libswiftSwiftOnoneSupport library.

rdar://problem/48924409
2019-03-25 14:57:03 -07:00
Andrew Trick
a461faf16b Fix a PerformanceInliner crash caused by a null callee signature.
This is an obvious drive-by fix. It will crash when building
Foundation after I commit changes to the pipeline. My attempts at
creating a unit test were unsuccessful because it depends on some
interaction between inlining and specialization heuristics.
2019-03-21 15:13:12 -07:00
David Zarzycki
e9c655f34d [SILOpt] NFC: Silence unused variable warning 2019-03-19 13:34:16 -04:00
Slava Pestov
176d99c7b9 Completely disable using prespecializations from SwiftOnoneSupport 2019-03-15 17:59:20 -04:00
Slava Pestov
e9bd15f7fc SILOptimizer: More generic specializer plumbing for using the right resilience expansion
Also NFC for now.
2019-03-13 02:21:53 -04:00
Slava Pestov
5c72a3691c SILOptimizer: Add some FIXMEs and a cleanup 2019-03-13 02:12:29 -04:00
Slava Pestov
8915f96e3e SIL: Replace SILType::isTrivial(SILModule) with isTrivial(SILFunction) 2019-03-12 01:16:04 -04:00
Slava Pestov
00b4662ab9 SILOptimizer: Clean up the generic specializer a bit 2019-03-12 01:16:04 -04:00
Slava Pestov
c791c4a137 SIL: SILUndef must be aware of the resilience expansion
The ownership kind is Any for trivial types, or Owned otherwise, but
whether a type is trivial or not will soon depend on the resilience
expansion.

This means that a SILModule now uniques two SILUndefs per type instead
of one, and serialization uses two distinct sentinel IDs for this
purpose as well.

For now, the resilience expansion is not actually used here, so this
change is NFC, other than changing the module format.
2019-03-12 00:30:35 -04:00
swift-ci
666457bc27 Merge pull request #23122 from ravikandhadai/rdar48605307 2019-03-07 14:25:48 -08:00
Slava Pestov
ced5548deb SIL: Add resilience expansion parameter to TypeConverter::countNumberOfFields() 2019-03-06 02:26:26 -05:00
Slava Pestov
5847e163c1 SIL: Use better type lowering APIs in a couple of spots 2019-03-05 20:59:58 -05:00
Ravi Kandhadai
04770f6124 [SIL Diagnostics] Fix undefined behavior due to bit shifting in ConstantFolding.cpp
<rdar://48605307>
2019-03-05 16:09:01 -08:00
Michael Gottesman
c3fd9e35d3 Merge pull request #23101 from gottesmm/objc_to_swift_cast_cleanups
[cast-opt] Small cleanups to optimizeBridgedObjCToSwiftCast in preparation for fixing it for ownership.
2019-03-05 12:35:50 -08:00
Michael Gottesman
5da46389c5 [cast-opt] Extract into a helper the SILFunction, SubstitutionMap searching code from optimizeBridgedSwiftToObjCCast. 2019-03-05 10:39:47 -08:00
Michael Gottesman
b8a7102c90 [cast-opt] Refactor finding the ObjectiveCBridgeable protocol substitutions into a helper function. 2019-03-05 09:17:58 -08:00
Michael Gottesman
c57a0324f2 [cast-opt] Move some values closer to their definitions to ease code changes. 2019-03-05 09:17:58 -08:00
Michael Gottesman
25f21de8dd [cast-opt] Delete dead code. 2019-03-05 09:17:58 -08:00
Michael Gottesman
eb8c9d9bf0 [dynamic-cast] Hoist early bail out if the source objc type is address only.
This could probably be an error, but I am leaving it to preserve previous
behavior. The reason I am hoisting this is that I am hoisting it before we
potentially split a basic block. When we evaluate if we can early exit, we
should never do work before we know that we will emit /something/.
2019-03-05 09:17:58 -08:00