Commit Graph

1549 Commits

Author SHA1 Message Date
Doug Gregor
3c1f6f72c9 [IRGen] Only emit conformances local to a nominal type along with its metadata.
Rather than using getAllConformances() to emit all conformances for a
nominal type whenever we emit its type metadata, use
getLocalConformances() consistently--on the nominal type and on any
extension--to emit the conformances in the appropriate source files.
2018-08-03 09:23:26 -07:00
swift-ci
f7b8996498 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 20:59:23 -07:00
Slava Pestov
2d17ea34f4 IRGen: Move type layout verifier implementation to TypeLayoutVerifier.cpp 2018-07-30 18:37:09 -07:00
swift-ci
8247c2ba15 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 13:09:54 -07:00
Joe Groff
f8e5ebe873 Merge pull request #18299 from jckarter/enable-key-path-resilience
Enable key path resilience.
2018-07-30 13:00:43 -07:00
swift-ci
7f536bef9a Merge remote-tracking branch 'origin/master' into master-next 2018-07-29 10:49:08 -07:00
John McCall
db8f23df74 Update the ABI for uniquing foreign type metadata.
- `swift_getForeignTypeMetadata` is now a request/response function.

- The initialization function is now a completion function, and the
  pointer to it has moved into the type descriptor.

- The cache variable is no longer part of the ABI; it's an
  implementation detail of the access function.

- The two points above mean that there is no special header on foreign
  type metadata and therefore that they can be marked constant when
  there isn't something about them that needs to be initialized.

The only foreign-metadata initialization we actually do right now is
of the superclass field of a foreign class, and since that relationship
is a proper DAG, it's not actually possible to have recursive
initialization problems.  But this is the right long-term thing to do,
and it removes one of the last two clients of once-based initialization.
2018-07-29 03:16:35 -04:00
swift-ci
0d5cb630cc Merge remote-tracking branch 'origin/master' into master-next 2018-07-28 10:09:14 -07:00
John McCall
d10239313f Reference runtime-only ObjC classes with bare strings.
As part of this, rename TypeMetadataRecordKind to TypeReferenceKind
and consistently give it three bits of storage.

The better modelling of these type references appears to have been
sufficient to make dynamic conformance checks succeed, which is good
but unexpected.
2018-07-27 22:55:22 -04:00
Joe Groff
9cc6d94b49 Adjust TBDGen rules for property descriptors.
- Move the filter checks in SILGen for skipping emitting certain property descriptors into the AbstractStorageDecl::exportsPropertyDescriptor() predicate, to ensure that TBDGen and SILGen are in sync
- Fix the linkage of property descriptors to be based on the getter's linkage rather than the property's, since a property may be internal but have usableFromInline accessors
2018-07-27 13:11:31 -07:00
swift-ci
97d4d925fc Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 14:09:23 -07:00
John McCall
dc052e6364 Resolve metadata cycles through non-generic value types with resilient layout.
The central thrust of this patch is to get these metadata initializations
off of `swift_once` and onto the metadata-request system where we can
properly detect and resolve dependencies.  We do this by first introducing
runtime support for resolving metadata requests for "in-place"
initializations (committed previously) and then teaching IRGen to actually
generate code to use them (this patch).

A non-trivial amount of this patch is just renaming and refactoring some of
existing infrastructure that was being used for in-place initializations to
try to avoid unnecessary confusion.

The remaining cases that are still using `swift_once` resolution of
metadata initialization are:

- non-generic classes that can't statically fill their superclass or
  have resilient internal layout

- foreign type metadata

Classes require more work because I'd like to switch at least the
resilient-superclass case over to using a pattern much more like what
we do with generic class instantiation.  That is, I'd like in-place
initialization to be reserved for classes that actually don't need
relocation.

Foreign metadata should also be updated to the request/dependency scheme
before we declare ABI stability.  I'm not sure why foreign metadata
would ever require a type to be resolved, but let's assume it's possible.

Fixes part of SR-7876.
2018-07-25 15:21:55 -04:00
swift-ci
f0fe310f44 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 19:29:28 -07:00
Doug Gregor
a2b2798de2 [ABI] Eliminate the now-unused protocol requirement array.
This is a holdover from the old protocol descriptor layout, which is no
longer useful.
2018-07-24 17:33:16 -07:00
Bob Wilson
b254041121 Merge remote-tracking branch 'origin/master' into master-next 2018-06-28 23:23:29 -07:00
Slava Pestov
fcfa1786c8 IRGen: Add another lldb resilience hack
When accessing global variables defined in the REPL, lldb does not consult
debug info, so it does not see that the DW_OP_deref was emitted.

So instead, set a special bit on globals defined in the REPL which bypasses
resilience for them altogether.

Part of the fix <rdar://problem/39722386>.
2018-06-28 16:56:55 -07:00
swift-ci
bea73f7bce Merge remote-tracking branch 'origin/master' into master-next 2018-06-26 17:29:54 -07:00
Arnold Schwaighofer
61c9276809 Fix compile error 2018-06-26 06:17:18 -07:00
Arnold Schwaighofer
d430bb0074 Sink the logic into getResilienceExpansionForLayout
This clearly satisfies the postcondition that 'Calling isResilient() with this scope will always return false.'
2018-06-25 19:25:10 -07:00
swift-ci
60a0e52c88 Merge remote-tracking branch 'origin/master' into master-next 2018-06-22 08:29:52 -07:00
Slava Pestov
cb013b5881 DebugInfo: Bypass resilience to calculate if a global is indirect or not
Progress on <rdar://problem/39722386>.
2018-06-22 01:15:11 -07:00
swift-ci
243d603ffe Merge remote-tracking branch 'origin/master' into master-next 2018-06-15 08:29:11 -07:00
Jordan Rose
7938272c42 [DebugInfo] Don't record that the standard library imports itself (#17226)
This causes problems for cross-compilation -parse-stdlib tests that
emit debug info. At the moment we have zero of those, but we're
trying to add one.

Also, don't try to load new modules when recording imports. (This
isn't harmful, just inefficient.)
2018-06-15 08:23:11 -07:00
swift-ci
72f5e8d124 Merge remote-tracking branch 'origin/master' into master-next 2018-06-13 10:49:12 -07:00
Joe Groff
14fd26a6ed IRGen: More specifically curtail JIT use of relative references to the integrated REPL.
The other JIT modes all still build an entire local context into one LLVM module, so it's safe to form relative references, and necessary for reflection to work with private and local contexts. Only the integrated REPL needs this prohibition. Fixes rdar://problem/40607819.
2018-06-12 14:11:36 -07:00
swift-ci
b87ea23124 Merge remote-tracking branch 'origin/master' into master-next 2018-06-06 17:29:44 -07:00
Erik Little
863f3a19ff Rename @effects to @_effects
@effects is too low a level, and not meant for general usage outside
the standard library. Therefore it deserves to be underscored like
other such attributes.
2018-06-06 12:53:03 -04:00
swift-ci
fdbcfbca65 Merge remote-tracking branch 'origin/master' into master-next 2018-05-30 10:29:01 -07:00
Saleem Abdulrasool
477d43ef1c Merge pull request #16142 from compnerd/irgen-dllstorage
IRGen: the runtime is compacted into the stdlib
2018-05-30 10:27:29 -07:00
Saleem Abdulrasool
283c00e41e IRGen: special case the handling for the stdlib
Because the runtime is compacted into the standard library, functions
which are normally imported are actually local definitions.  Use module
level named metadata to identify the module as being the swift standard
library.  Refactor the condition slightly to improve code readability.

This addresses SR-7107!
2018-05-29 15:39:32 -07:00
swift-ci
76bd350b43 Merge remote-tracking branch 'origin/master' into master-next 2018-05-24 08:09:06 -07:00
Arnold Schwaighofer
cc7f207cec Rename swift sections from swift4 to swift5
rdar://38465220
2018-05-23 12:18:08 -07:00
swift-ci
228d6d7674 Merge remote-tracking branch 'origin/master' into master-next 2018-05-17 07:49:03 -07:00
Arnold Schwaighofer
0be00c820e Merge pull request #16608 from aschwaighofer/unique_foreign_type_witnesses
Unique synthesized foreign type witnesses and make witness tables part of the metadata cache key
2018-05-17 07:35:10 -07:00
swift-ci
14cddf5cd6 Merge remote-tracking branch 'origin/master' into master-next 2018-05-14 15:08:49 -07:00
Erik Eckstein
915391ee99 IRGen: don't emit metadata lazily in JIT mode.
We already do this for witness tables, but the check was missing for metadata.
This problem caused unresolved symbols when interpreting with -O.

rdar://problem/40128897
2018-05-14 14:07:19 -07:00
Arnold Schwaighofer
b83941795a Unique synthesized foreign type conformances
- Add swift_getForeignWitnessTable to unique non-unique foreign type
   witness tables

 - IRGen: Call the foreign witness uniquing runtime function

rdar://24958043
2018-05-14 13:52:41 -07:00
swift-ci
ebc2c0e05a Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 19:49:11 -07:00
Vedant Kumar
bdfd220968 [Coverage] Mark symtab entries as guaranteed after intrinsic lowering
SIL optimizations may rewrite profiling intrinsics in a way that IRGen
can't lower (r://39146527). Don't claim that a coverage mapping has a
guaranteed associated symbol table entry when this happens.

I have not added a test, as this is a defensive workaround until we can
land add a SIL verifier check that prevents profiling intrinsics from
being rewritten.

rdar://40133800
2018-05-10 18:51:40 -07:00
swift-ci
908dbfed4a Merge remote-tracking branch 'origin/master' into master-next 2018-05-10 02:09:07 -07:00
Slava Pestov
51ece23422 IRGen: Fix enum lowering with -enable-resilience-bypass
The layout of an enum type will only use spare bits if the
payload types have a fixed size in all resilience domains
where they are visible. In practice, this means that:

- If the enum is internal or resilient, we can use spare bits
  if the payload types are fixed size from inside the current
  module.

- If the enum is public and not resilient, we can use spare bits
  if the payload types are fixed size from all resilience
  domains.

The bug was that the 'fixed size in all resilience domains'
check was returning true for resilient types when the
-enable-resilience-bypass flag was on. This is wrong, because
this meant that building a module with and without
-enable-resilience-bypass could produce different lowerings
for enum types.

Fixes <rdar://problem/40034143>.
2018-05-10 00:56:15 -04:00
swift-ci
28f97c08ca Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 10:09:45 -07:00
Adrian Prantl
2c7a69852b Emits a DW_OP_deref for global variables in a fixed size buffer.
Note that this is only correct unless the variable uses inline
storage. This makes the majority of resilient types in Foundation work
as global variables.  The correct solution would be for LLDB to poke
at the runtime to figure out whether the storage is inline or not, but
until then this is the next best thing.

rdar://problem/39722386
2018-05-02 15:40:16 -07:00
swift-ci
cd0fd541ae Merge remote-tracking branch 'origin/master' into master-next 2018-04-23 13:29:24 -07:00
Saleem Abdulrasool
4cdddedddb IRGen: avoid implicit conversion from IGM to UniversalLinkInfo
This just makes the conversion an explicit operation.  This makes it
easier to see what is being invoked.  NFC.
2018-04-23 11:17:33 -07:00
swift-ci
44b4be86f4 Merge remote-tracking branch 'origin/master' into master-next 2018-04-20 08:27:12 -07:00
Andrew Trick
abab49e54c Support exclusivity enforcement of KeyPath read-only access.
Use begin_unpaired_access [no_nested_conflict] for
Builtin.performInstantaneousReadAccess. This can't be optimized away
and is the proper marker to use when the access scope is unknown.

Drop the requirement that
_semantics("optimize.sil.preserve_exclusivity") be @inline(never). We
actually want theses inlined into user code. Verify that the
@_semantic functions are not inlined or otherwise tampered with prior
to serialization.

Make *no* change to propagate @inline(__always) into LLVM. This no longer has
any relationship to this PR and can be investigated seperately.
2018-04-19 22:46:10 -07:00
Michael Gottesman
e58fdc81fc [Exclusivity] Add support for semantics tag "optimize.sil.preserve_exclusivity".
This is a special @_semantics attribute that preserves exclusivity even if we
are eliminating exclusivity in other parts of a module in release mode. This is
done by:

1. Teaching the Access Marker Elimination pass to skip any function with the
semantics tag.

2. Requiring all functions with the semantics tag to be noinline. This ensures
that the SIL level inliner will not inline these functions into any callers
without the protection of the semantics tag. This is enforced in IRGenPrepare
and ensures that our access markers will live to IRGen time.

3. In IRGenPrepare, we convert these functions from noinline to always
inline. After IRGen this then allows for the LLVM inliner to inline these
trivial functions that just perform the exclusivity checks ensuring that we do
not have extra calls in the fast path.

This ensures that we can fix the keypaths exclusivity issue without having to
enable exclusivity across the entire stdlib and deal with any of the potential
performance issues therein.

rdar://39335800
2018-04-19 21:37:12 -07:00
swift-ci
b95dd21966 Merge remote-tracking branch 'origin/master' into master-next 2018-04-17 06:29:07 -07:00
Mike Ash
309c7f7634 Merge pull request #15828 from mikeash/fix-asan-metadata
[IRGen] Blacklist metadata globals from address sanitizer.
2018-04-17 06:19:14 -07:00