Commit Graph

1572 Commits

Author SHA1 Message Date
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
Slava Pestov
152fab22a1 Revert "IRGen: Ensure that default witness thunks are emitted in the same thread as the protocol descriptor" 2019-01-15 01:05:06 -05:00
Saleem Abdulrasool
0c3f772767 IRGen: ensure that declarations are not COMDATed
Unfortunately, declarations cannot be marked with their COMDAT groups.
This fixes multithreaded IRGen where we would emit declarations for the
global initializers with COMDATs causing the IR Verifier to object.  The
existing test cases cover this scenario.
2019-01-14 16:52:35 -08:00
swift-ci
3fc7a5d887 Merge remote-tracking branch 'origin/master' into master-next 2019-01-14 15:11:06 -08:00
Slava Pestov
50465688f8 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-14 16:26:07 -05:00
Saleem Abdulrasool
aba8de7345 IRGen: adjust for SVN r351020
Update for SVN r351020, which removed TypeBuilder from LLVM.  This was not
actually used for constructing types anymore, so simply remove the header.
2019-01-14 08:49:03 -08:00
Saleem Abdulrasool
7f005414dd Merge pull request #21639 from compnerd/tinkering-linkering
ApplyIRLinkage cleanups
2019-01-04 15:26:11 -08:00
Saleem Abdulrasool
d3efed2943 IRGen: use ApplyIRLinkage more aggressively (NFC)
Use `ApplyIRLinkage` rather than manually applying the DLLStorage.  This
makes it much more apparent as to the desired semantic linkage desired.
2019-01-04 10:39:03 -08:00
Daniel Dunbar
8980213f7c Merge pull request #20687 from ddunbar/swasm-allow-wasm-object-format
[Swift+WASM] Allow Wasm object format.
2019-01-04 08:34:43 -08:00
Slava Pestov
4d4c194760 IRGen: Clean up and fix lazy metadata emission for reflection
We were wastefully emitting an accessor if a field had a type, for
example if my field type was (() -> (X, Array<Y>>) we would force
the emission of a function to construct (() -> (X, Array<Y>)) even
though all we care about is the type metadata for X and Y.

Conversely, we would skip the field type if it contained an
archetype, even if it otherwise contained metadata that we need
to force to emit, for instance something like (T, X) where T is
a generic parameter and X is a nominal type.

A final side effect is we no longer try to emit type metadata for
one-element tuples when emitting enum payload metadata, which is
something I want to assert against.
2018-12-15 00:05:48 -05:00
Jordan Rose
b060166dc7 Merge pull request #20559 from jrose-apple/sub-rosa
[IRGen] Generate proper type descriptors for ObjC subscript accessors

https://bugs.swift.org/browse/SR-8356
2018-12-10 11:58:50 -08:00
Saleem Abdulrasool
f067cb7250 IRGen: address TODO for COMDATing
Enable COMDATing in `createFunction`.  This is particularly important
for the emission of the GetEnumTagSinglePayload.  The function emission
is marked as linkonce ODR but does not get COMDAT'ed currently, breaking
emission on PE/COFF targets like Windows.
2018-12-08 22:48:56 -08:00
Jordan Rose
f6abffcaba [IRGen] Stop registering protocol property accessors twice in JIT mode
We visited them twice, which led to registering them twice. Add a test
for this feature so that we don't regress on this or on the use of
non-extended types in the future (see previous commits).
2018-12-08 22:43:34 -08:00
Jordan Rose
c34fe93f98 [IRGen] Generate proper type descriptors for ObjC subscript accessors
https://bugs.swift.org/browse/SR-8356
rdar://problem/42284266
2018-12-08 14:20:49 -08:00
Jordan Rose
4abb570025 [IRGen] Stop using "extended" type encodings where not supported
These are only used in two places in the Apple Objective-C runtime:

- A protocol's "extended method types" list
- Block type descriptors

We were using them when dynamically registering a protocol with the
Objective-C runtime, but that's just expecting "normal" types; the
"extended method types" list is never present in such a protocol.
2018-12-08 14:20:49 -08:00
Slava Pestov
aa747dcd81 Remove property behaviors 2018-12-07 20:38:33 -05:00