Commit Graph

119 Commits

Author SHA1 Message Date
Roman Levenstein
55ea9ec0e3 [sil-combine] Minor clean-up of casts optimizations. NFC.
Add more checks and logic into emitSuccessfulIndirectUnconditionalCast and emitSuccessfulScalarUnconditionalCast, so that its clients in sil-combine can be simplified by avoiding looking into special cases.

Swift SVN r26885
2015-04-02 19:57:35 +00:00
Jordan Rose
f74bc7122c Split getAccessibility() into getFormalAccess() and getEffectiveAccess().
Currently a no-op, but effective access for entities within the current
module will soon need to take testability into account. This declaration:

  internal func foo() {}

has a formal access of 'internal', but an effective access of 'public' if
we're in a testable mode.

Part of rdar://problem/17732115 (testability)

Swift SVN r26472
2015-03-24 02:16:58 +00:00
Arnold Schwaighofer
d6ec9f2640 Make isObjectiveCBridgeable an available function so it can be used elsewhere.
Swift SVN r26265
2015-03-18 17:43:09 +00:00
Roman Levenstein
eddfc3c57a Improve casts analysis for bridged types.
Check if the outcome of a cast from an ObjC type to a Swift type or from a Swift type to an ObjC type can be statically determined.
This allows for folding of many such casts.

Swift SVN r26125
2015-03-14 02:23:07 +00:00
Roman Levenstein
340f20968d Improve the logic for analyzing casts between metatypes.
Do not fall through from the metatypes analysis code if the analysis could not decide whether the cast would succeed or fail. Make a more explicit decision instead based on the instance type of a metatype.

This fixes some logical errors in analysis of casts between bridged types. They were caused by falling through from the metatypes analysis.

Swift SVN r26120
2015-03-14 02:23:03 +00:00
Roman Levenstein
ad566f229d Add a missing case into assert.
SILFunctionType and FunctionType are different types.

Swift SVN r26119
2015-03-14 02:23:02 +00:00
Roman Levenstein
a081647f83 Add a FIXME about upcasts between existential metatypes.
Swift SVN r26118
2015-03-14 02:23:01 +00:00
Roman Levenstein
6047ec5547 Handle types conforming to _BridgedToObjectiveC protocol in a special way during cast folding.
This fixes the broken build of validation suite.

Swift SVN r25710
2015-03-03 06:03:54 +00:00
Roman Levenstein
a4055afc15 Third part of the cast folding and type-casts re-factoring. Addressing JoeG's comments.
This patch does the following:
- Improvements and correctness fixes for conversions of existential metatypes. They may succeed if you have a concrete or existential metatype that conforms to the protocol. Based on Joe's review of my previous patch.
- Removes special-cases for AnyObject. AnyObject is handled as any other class existential.
- Improves folding of conversions from class existential metatypes to concrete non-class metatypes
- Improves comments.
- Adds more tests to cover new test-cases.
- Adjusts a few existing tests.

Swift SVN r25690
2015-03-02 22:28:21 +00:00
Roman Levenstein
62cc75f4f1 Fix a small bug in getAnyMetatypeDepth.
getAnyMetatypeDepth was looping over the chain of metatypes, but it was not actually counting the depth.

Swift SVN r25689
2015-03-02 22:28:19 +00:00
Roman Levenstein
c199905a2f Second part of the cast folding and type-casts re-factoring.
This patch does the following:
- Moves the logic for handling special-case of converting to/from AnyObject.Protocol (and existential.Protocol in general) into DynamicCasts, where all other cases are handled already.
- Moves the peephole which was folding checked_cast_br into an unchecked cast and branch from sil-combine into sil-simplify-cfg, because it is a better place for it, since this peephole affects the CFG. The corresponding test is also moved from sil_combine.sil into simplify_cfg.sil.
- Adds a few checked_cast_br peepholes to sil-combine.   They try to simplify checked_cond_br instructions using existential metatypes by propagating a concrete type whenever it can be determined statically.
- Adds a new test with a lot of test-cases that make sure we are really folding many type-checks at compile-time now.

Swift SVN r25504
2015-02-24 17:31:08 +00:00
Roman Levenstein
c97f748fb9 Move the logic for folding type casts using statically known protocol conformances into DynamicCasts.cpp.
The logic for different special cases of type casting is spread over multiple places currently. This patch simply re-factors some of that  code (folding of of type casts using statically known protocol conformances) and moves it into one central place, which makes it easier to maintain. Plus, it allows other clients of DynamicCasts benefit from it as well, e.g. the inliner can use this now. NFC.

Swift SVN r25486
2015-02-23 21:30:48 +00:00
Joe Groff
f44e94da97 Remove debug spew
Swift SVN r24777
2015-01-28 02:38:44 +00:00
Joe Groff
04f44ba038 SIL: Classify potentially bridgeable checked casts as MaySucceed.
Fixes rdar://problem/19482567.

Swift SVN r24773
2015-01-28 02:14:35 +00:00
Michael Gottesman
1afc987739 Refactor the SILArgument API on SILBasicBlock so we can insert bb arguments anywhere in the argument list. Also clean up the API names so that they all match.
Swift SVN r23543
2014-11-22 00:24:40 +00:00
John McCall
20b1f2de3e Switch isa and as? processing over to use the new
indirect cast instructions when necessary.

Swift SVN r19079
2014-06-22 09:53:36 +00:00
John McCall
e8428377de Add some functions to query a CastConsumptionKind.
Swift SVN r19077
2014-06-22 09:53:31 +00:00
John McCall
385879beea Remove the CheckedCastKind from SIL dynamic casts.
It is straightforward and less redundant to recover this
information from the operand types.

Swift SVN r19056
2014-06-20 22:43:53 +00:00
John McCall
48d6a833a5 SILGen unconditional dynamic casts using the new
unconditional_dynamic_cast_addr instruction.

Also, fix some major semantic problems with the
existing specialization of unconditional dynamic
casts by handling optional types and being much
more conservative about deciding that a cast is
infeasible.

This commit regresses specialization slightly by
failing to turn indirect dynamic casts into scalar
ones when possible; we can fix that easily enough
in a follow-up.

Swift SVN r19044
2014-06-20 07:47:03 +00:00