Commit Graph

2424 Commits

Author SHA1 Message Date
Michael Gottesman
a36a4ec738 [sil] Add convenience APIs: createTrivial{Load,Store}Or to SILBuilder.
Often times one wants to create a load/store and you don't know if you have a
trivial type. These APIs allow you to use the correct semantic ownership
qualifier at the callsite without worrying: if you have a true trivial type, the
API will change the qualifier to trivial for you.
2017-07-13 14:23:49 -07:00
Michael Gottesman
38cd78024b Add template <T> ValueBase::getSingleUserOfType.
Looping over all users and returning the only user of a specific type is a
common pattern in the compiler. This method just allows for the loop to be
eliminated.
2017-07-13 14:22:42 -07:00
swift-ci
f70e32cf19 Merge remote-tracking branch 'origin/master' into master-next 2017-07-12 18:08:55 -07:00
swift-ci
5bd97c500b Merge pull request #10923 from gottesmm/small_is_lowering_of_value_metatype_changes 2017-07-12 18:03:37 -07:00
Michael Gottesman
90289277e8 [sil] Add assert to SILBuilder::createValueMetatype to ensure that its type is a lowered type of our expected formal instanceType.
It makes it easier to track down this type of bug since the assert occurs in
SILBuilder right where the invalid ValueMetatype is created.

rdar://problem/31880847
2017-07-12 17:32:00 -07:00
Michael Gottesman
f2c4aeac31 [sil] Refactor isLoweringOf from the verifier onto SILType.
I am going to use this to put an assertion in SILBuilder on ValueMetatype so
that the assertion fires right when the ValueMetatype is created instead of
later once we are verifying. It is still only being used in assertions/etc.

rdar://problem/31880847
2017-07-12 17:31:59 -07:00
swift-ci
c33d8667ae Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 12:49:08 -07:00
swift-ci
e98182387b Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 12:23:35 -07:00
John McCall
7f22faf968 Substantially rework how SILGen handles bridging as part of laying the
ground work for the syntactic bridging peephole.

- Pass source and dest formal types to the bridging routines in addition
  to the dest lowered type.  The dest lowered type is still necessary
  in order to handle non-standard abstraction patterns for the dest type.

- Change bridging abstraction patterns to store bridged formal types
  instead of the formal type.

- Improve how SIL type lowering deals with import-as-member patterns.

- Fix some AST bugs where inadequate information was being stored in
  various expressions.

- Introduce the idea of a converting SGFContext and use it to regularize
  the existing id-as-Any conversion peephole.

- Improve various places in SILGen to emit directly into contexts.
2017-07-11 12:45:13 -04:00
Michael Gottesman
1264cfa492 [semantic-sil] Add a semantic attribute "verify.ownership.sil.never".
This semantic attribute allows a user to disable ownership verification on
specific functions.

The intention is that once I turn on the sil ownership verifier for parts of the
stdlib, if an engineer exposes an ownership issue, they can disable ownership
verification on that specific function, file a bug, and continue with their
work.

rdar://31880847
2017-07-10 13:28:06 -07:00
Joe Groff
8793212293 Merge pull request #10741 from jckarter/key-path-generic-computed
Handle generic computed properties in key paths.
2017-07-07 13:50:27 -07:00
Joe Groff
101788dbd4 IRGen: Support for computed properties with dependent generic context.
Use the KeyPath implementation's new support for instantiating and dealing with captures to lower the generic context required to dispatch computed accessors with dependent generics.
2017-07-06 20:07:41 -07:00
swift-ci
cce4d1e960 Merge remote-tracking branch 'origin/master' into master-next 2017-07-06 11:28:50 -07:00
Robert Widmann
957d633185 Rename getInOutOrLValueObjectType to getWithoutSpecifierType
Prepares the AST for a future in which more than just inout and
@lvalue need to be stripped off of ephemeral types.
2017-07-06 09:35:04 -07:00
Bob Wilson
b9f6e6b371 Remove llvm::DominatorBase templates to match LLVM r306713.
The content from DominatorBase has been merged into DominatorTreeBase,
and DominatorBase has been removed.
2017-07-05 11:56:00 -07:00
Michael Gottesman
78713ce07f Merge pull request #10519 from jrose-apple/ModuleMacro-master-next
WIP getting master-next up and running with clang::ModuleMacro
2017-06-30 14:52:09 -07:00
swift-ci
b28a1093da Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 15:09:18 -07:00
Doug Gregor
623d72db3c [AST] Make the "requirement signature" of a protocol a flat array.
Rather than pretend that the requirement signature of a protocol is a
full, well-formed generic signature that one can meaningfully query,
treat it as a flat set of requirements. Nearly all clients already did
this, but make it official. NFC
2017-06-29 14:01:49 -07:00
Greg Parker
7b009eccde Merge remote-tracking branch 'origin/master' into master-next 2017-06-28 15:25:17 -07:00
Joe Groff
3c82e981f9 KeyPaths: Add support for optional chaining/forcing components.
rdar://problem/31768715
2017-06-26 09:40:31 -07:00
Jordan Rose
c22168d02d [SIL] Implement a very simple isLegalToHoistInto for llvm::LoopInfo.
I'm not a SIL author, so it's likely that this could be improved,
but I think this is closest to the old LLVM behavior.
2017-06-23 12:49:49 -07:00
Huon Wilson
d49d3e9337 Merge pull request #10394 from huonw/symbol-list-9
[AST] Move getEffectiveAccess calls into SIL.
2017-06-22 10:38:17 -07:00
Andrew Trick
e51bc3beca Add a comment in getCalleeArgIndexOfFirstAppliedArg(). 2017-06-21 19:39:12 -07:00
Huon Wilson
a0bc3bd0b6 [AST] Move getEffectiveAccess calls into SIL. 2017-06-20 17:34:48 -07:00
Andrew Trick
e27bdf706e Add utilities to ApplySite to avoid hardcoding parameter/argument offsets. 2017-06-20 00:01:52 -07:00
Huon Wilson
296f23189b [TBDGen] Protocol witnesses thunks for members of public superprotocols are public.
Specifically, public superprotocols of non-public protocols have some
weird handling in SILGen, so we reproduce this.

Fixes rdar://problem/32254485 .
2017-06-19 15:00:12 -07:00
Roman Levenstein
2a10d8692b Clean-up the code that stored and passes the SILSerializeAll flag around.
- SILSerializeAll flag is now stored in the SILOptions and passed around as part of it
- Explicit SILSerializeAll/wholeModuleSerialized/makeModuleFragile API parameters are removed in many places
2017-06-16 17:50:33 -07:00
swift-ci
22bc57287e Merge remote-tracking branch 'origin/master' into master-next 2017-06-08 10:08:35 -07:00
Roman Levenstein
647466d0b0 [sil-opened-archetype-tracker] Fix a memory leak
Placeholder global_addr instructions were never destroyed.
Now they are inserted in the entry basic block and later removed from there by the end of SIL deserialization.
2017-06-08 07:50:57 -07:00
swift-ci
2f46f4574f Merge remote-tracking branch 'origin/master' into master-next 2017-06-07 17:28:34 -07:00
Michael Gottesman
f85da6860a [sil] Delete SILInstruction::removeFromParent().
This is a very easily misused API since it allows for users to leak instructions
if they are not careful. This commit removes this API and replaces the small
number of uses of this API with higher level APIs that accomplish the same task
without using removeFromParent(). There were no API users that specifically
required removeFromParent.

An example of one way we were using removeFromParent is to move a SILInstruction
to the front of a block. That does not require exposing an API like
removeFromParent()... we can just create a higher level API like the one added
in this commit: SILInstruction::moveFront(SILBasicBlock *).

rdar://31276565
2017-06-07 16:52:10 -07:00
swift-ci
247fa21f19 Merge remote-tracking branch 'origin/master' into master-next 2017-06-07 00:08:33 -07:00
Michael Gottesman
a11fceb635 [gardening] Remove unneeded method addNodeToList on ilist_traits<SILBasicBlock>.
addNodeToList only needs to be implemented to override the default callback
behavior of ilist_trait_defaults<SILBasicBlock>.  This implmentation in
ilist_traits<SILBasicBlock> is exactly the same as the default callback so is
unnecessary.
2017-06-06 10:12:37 -07:00
swift-ci
19acfea4fc Merge remote-tracking branch 'origin/master' into master-next 2017-06-05 19:48:33 -07:00
Michael Gottesman
c3a5c51586 [gardening] Move SILInstruction::replaceAllUsesWithUndef onto ValueBase.
This allows this method to also be used on SILArguments.
2017-06-05 17:01:02 -07:00
swift-ci
d8272944da Merge remote-tracking branch 'origin/master' into master-next 2017-05-22 22:08:34 -07:00
Slava Pestov
9c7afa7bdd SILGen: Fix issues with types nested inside fully-concrete extensions
Add a new version of TypeConverter::getEffectiveGenericSignature()
which takes a DeclContext, which uses the same logic as the
AnyFunctionRef version, and use it when computing lowered types
for destructors, stored property initializers and ivar destroyers.

Also, canonicalize the interface type of 'Self' as part of building
these types, to fold away concrete generic parameters.

Fixes <rdar://problem/32120987>.
2017-05-22 19:49:53 -07:00
swift-ci
ef2dc2c423 Merge remote-tracking branch 'origin/master' into master-next 2017-05-12 12:48:31 -07:00
Roman Levenstein
58dab83350 Make maybeScopeless declaration unconditionally available 2017-05-12 12:33:49 -07:00
Max Moiseev
614bb13cbf Merge remote-tracking branch 'origin/master' into master-next 2017-05-11 11:29:22 -07:00
Huon Wilson
606a3cc679 Merge pull request #9313 from huonw/symbol-list-7
TBD: ivar init/destroy, materializeForSet callbacks
2017-05-11 20:13:22 +10:00
Roman Levenstein
3e7da65106 Merge pull request #9470 from swiftix/generic-specialization-fixes
[generic-specializer] Fixes for partial_apply instructions and for specialization of self-recursive functions
2017-05-10 21:04:54 -07:00
Jordan Rose
cbc35f03d3 Merge pull request #9451 from jrose-apple/protocols-have-tables-too
Handle missing members in protocols as well.
2017-05-10 17:02:52 -07:00
Jordan Rose
df26b25f3a Merge pull request #9360 from jrose-apple/VTablePlaceholder
Add a new MissingMemberDecl and use it to handle non-deserializable class members
2017-05-10 17:02:16 -07:00
Roman Levenstein
f78678a529 [sil-cloner] Improve handling of self-recursive apply instructions
- re-factor the code so that all kinds of applies can reuse it
- properly handle self-recursive generic functions

Fixes rdar://31899989 and rdar://31886854
2017-05-10 16:31:08 -07:00
Jordan Rose
aeb0fedad1 Handle missing members in protocols as well.
This means both not crashing when we deserialize the protocol but
also emitting correct offsets for dynamic dispatch through the
protocol's witness table.

Also fix a bug with vtable and witness table slots for
materializeForSet accessors for properties that can't be
imported. Because materializeForSet doesn't have the type of the
property in its signature, it was taking a different failure path from
everything else, and that failure path didn't properly set the name or
flags for the missing member.

Finishes rdar://problem/31878396
2017-05-10 13:43:33 -06:00
Roman Levenstein
946b1d4225 Fix issues with the AddressLowering pass
Override the current SILModuleConvention of the SILModule when we perform the address lowering.
2017-05-10 11:59:43 -07:00
Jordan Rose
384b2a674b Actually honor MissingMemberDecls in ClassMetadataScanner.
...which is sufficient to correctly invoke methods in a vtable
even when members have been deleted. 🎉
2017-05-10 12:41:22 -06:00
Roman Levenstein
45c2c4af0e Re-factoring: Get rid of useless arguments in "create*Apply" functions
Till now createApply, createTryApply, createPartialApply were taking some arguments like SubstCalleeType or ResultType. But these arguments are redundant and can be easily derived from other arguments of these functions. There is no need to put the burden of their computation on the clients of these APIs.

The removal of these redundant parameters simplifies the APIs and reduces the possibility of providing mismatched types by clients, which often happened in the past.
2017-05-10 08:03:37 -07:00
swift-ci
966ea67056 Merge remote-tracking branch 'origin/master' into master-next 2017-05-09 15:08:38 -07:00