Commit Graph

1051 Commits

Author SHA1 Message Date
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
Michael Gottesman
e3acbd0b84 [cast-opt] Perform initial argument/cast replacement with an inline constructor in optimizeBridgedObjCToSwiftCast.
This makes it easier to read and understand the control flow by using early
returns.
2019-03-05 09:17:58 -08:00
Michael Gottesman
19a7978ff5 [cast-opt] Eliminate some unneeded type checks in favor of just asserting the instructions we handle.
This code today only handles the following two instructions:

1. checked_cast_addr_br
2. unconditional_checked_cast_addr

We were asserting that the source/dest of these values were addresses... but
they are obviously are!
2019-03-05 08:44:47 -08:00
Michael Gottesman
b87e203853 [cast-opt] Hoist the AnyHashable bail-out as early as possible.
We were doing unneeded work and then bailing. This is NFC.
2019-03-05 08:44:47 -08:00
Michael Gottesman
aefbc490d6 [cast-opt] Extract out the retrieval of the ObjC -> Swift bridging functions into a helper function.
NFC. Extracted using Xcode.
2019-03-04 23:12:01 -08:00
swift-ci
0d9b1963c7 Merge pull request #23086 from gottesmm/pr-706deb33fc2fb07b5b920a486f7696ceb08a8fc3 2019-03-04 22:05:42 -08:00
Michael Gottesman
276455979e [cast-opt] Eliminate always true if statement.
I think that this is a result of previous refactorings. This code has a long
time assert in it that Src (since 2016) is an address and for a long time the bridged type has
always been an object (since 2015). So, thus we know that the following is always true.

  SILBridgedTy != Src->getType()

I also removed a level of indentation. NFC.

The 2015 commit hash is: 2dd38eee0e (the original commit).
The 2016 commit hash is: 506ab9809f
2019-03-04 20:59:19 -08:00
Michael Gottesman
ee02174f71 [cast-opt] Change optimize{Swift,ObjC}to{ObjC,Swift} to use SILDynamicCastInst.
I also debrided dead variables that resulted from eliminating the trampoline
argument code in optimizeBridgedCasts().
2019-03-04 10:48:13 -08:00
Michael Gottesman
fa4c38bf0c [cast-opt] Now that all users of optimizeBridgedCasts use the SILDynamicCastInst entrypoint, delete the old entrypoint and inline its body into the new entrypoint. 2019-03-03 16:33:12 -08:00
Michael Gottesman
e833d11720 [cast-opt] Change simplifyCheckedCast{,Value}BranchInst to use SILDynamicCastInst.
This is the last change needed to simplify the API of optimizeBridgedCasts to
take SILDynamicCastInst.
2019-03-03 16:33:11 -08:00
Michael Gottesman
807b187302 [cast-opt] Update simplifyCheckedCastAddrBranchInst to use SILDynamicCastInst.
This is another step towards eliminating the many argument call to
optimizeBridgedCasts.
2019-03-03 16:33:11 -08:00
Michael Gottesman
aaf464485b [cast-opt] Change CheckedCastBranch metatype opts to use SILDynamicCastInst. 2019-03-03 14:50:21 -08:00
Michael Gottesman
e80c394e82 [cast-opt] Update optimization of unconditional checked cast to use SILDynamicCastInst. 2019-03-03 14:50:21 -08:00
Michael Gottesman
d4e910ce5c [cast-opt] Update optimizeUnconditionalCheckedCastAddrInst to use SILDynamicCastInst. 2019-03-03 13:42:04 -08:00
Slava Pestov
2813912c48 Merge pull request #23010 from pschuh/s-5
FloatLiteralExpr now is lowered directly into SIL.
2019-03-01 17:32:23 -05:00
Parker Schuh
5160da6a2e FloatLiteralExpr now is lowered directly into SIL.
For context, String, Nil, Bool, and Int already behave this way.

Note: Swift can compile against 80 or 64 bit floats as the builtin
literal type. Thus, it was necessary to capture this bit somehow in the
FloatLiteralExpr. This was done as another Type field capturing this
info.
2019-03-01 09:01:30 -08:00
Slava Pestov
1944254253 SIL: Use SILFunction type lowering APIs in various places 2019-03-01 02:07:16 -05:00