Commit Graph

9332 Commits

Author SHA1 Message Date
Michael Gottesman
406bc0c19a [deserialization] Change SILLinking to use SILModule for linking instead of performing the linking itself.
This approach will allow us to go back to doing lazy linking if we want
to in the future.

Swift SVN r15498
2014-03-26 08:47:01 +00:00
Manman Ren
ea319984fd SILParser: handle overloaded members for super_method.
rdar://15763213


Swift SVN r15469
2014-03-25 22:35:02 +00:00
Michael Gottesman
f4bb049bfc [deserialization] Enable lazy deserialization of witness tables.
This patch adds in the necessary infrastructure for lazily deserializing
witness tables. This is done by following the same approach as the
deserialization/serialization of SILFunction.

Now if one calls SILModule::lookUpWitnessTable and the given witness table is a
definition, the SILModule will attempt to deserialize it from one of the other
modules.

Swift SVN r15403
2014-03-24 09:16:09 +00:00
Michael Gottesman
59a44ca1f2 [deserialization] Add SILWitnessTable::convertToDefinition for converting SILWitnessTable declarations -> definitions.
This will be used for lazy deserialization of witness tables.

Swift SVN r15402
2014-03-24 05:07:21 +00:00
Michael Gottesman
5b1e2d4025 This caching statement should not be necessary due to r15399.
Swift SVN r15401
2014-03-24 05:07:20 +00:00
Michael Gottesman
f807249aa8 [deserialization] Store the mangled name of a SILWitnessTable on the instance itself.
The importance of this is that we will be able to use this name during
SIL serialization/deserialization to lookup partially deserialized
witness tables.

I left IRGen's original code alone until I can discuss with Joe/John
combining the logic together.

Swift SVN r15400
2014-03-24 05:07:20 +00:00
Michael Gottesman
69af5467ce Add a witness table to the witness table lookup cache when we create it, not lazily as we perform a search.
This means that every witness table in a SILModule must be in the
protocol conformance -> witness table map. We still return nullptr if
there is no such witness table.

Swift SVN r15399
2014-03-24 04:38:49 +00:00
Chris Lattner
0bec9700e8 Add a hack to the ASTPrinter, when printing PatternBindingDecls to print
immutable variables with a let prefix instead of a 'var' prefix.  This allows
us to AST print this as 'let' instead of 'var', which isn't totally awesome,
but is better than misleading people with var.

func f() {
  let x : Int  = 42
}

Also, fix the SILPrinter to explode pattern binding decls, so that it doesn't
fall into the booby traps inherent in PatternBindingDecl printing.


Swift SVN r15393
2014-03-23 16:37:51 +00:00
Joe Groff
2cd5244e98 SIL: Don't emit capture parameters for local generic param types.
Fixes <rdar://problem/16399018>.

Swift SVN r15367
2014-03-22 16:31:10 +00:00
Ted Kremenek
f43842e160 Change processing of @asmname to use a new internal representation.
This representation is inspired by Clang's internal representation.
The current attribute representation, which is basically a union
of "stuff" in DeclAttributes, is not amendable to richer
attributes, such as @availability, that need to be implemented.
In Clang, attributes are modeled with actual objects that
encode both semantic and syntactic information (e.g., source ranges)
that facilitate richer checking, better diagnostics, and better tools.

This change is foundational for implementing @availability, but
also is a better long-term representation.  As a migratory path,
it creates some duplications, with AttrKind and DeclAttrKind, the
two which should eventually become the same thing.

As part of this patch, there is some additional parser recovery
(for the new attribute representation) for duplicate attributes.
The parser now parses the entire duplicate attribute, which could
be quite complex, and then issues a diagnostic that the attribute
is a duplicate (and discarding it).  This delayed diagnostic
also allows us to present ranges for the duplicate attribute, which
provides a better user experience.

Swift SVN r15365
2014-03-22 14:58:30 +00:00
Michael Gottesman
2235221854 [deserialization] Unique normal protocol conformances in ASTContext like we do for specialized/inherited protocol conformances.
This fixes the following two bugs:

1. We sometimes would create new conformances when deserializing a
witness method which would not be mapped in the SILModule to the
appropriate witness table. This would cause us to be unable to perform
devirtualization of this witness method. This is tested via a new
verifier check.

2. Different conformances would be created for an instance of a base
protocol and the original protocol. This would cause IRGen to try to
emit witness table global variables with differing types, hitting an
assertion. This is tested via a traditional test.

Swift SVN r15362
2014-03-22 05:05:48 +00:00
Michael Gottesman
3ad6f33202 Teach the generic specializer how to create SILWitnessTable declarations if a specialized conformance does not have a witness table.
This also teaches IRGen not to emit WitnessTable declarations. This
causes them to be left as unknown symbols in the resulting executable.

Swift SVN r15361
2014-03-22 05:05:47 +00:00
Michael Gottesman
084d468236 [deserialization] Refactor SILModule::linkFunction into a SILVisitor pattern.
The if statement therein was just going to keep getting bigger and
bigger especially since I am going to add support for witness_method
among other things.

Swift SVN r15360
2014-03-22 02:06:38 +00:00
Joe Groff
fe20665b4b SIL: Handle unprototyped function types in CFunctionTypeConventions.
Fixes <rdar://problem/16355896>.

Swift SVN r15352
2014-03-21 23:47:08 +00:00
Michael Gottesman
8016a1cf4d Refactor out code for checking operands into checkLegalTypes and enable checking (via checkLegalTypes) of generic types of SILArguments/SILInstructions.
These checks will make sure that any SILArgument, SILInstruction that is
generic has a primary archetype that matches a primary archetype in the
generic parameter list of the function which contains it.

Swift SVN r15281
2014-03-20 20:05:16 +00:00
Michael Gottesman
5d2a25f0b9 Make sure that every operand of every SILInstruction that is generic has primary archetypes which are valid in the current function's context.
I also refactored out common code used both here and in checkApplyInst
that does the same thing but for ApplyInst substitution parameters.

Swift SVN r15278
2014-03-20 19:47:13 +00:00
John McCall
c40a2e54b2 Extract a method to print a CheckedCastKind and dump
it on CheckedCastExprs.

Swift SVN r15245
2014-03-19 20:25:09 +00:00
John McCall
79dbbd6c9c Bridge optional types when the value type is trivially bridgeable.
Swift SVN r15128
2014-03-17 05:05:08 +00:00
John McCall
580bf7f5d6 getLoweredBridgedType doesn't seem to promise to return
a canonical type.

Swift SVN r15127
2014-03-17 05:05:07 +00:00
John McCall
ab809e8ac9 Use hasRetainablePointerRepresentation instead of
hasReferenceSemantics when deciding whether an ObjC result
can be autoreleased.

Test to come as part of a larger, integrated whole.

Swift SVN r15126
2014-03-17 05:05:03 +00:00
Doug Gregor
3cc834714c SILGen for initialization using an existential metatype value.
Loosen the restrictions on open_existential_ref to also allow it to
refer to an existential metatype. When it does, open_existential_ref
returns the metatype for the opened archetype.



Swift SVN r15113
2014-03-16 20:52:54 +00:00
Nadav Rotem
51087ea8b0 CSE cond_fail.
Swift SVN r15111
2014-03-16 04:27:07 +00:00
Nadav Rotem
6b6761fa08 CSE ApplyInst of BuiltIns with no side effects.
Swift SVN r15110
2014-03-16 03:52:18 +00:00
Nadav Rotem
9583261228 CSE two more instructions.
Swift SVN r15102
2014-03-15 07:25:26 +00:00
Manman Ren
8e64b2a170 SILParser: parsing generic code.
Do not print '.Archetype' property of Substitution in SILPrinter.
Update testing cases accordingly.

We assume the order of substitions matchs the order of AllArchetypes for
the generic param list.

rdar://14443287


Swift SVN r15090
2014-03-14 23:13:55 +00:00
Michael Gottesman
df649b724b [serialization] Do not serialize the bodies of sil functions with external linkage.
They should always be deserialized from their original modules.

Swift SVN r15089
2014-03-14 23:11:54 +00:00
Joe Groff
27310e2893 SIL: Properly account for generic parameters of foreign destructors.
We can't assume that ObjC types are never generic anymore.

Swift SVN r15072
2014-03-14 20:43:21 +00:00
Joe Groff
6e5c776bb9 SIL: Preserve GenericFunctionType signatures through bridging.
If we feed a GenericFunctionType into getBridgedFunctionType, we should get one out.

Swift SVN r15071
2014-03-14 20:43:18 +00:00
Michael Gottesman
11c03b0482 [deserialization] When linking functions, return failure if we get back a declaration.
We consider linking to only succeed if we actually convert a declaration
into a definition.

Swift SVN r15070
2014-03-14 20:36:17 +00:00
John McCall
794360d312 Permit optional class types to be returned autoreleased.
Swift SVN r15042
2014-03-14 07:10:10 +00:00
Chris Lattner
bca9000809 silence some fallthrough warnings.
Swift SVN r15033
2014-03-14 05:50:38 +00:00
Michael Gottesman
5b88963e78 [SIL] Implement external SIL Witness Table declarations.
This will help with ensuring that we do not create multiple witness
table "definitions" one of which is null. That situtation yields an
IRGen assertion to be hit since the external declaration (in the guise
of a definition) has a different type from the actual deserialized
definition.

Swift SVN r14999
2014-03-13 19:52:59 +00:00
Manman Ren
e716023bc3 SILParser: handle overloaded members in SILDeclRef.
The problem is that SILDeclRef::print does not print enough information
for SILParser to find the correct Decl when there are overloading members.

This commit handles the case for class_method. We print type information for
the SILDeclRef together with the SILFunctionType separated by a comma.

SILParser then use the type information to disambiguate the overloaded
methods.

rdar://15763213


Swift SVN r14994
2014-03-13 17:52:47 +00:00
Manman Ren
3a95cfc128 SILPrinter & SILParser: update both and testing cases to match SIL.rst.
For struct_extract and struct_element_addr, we now print %7 : $M, #M.member
instead of %7 : $M, #member

rdar://15810604


Swift SVN r14960
2014-03-12 18:07:48 +00:00
Adrian Prantl
d1fed3b520 silence warnings
Swift SVN r14921
2014-03-11 16:55:15 +00:00
Dave Abrahams
156e867eab [SIL] Fix a broken string literal
Swift SVN r14911
2014-03-11 06:11:30 +00:00
Joe Groff
c5feea4697 SILGen: Emit conformances for external definitions.
Teach IRGen to honor the linkage of SILWitnessTables, and teach SILGen to emit witness tables and protocol witness thunks for external definitions with shared linkage. Fixes <rdar://problem/16264703>.

Swift SVN r14908
2014-03-11 05:08:58 +00:00
Manman Ren
37ea7f9d4b SILPrinter & SILParser: update both and testing cases to match SIL.rst.
For ref_element_addr, we now print
ref_element_addr %7 : $M, #M.member
instead of
ref_element_addr %7 : $M, #member

rdar://15810604


Swift SVN r14899
2014-03-11 00:25:51 +00:00
Michael Gottesman
6f5e78c0df [deserialization] Add in verifier check that makes sure an applies replacement is equal to one of its parent functions archetypes.
Swift SVN r14891
2014-03-10 23:37:11 +00:00
Michael Gottesman
3181ecc4fe Remove trailing whitespace. NFC.
Swift SVN r14890
2014-03-10 23:37:11 +00:00
Joe Groff
945fbaf167 SIL: Add a linkage specifier to SILWitnessTables.
In the short term, we need to be able to emit shared symbols for SILWitnessTables corresponding to Clang-imported modules, and soon, the generic specializer will need to be able to reference *_external witness tables deserialized from library modules.

Swift SVN r14887
2014-03-10 23:14:16 +00:00
Mark Lacey
2f4b982051 Remove TrivialTypeCache and AddrOnlyTypeCache from SILModule.
Now that we have better hashing in type lowering, these do not provide a
benefit.

Swift SVN r14878
2014-03-10 21:34:06 +00:00
Michael Gottesman
ea1d62e23a [deserialization] Verify functions when we deserialize them. This should help to catch deserialization issues.
Swift SVN r14876
2014-03-10 21:16:04 +00:00
Joe Groff
8e2521e8c2 SILGen: Emit derived '==' operators from Clang modules with shared linkage.
In Sema, give derived '==' definitions the module's DerivedFileUnit as their decl context instead of the more general Module, and give it a backreference to the nominal type for which it was derived. 
In SILGen, visit the derived global decls associated with Clang-imported enums, and give them shared linkage. Part of fixing <rdar://problem/16264703>.

Swift SVN r14875
2014-03-10 20:33:54 +00:00
Michael Gottesman
c52da10ee6 Fix typo where nullptr should be false.
Swift SVN r14835
2014-03-09 05:05:40 +00:00
Michael Gottesman
b4430012b2 [deserialization] Change isPublic(SILLinkage) -> hasPublicVisibility(SILLinkage) which is makes it 100% clear what the function is attempting to do.
Swift SVN r14823
2014-03-08 02:49:35 +00:00
Michael Gottesman
ba6ac196f6 Revert "[deserialization] Deserialize WitnessTables/VTables in SILModule, not in SILLinking."
This reverts commit r14623. I will recommit this when I reenable deserialization
of witness tables/vtables. This will enable the deserialization of SILFunctions
by default from the stdlib by avoiding the lack of external witness
tables/vtables.

Swift SVN r14786
2014-03-07 19:27:01 +00:00
Michael Gottesman
a50e4d54b8 Revert "[deserialization] Disable deserialization of vtables/witness tables for now."
This reverts commit r14750. I need to disable some tests.

Swift SVN r14751
2014-03-06 20:52:01 +00:00
Michael Gottesman
0b142c1f04 [deserialization] Disable deserialization of vtables/witness tables for now.
Some recent work done by John have unblocked deserialization of SILFunctions. We
still can not properly deserialize witness tables/vtables but enabling by
default deserialization of SILFunctions from the stdlib is a good first step
toward reaching our performance goals.

There will be forthcoming commits which removes Benchmarks.swift and all of the
infrastructure we have in place for compiling benchmarks in the standard
library.

Swift SVN r14750
2014-03-06 20:15:49 +00:00
Joe Groff
54f9cf4b7d SIL: Don't crash when dumping a SILModule without an origin Swift module.
Skip trying to collect the top-level decls if there's no module to collect them from.

Swift SVN r14738
2014-03-06 17:44:54 +00:00