Commit Graph

1537 Commits

Author SHA1 Message Date
Arnold Schwaighofer
a0387eea40 Opaque result types: Dynamic replacement fixes for computed properties 2019-04-22 08:32:43 -07:00
Arnold Schwaighofer
bd2bee7572 [IRGen/TBDGen] Minor fixes for opaque result types.
Fixes rdar://problem/50001229.
2019-04-22 07:50:25 -07:00
Arnold Schwaighofer
84c7b77d02 Make opaque type descriptors dynamically replaceable
This is to support dynamic function replacement of functions with opaque
result type.

This approach requires that all state is thrown away (that could contain the
old returned type for an opaque type) between replacements.

rdar://48887938
2019-04-22 07:31:07 -07:00
swift-ci
53d5e800c1 Merge remote-tracking branch 'origin/master' into master-next 2019-04-19 16:50:46 -07:00
Slava Pestov
d6868acf8a IRGen: Categories on class stubs should go in a separate list and section 2019-04-19 16:50:29 -04:00
swift-ci
89372f876a Merge remote-tracking branch 'origin/master' into master-next 2019-04-18 15:10:40 -07:00
Joe Groff
a99716bbb8 Visit var/subscript opaque return decls during IRGen/TBDGen. 2019-04-17 14:46:22 -07:00
Joe Groff
c58737fb91 merge fixup 2019-04-17 14:46:22 -07:00
Joe Groff
ffc9fd5e38 IRGen: Emit opaque type descriptors. 2019-04-17 14:44:40 -07:00
Joe Groff
ca537d1e86 opaque descriptor wip 2019-04-17 14:44:40 -07:00
Joe Groff
09ca7a784b IRGen: Emit runtime calls to fetch opaque type metadata.
Introduce code to emit runtime calls to get the type metadata for the underlying type of an opaque type and to get its conformances.
2019-04-17 14:43:32 -07:00
Joe Groff
71912bbfd6 AST: Represent OpaqueTypeDecls.
To represent the abstracted interface of an opaque type, we need a generic signature that refines
the outer context generic signature with an additional generic parameter representing the underlying
type and its exposed constraints. Opaque types also need to be keyed by their originating decl, so
that we can treat values of the same opaque type as the same. When we check a FuncDecl with an
opaque type specified as its return type, create an OpaqueTypeDecl and associate it with the
originating decl. (A representation for *types* derived from the opaque decl will come next.)
2019-04-17 14:43:32 -07:00
swift-ci
707344affa Merge remote-tracking branch 'origin/master' into master-next 2019-04-12 07:29:33 -07:00
Slava Pestov
606e226f6f IRGen: Force field descriptors to be emitted when we emit typerefs
Emission of typerefs used by the runtime would force type metadata;
do the same for remote reflection-only typerefs.
2019-04-12 01:46:23 -04:00
Slava Pestov
af83492a45 IRGen: Lazily emit reflection field descriptors
Previously even if a type's metadata was optimized away, we would still
emit a field descriptor, which in turn could reference nominal type
descriptors for other types via symbolic references, etc.
2019-04-12 01:46:23 -04:00
Slava Pestov
dd80f588dd IRGen: Emit foreign type metadata using the lazy metadata mechanism
Instead of a wholly separate lazyness mechanism for foreign metadata where
the first call to getAddrOfForeignTypeMetadataCandidate() would emit the
metadata, emit it using the lazy metadata mechanism.

This eliminates some code duplication. It also ensures that foreign
metadata is only emitted once per SIL module, and not once per LLVM
module, avoiding duplicate copies that must be ODR'd away in multi-threaded
mode.

This fixes the test case from <rdar://problem/49710077>.
2019-04-12 01:46:23 -04:00
Slava Pestov
6d2fc0c08c IRGen: Change around how we decide to emit lazy type metadata
The old logic was confusing. The LazyTypeGlobals map would contain
entries for all referenced types, even those without lazy metadata.

And for a type with lazy metadata, the IsLazy field would begin
with a value of false -- unless it was imported.

When a non-imported type was finally visited in the AST, we would
try to "enable" lazyness for it, which meant queueing up any
metadata that had been requested prior, or immediately emitting
the metadata otherwise.

Instead, let's add a separate map that caches whether a type has
lazy metadata or not. The first time we ask for the metadata of a
type, consult this map. If the type has lazy metadata according to
the map, queue up metadata emission for the type. Otherwise, emit
metadata eagerly when the type is visited in the AST.
2019-04-12 01:46:23 -04:00
Slava Pestov
4ec1e83385 IRGen: Assert if its too late to queue up lazy emission 2019-04-12 01:46:22 -04:00
swift-ci
e2ffa482cc Merge remote-tracking branch 'origin/master' into master-next 2019-03-28 08:29:21 -07:00
adrian-prantl
d4149db878 Merge pull request #23425 from adrian-prantl/48409386
Remove Resilience workarounds and describe fixed-size global reslient
2019-03-28 08:25:02 -07:00
swift-ci
019c93647f Merge remote-tracking branch 'origin/master' into master-next 2019-03-27 12:29:03 -07:00
adrian-prantl
e622ea6980 Merge pull request #23465 from adrian-prantl/48018240-irgen
Add a -public-linkage-for-metadata-accessors IRGen flag for LLDB.
2019-03-27 12:13:41 -07:00
Adrian Prantl
0b8fc3d405 Remove Resilience workarounds and describe fixed-size global resilient
variables in DWARF.

rdar://problem/48409386
2019-03-27 10:51:16 -07:00
Adrian Prantl
e1f92cc39e Add a -force-public-linkage IRGen flag for LLDB.
In LLDB expressions, references to private metadata accessors may be
emitted and need to be bound to symbols available in the attached
program, even if these symbols are only supposed to have private
visibility within the program.

Also rdar://problem/48018240
2019-03-27 09:10:23 -07:00
swift-ci
36d8c65f53 Merge remote-tracking branch 'origin/master' into master-next 2019-03-27 05:29:27 -07:00
Slava Pestov
4207738e17 Add mangling and IRGen LinkEntity for Objective-C resilient class stubs 2019-03-26 18:44:44 -04:00
swift-ci
68948a4871 Merge remote-tracking branch 'origin/master' into master-next 2019-03-22 16:50:20 -07:00
Arnold Schwaighofer
add98add6a IRGen: The call to the dynamic implementation is a tail call 2019-03-21 10:12:35 -07:00
swift-ci
3752b17fd7 Merge remote-tracking branch 'origin/master' into master-next 2019-03-14 22:09:52 -07:00
Saleem Abdulrasool
a9bf6c6c81 IRGen: correct field metadata section name on COFF
COFF has a section name limit which was being exceeded.  Correct the
section name to what was expected (the tests are lenient and would
accept the ELF name as well).  Furthermore, ensure that the section is
emitted into the B group so that it can be collated and markers
inserted.
2019-03-14 18:31:55 -07:00
Saleem Abdulrasool
b97857e99f IRGen: adjust for SVN r355989
SVN r355989 adds support for the XCOFF file format.  For now, treat it as a COFF
target, though XCOFF and COFF are different.
2019-03-13 13:31:24 -07:00
swift-ci
c2452fb0b6 Merge remote-tracking branch 'origin/master' into master-next 2019-02-25 23:49:29 -08:00
Doug Gregor
9e4ba64c0f [IRGen] Document a bool parameter at the call site. NFC 2019-02-25 22:35:08 -08:00
Doug Gregor
b5f45f8f72 [IRGen] Mangle Swift @objc(renamed) protocols as Objective-C in metadata.
When emitting metadata for a Swift-defined @objc protocol that has
provided a specific Objective-C name (e.g., via @objc(renamed)),
mangle such protocols using their Objective-C names so they can be
found at runtime.

Only do this for metadata, because doing it anywhere else would cause
an ABI break. Fixes rdar://problem/47877748.
2019-02-25 17:31:08 -08:00
swift-ci
0d0210249f Merge remote-tracking branch 'origin/master' into master-next 2019-02-19 20:49:46 -08:00
Slava Pestov
69d1cafd1c AST: Add AvailabilityContext parameter to Decl::isWeakImported()
For now, it's not used, but we do try to pass the right value down from
our various call sites.

Progress on <rdar://problem/46674512>.
2019-02-19 18:58:44 -05:00
swift-ci
1fa9f9f2dc Merge remote-tracking branch 'origin/master' into master-next 2019-02-15 20:29:10 -08:00
Doug Gregor
d31ef61a28 Eliminate "sorting" of DeclContext-local protocols / conformances.
Sorting of DeclContext-local protocols and conformances shouldn't ever
be necessary, because the underlying data structures that produce
these lists should be deterministic. Sorting can hide any
non-determinism, so stop doing it and we can address the underlying
nondeterminism.
2019-02-15 14:16:48 -08:00
Saleem Abdulrasool
b700aed019 IRGen: followup for SVN r352827
This adjusts the previous change for the IRGen API changes in SVN r352827.  We
sometimes may get back a BitCastInst for the function type coercion.  Ensure
that we strip the pointer casts before performing the cast which may otherwise
fail with an assertions build.  We need to now perform a cast for the
existential boxed constructor and destructor calls to account for the missing
bitcast on a reused function.  This actually makes the IR a bit clearer as the
two parameters are being cast instead when necessary.
2019-02-14 09:27:48 -08:00
Bob Wilson
a43ee93445 Merge pull request #22353 from compnerd/r352827
Adjust for SVN r352827
2019-02-09 16:42:18 -08:00
swift-ci
89b29e1cda Merge remote-tracking branch 'origin/master' into master-next 2019-02-05 08:29:37 -08:00
Saleem Abdulrasool
6a1072d825 Adjust for SVN r352827
Update for `getOrInsertFunction` API in LLVM.
2019-02-04 12:48:46 -08:00
Saleem Abdulrasool
846a64b538 IRGen: give non_abi WeakODR linkage
Mark the non_abi functions as weak_odr.  This is needed on Windows
where the default argument generators are emitted as non-ABI functions.
These can be emitted multiple times and need to be coalesced by the
linker - that is be COMDATed as per WeakODR semantics as multiple
definitions are a hard error with PE/COFF.  Use WeakODR rather than
LinkOnceODR as we want to ensure that the symbol is preserved even if
unreferenced.
2019-01-31 17:53:50 -08:00
swift-ci
9416f1973d Merge remote-tracking branch 'origin/master' into master-next 2019-01-18 14:32:40 -08:00
Robert Widmann
c5b7230d22 [NFC] Upgrade EnumElementDecl to a DeclContext
Pure plumbing for the sake of default arguments.
2019-01-16 18:39:30 -05:00
swift-ci
6c6c3f6cbc Merge remote-tracking branch 'origin/master' into master-next 2019-01-16 11:30:02 -08:00
Slava Pestov
5182104e47 Merge pull request #21883 from slavapestov/default-witness-thunks-multithreaded-again
IRGen: Ensure that default witness thunks are emitted in the same thread as the protocol descriptor
2019-01-16 14:26:27 -05:00
swift-ci
16b7ebb1c0 Merge remote-tracking branch 'origin/master' into master-next 2019-01-16 10:10:05 -08:00
Slava Pestov
77e5b44560 IRGen: Ensure that default witness thunks are emitted in the same thread as the protocol descriptor
Protocol descriptors for resilient protocols relatively-reference
default witness thunks, so when using -num-threads N with N > 1,
we must ensure the default witness thunk is emitted in the same
LLVM module.
2019-01-15 21:42:24 -05:00
swift-ci
c7caa89c53 Merge remote-tracking branch 'origin/master' into master-next 2019-01-14 23:10:01 -08:00