Commit Graph

752 Commits

Author SHA1 Message Date
swift-ci
89372f876a Merge remote-tracking branch 'origin/master' into master-next 2019-04-18 15:10: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
swift-ci
707344affa Merge remote-tracking branch 'origin/master' into master-next 2019-04-12 07:29:33 -07: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
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
Mishal Shah
345e9881d1 Merge pull request #22699 from apple/stable-update-5.1
Update Swift:master to work with new stable re-branch from swift-5.1-branch
2019-02-20 12:22:00 -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
Saleem Abdulrasool
437cfa7fa2 IRGen: adjust for SVN r348827
CodeGenOptions.h was moved from Frontend to Basic.
2019-02-08 14:22:57 -08:00
Saleem Abdulrasool
6a1072d825 Adjust for SVN r352827
Update for `getOrInsertFunction` API in LLVM.
2019-02-04 12:48:46 -08:00
swift-ci
535b711531 Merge remote-tracking branch 'origin/master' into master-next 2019-01-04 15:29:24 -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
Saleem Abdulrasool
02dfb509ba IRGen: create new External{Im,Ex}port named linkages
Create two new semantic names: `ExternalImport` and `ExternalExport`.
These are for symbols which are either imported from an external module
or exported for consumption by external modules.
2019-01-04 10:39:03 -08:00
Saleem Abdulrasool
9546cc2413 IRGen: always provide DLLStorage
Now that DLLStorage is only applied when needed, always pass the correct
DLLStorage.  The IRLinkage applicator will determine if the DLLStorage
should be applied or not.
2019-01-04 10:39:03 -08:00
Saleem Abdulrasool
a6df0469cf IRGen: create InternalWeakODR named IRLinkage (NFC)
Create a new named IRLinkage type: `InternalWeakODR`.  This just gives
the IRLinkage a semantic name rather than the computed value.  NFC.
2019-01-04 10:39:03 -08:00
swift-ci
c2e98d3097 Merge remote-tracking branch 'origin/master' into master-next 2019-01-04 08:50:02 -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
swift-ci
247d0fb84e Merge remote-tracking branch 'origin/master' into master-next 2019-01-02 21:50:10 -08:00
Saleem Abdulrasool
e6354fe206 IRGen: COMDAT the force load thunks
Use `ApplyIRLinkage` to the force load thunks to permit multiple
emissions to be COMDATed on Windows.  The multi-module tests would emit
the symbols multiply and would fail to link.
2018-12-27 18:43:28 -08:00
swift-ci
bd421dcd97 Merge remote-tracking branch 'origin/master' into master-next 2018-12-20 18:15:07 -08:00
Slava Pestov
0c6ac60688 IRGen: Don't deserialize witness tables accidentally
This is actually NFC: We should have already deserialized everything
we need at this point, and because of large loadable types and
address lowering, deserializing more stuff in IRGen is not valid,
and in fact we check for this and refuse to deserialize.
2018-12-20 17:36:38 -05:00
swift-ci
8561c0367b Merge remote-tracking branch 'origin/master' into master-next 2018-12-11 22:49:14 -08:00
Saleem Abdulrasool
49b9449d8b IRGen: adjust for SVN r348827
CodeGenOptions.h was moved from Frontend to Basic.
2018-12-11 21:40:04 -08:00
John McCall
2ba7090fe8 Remove the extra-inhabitant value witness functions.
This is essentially a long-belated follow-up to Arnold's #12606.
The key observation here is that the enum-tag-single-payload witnesses
are strictly more powerful than the XI witnesses: you can simulate
the XI witnesses by using an extra case count that's <= the XI count.
Of course the result is less efficient than the XI witnesses, but
that's less important than overall code size, and we can work on
fast-paths for that.

The extra inhabitant count is stored in a 32-bit field (always present)
following the ValueWitnessFlags, which now occupy a fixed 32 bits.
This inflates non-XI VWTs on 32-bit targets by a word, but the net effect
on XI VWTs is to shrink them by two words, which is likely to be the
more important change.  Also, being able to access the XI count directly
should be a nice win.
2018-12-11 22:18:44 -05:00
Carl Peto
3d61e9fd5a Fix incompatibilities with 16 bit pointers
- fix code generation for enum types to zext or trunc 32 bit data as appropriate for the platform
- fix IR generation code to use a relative address type of 16 bit width on that platform

- correct order of statements and line up comments
2018-11-29 22:15:54 +00:00
Daniel Dunbar
1efee0c27a [Swift+WASM] Allow Wasm object format.
- This currently does nothing more than adopt the ELF conventions, but for the
   Wasm object file format.
2018-11-20 15:22:26 -07:00
John McCall
2de83cfccb Merge pull request #20607 from rjmccall/self-protocol-conformance
Support the explicit representation of self-conformances
2018-11-15 17:38:44 -05:00
John McCall
5553224fd4 Support the explicit representation of self-conformances.
Big, but actually NFC because we're never actually creating them.
2018-11-15 16:42:03 -05:00
Mike Ash
0262f1dd67 [IRGen] Record the Swift major/minor version in the top two bytes of the objc_image_info flags field.
rdar://problem/44204568
2018-11-15 12:05:22 -05:00
Arnold Schwaighofer
152e8db8bb IRGen and runtime implementation for dynamic replacements 2018-11-06 09:58:36 -08:00
Arnold Schwaighofer
ebbe3aed1c IRGen: Add implementation for dynamically replaceable functions
A dynamically replaceable function calls through a global variable that
holds the function pointer.

struct ChainEntry {
   void *(funPtr)();
   struct ChainEntry *next;
}

ChainEntry dynamicallyReplaceableVar;

void dynamicallyReplaceableFunction() {
  dynamicallyReplaceableVar.funPtr()
}

dynamic replacements will be chainable so the global variable also
functions as the root entry in the chain of replacements.

A dynamic replacement functions can call the previous implementation by
going through its chain entry.

ChainEntry chainEntryOf_dynamic_replacement_for_foo;

void dynamic_replacement_for_foo() {
   // call the previous (original) implementation.
   chainEntryOf_dynamic_replacement_for_foo.funPtr();
}
2018-11-06 09:53:21 -08:00
John McCall
cf511445e2 Basic support for Builtin.IntegerLiteral. 2018-10-31 18:42:34 -04:00
John McCall
0bb884546b Add a runtime interface for working with Builtin.IntegerLiteral values. 2018-10-31 04:58:18 -04:00
Erik Eckstein
73aabff8a2 IRGen: lazily emit shared witness tables
This avoids emitting synthesized witness tables if they are not needed.
2018-10-10 08:24:26 -07:00
Jordan Rose
d412f4b4ba [IRGen] Adopt std::unique_ptr for IRGenDebugInfo (#19369) 2018-09-18 11:10:10 -07:00
Slava Pestov
870c58e017 IRGen: Change method descriptor layout to be consistent with protocol requirements
Both now have a flags field followed by the implementation.
2018-09-04 14:46:34 -07:00
Slava Pestov
b7449d5621 IRGen/Runtime: Method override descriptors 2018-09-04 14:46:34 -07:00
Slava Pestov
44c4497ac5 IRGen/Runtime: Protocol requirement descriptors don't need to reference the dispatch thunk 2018-08-31 00:16:22 -07:00
Jordan Rose
d52dad3732 [IRGen] Extract getConformance from ProtocolInfo (#18681)
We were using this just as a convenient way to share an existing
DenseMap, but it's not really related; we don't need to compute
witness table layout just to generate a conformance reference.

I started working on this because the "Cub" source compat project was
hitting issues here, but now I can't reproduce it. Still, this is a
reasonable cleanup.
2018-08-13 17:16:41 -07:00
John McCall
436a8b273d Add runtime functions to compute tuple layouts from element layouts.
Previously, when a tuple type had non-fixed layout, we would compute
a layout by building the metadata for that tuple type and then
extracting the layout from the VWT.  This can be quite expensive
because it involves constructing the exact metadata for types like
arrays and functions despite those types being fixed-layout across
all instantiations.  It also tends to cause unnecessary recursive-type
issues, especially with enums where tuples are currently used to model
cases with mutliple payloads.  Since we just need a layout, computing
it directly from element layouts instead of constructing metadata for
the formal type lets us take advantage of all the other fast paths for
layout construction, e.g. for fixed types and single-field aggregates.

This is a good improvement overall, but it also serves to alleviate
some of the problems of rdar://40810002 / SR-7876 in a way that
might be suitable for integration to 4.2.
2018-07-29 18:27:27 -04:00
David Zarzycki
057bbb366a [IRGen] Adopt reference storage type meta-programming macros
This commit also fixes reference storage extra inhabitant bugs.
2018-06-30 11:48:47 -04:00
Ellis Hoag
c93a5a5776 Add -debug-info-format=[dwarf|codeview] option (#16888) 2018-06-20 09:52:57 -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
Arnold Schwaighofer
81a15fbe19 IRGen: Use clangs's LLVM datalayout
It knows better ...

rdar://40275689
2018-05-25 11:19:01 -07:00
Huon Wilson
cfc5abdaa2 [TBDGen] Emit the symbol for autolink-force-load-ing.
Fixes rdar://problem/40356032.
2018-05-23 10:56:49 +10:00
Saleem Abdulrasool
fc9de0deaf IRGen: adjust the module hash section for COFF
COFF uses 8-character section names.  Adjust the section name for the
module hash from `.swift_modhash` to `.sw5hash` to fit this restriction.
2018-05-02 17:42:56 -07:00
Jordan Rose
6af333f307 [IRGen] Be smarter about adding the FORCE_LINK symbols for overlays (#15647)
We use dummy symbols to force overlays not to get dropped when
autolinking, even if the user doesn't use anything from them
explicitly. This behavior is triggered by the semi-hidden flag
-autolink-force-load.

(It's semi-hidden because it has few legitimate uses in real life. If
you searched for "how to force autolinking to pick up a library" and
found this commit, don't just do this and move on. Come talk to me on
forums.swift.org.)

Previously we added these dummy symbols to every object file using
"common" linkage, a little-known feature added for C that ensures that
only one definition will actually get used in the final object file.
However, the way we were doing that wouldn't work so well for COFF,
and so in 1025eed64 Saleem changed this to use "weak ODR" linkage.
This has *nearly* the same effect, and avoids some other weirdness,
but has the downside of making the symbol in the final dylib "weak"
itself, meaning that some /other/ library could come along and
override it. That impacts loading time, and an Apple-internal tool
caught that as rdar://39019606.

To avoid this whole mess, "just" emit the symbol into the object file
that corresponds to the first file in the module, which allows us to
mark it as a normal public symbol.

P.S. None of this is actually important at the moment because all of
the overlays are built with single-threaded WMO, which always produces
one object file anyway. But I wanted to get it right once and for all.
2018-03-31 15:20:13 -07:00