Commit Graph

225 Commits

Author SHA1 Message Date
Joe Groff 53792aa64e IRGen: Make outlined enum copy/destroy lazier and better mangled.
Emit enum copy/destroy methods only when codegen demands them; they previously got emitted immediately when TypeInfo is instantiated, which led to many functions getting emitted that were never used. Also, make it so that the symbol name includes the full type of the enum instance the outlined functions operate on, so it's more obvious what they'e being used for and they can be ODRed across translation units.
2018-03-11 11:04:41 -07:00
Joe Groff f01af883fc IRGen: Use known value witness tables for common type layouts.
If a type has the same layout as one of the basic integer types, or has a single refcounted pointer representation, we can use prefab value witness tables from the runtime instead of instantiating new ones. This saves quite a bit of code size, particularly in the Apple SDK overlays, where there are lots of swift_newtype wrappers and option set structs.
2018-03-11 11:04:37 -07:00
Sho Ikeda cea6c03eb2 [gardening] Use !empty() over size() > 0 2018-03-08 09:21:09 +09:00
Sho Ikeda 26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
Pavel Yaskevich 94017f7ee7 [IRGen] Remove 'FieldNames' field from type context descriptor
All of the information contained by this field (list of property names)
is already encoded as part of the field reflection metadata and
is accessible via `swift_getFieldAt` runtime method.
2018-02-20 18:49:00 -08:00
Pavel Yaskevich 8bc7ba2239 [IRGen] Don't generate field reflection metadata for opaque struct/enum
One of my previous commits did that, but since we have Builtins reflection
section we don't really want to generate reflection field metadata for
opaque structs/enums. This reverts to the previous behavior.
2018-02-20 18:20:09 -08:00
Pavel Yaskevich 877c70bae9 [Runtime/Metadata] Add support for dynamic field descriptor registration 2018-02-20 18:20:09 -08:00
Jordan Rose 01f9fc76b5 Merge pull request #12778 from linux-on-ibm-z/master-s390x-fixes
Fixes for s390x
2018-01-22 09:44:36 -08:00
swift-ci 6ec935af06 Merge pull request #14026 from aschwaighofer/irgen_fix_ub_shift 2018-01-19 10:34:28 -08:00
Arnold Schwaighofer c842c34d2e IRGen: Shift by more-or-equal than num bits of type is undefined behavior
Caught by ubsan.
rdar://36649637
2018-01-19 09:26:50 -08:00
Joe Shajrawi 1e5e49a5d5 [IRGen] Fix a bug in multi-payload’s enum collectArchetypeMetadata: all payloads might not contain archetype but the enum itself might still be dynamically sized 2018-01-18 15:59:04 -08:00
Vivian Kong 9d0730d876 Fix packing enum payloads on big endian 2018-01-15 08:54:56 -05:00
John McCall 9bbbe2c418 Update the metadata-initialization ABI:
- Create the value witness table as a separate global object instead
  of concatenating it to the metadata pattern.

- Always pass the metadata to the runtime and let the runtime handle
  instantiating or modifying the value witness table.

- Pass the right layout algorithm version to the runtime; currently
  this is always "Swift 5".

- Create a runtime function to instantiate single-case enums.

Among other things, this makes the copying of the VWT, and any
modifications of it, explicit and in the runtime, which is more
future-proof.
2017-12-21 00:26:37 -05:00
Joe Shajrawi 5be50d75fc Fixes an invalid assert in No Payload Enum's collectArchetypeMetadata: the type itself might contain an Archetype. We need to check that it is not an Archetype itself 2017-12-04 16:26:36 -08:00
Joe Shajrawi 6ee370bcba Merge pull request #13004 from shajrawi/noinline_enum_outlined_funcs
Code Size: mark enum's outlined retain/releases as no inline
2017-11-17 19:18:07 -08:00
Joe Shajrawi 763e7ca99c mark enum's outlined retain/releases as no inline 2017-11-17 17:06:24 -08:00
Joe Shajrawi d8289aa3ec Code size: destroy_addr outline 2017-11-17 16:10:27 -08:00
Joe Shajrawi f6781deaf8 copy_addr outline: cleanups based on review 2017-11-16 23:19:33 -08:00
Joe Shajrawi 67f2852ef2 Code Size: copy_addr cleanup - get rid of mightContainMetadata 2017-11-15 15:28:29 -08:00
Joe Shajrawi 62d823c56d Code size: Do not use a global state for isOutlined 2017-11-15 15:28:27 -08:00
Joe Shajrawi 5aff0891b7 Code size: copy_addr outline part 2 - Support Archetypes 2017-11-15 15:26:44 -08:00
Joe Shajrawi 18b0240f02 Outline copy_addr part 1 clean-up: Remove Enum's TIK < Loadable check - archetype check covers it 2017-11-15 15:24:16 -08:00
Joe Shajrawi 8c67caa5c6 Merge pull request #12687 from shajrawi/outline_copyddr
Code Size: Outline copy addr instruction
2017-11-01 10:47:11 -07:00
Arnold Schwaighofer 865d85bd1c Reapply the enum value witness patch
Revert "Revert "Merge pull request #12606 from aschwaighofer/single_payload_enum_witness""

This reverts commit c422f80307.
2017-10-31 17:28:15 -07:00
Joe Shajrawi f4db36426c Code Size: Outline copy addr instruction 2017-10-31 17:03:48 -07:00
Arnold Schwaighofer c422f80307 Revert "Merge pull request #12606 from aschwaighofer/single_payload_enum_witness"
This reverts commit 0b414e45c5, reversing
changes made to fb27e7d32a.

There are failures on the resilient bot and lldb test case fails.
2017-10-31 08:24:26 -07:00
Arnold Schwaighofer 43b9d13a2e Add value witnesses for single payload enums
So far single payload enums were implemented in terms of runtime functions which
internally emitted several calls to value witnesses.

This commit adds value witnesses to get and store the enum tag side stepping the
need for witness calls as this information is statically available in many cases

/// int (*getEnumTagSinglePayload)(const T* enum, UINT_TYPE emptyCases)
/// Given an instance of valid single payload enum with a payload of this
/// witness table's type (e.g Optional<ThisType>) , get the tag of the enum.

/// void (*storeEnumTagSinglePayload)(T* enum, INT_TYPE whichCase,
///                                   UINT_TYPE emptyCases)
/// Given uninitialized memory for an instance of a single payload enum with a
/// payload of this witness table's type (e.g Optional<ThisType>), store the
/// tag.

A simple 'for element in array' loop in generic code operating on a
ContigousArray of Int is ~25% faster on arm64.

rdar://31408033
2017-10-23 13:31:46 -07:00
swift-ci 187c7f7ef2 Merge remote-tracking branch 'origin/master' into master-next 2017-08-01 14:29:04 -07:00
Robert Widmann 2823a6960f Properly interpolate negative AP literals
Integer and Floating literals are aware of their negation but
do not store the sign in the text of the value.  Retrieve the
sign bit and properly interpolate the text of the literal value
with it to distinguish negative and positive literals.
2017-08-01 09:48:53 -07:00
Greg Parker 7b009eccde Merge remote-tracking branch 'origin/master' into master-next 2017-06-28 15:25:17 -07:00
Arnold Schwaighofer a2dbf7c3a6 IRGen: Use the right mangling function for outlined multipayload consumes 2017-06-26 14:36:14 -07:00
swift-ci 1378be1c6d Merge remote-tracking branch 'origin/master' into master-next 2017-05-01 15:55:31 -07:00
Joe Shajrawi 0d0cac357a retain_value_addr and release_value_addr SIL instructions: take as an input an address, load the value inside it and call retain_value and release_value respectively 2017-04-30 10:23:55 -07:00
swift-ci cdde06ac25 Merge remote-tracking branch 'origin/master' into master-next 2017-04-27 15:56:02 -07:00
Arnold Schwaighofer ba0299bf0c IRGen: Enums - Use memcpy for indirectly primitive copying fixed size types
There is no value in exploding the schema. Exploding the schema only increases
code size for large enums.

rdar://31685718
2017-04-21 16:56:53 -07:00
Bob Wilson 810dc0d43e Replace uses of llvm::integerPart to match llvm r299341.
LLVM r299341 removed the llvm::integerPart typedef and replaced it
with llvm::APInt::WordType. The integerPartWidth constant was replaced
by llvm::APInt::APINT_BITS_PER_WORD.
2017-04-03 13:13:16 -07:00
Saleem Abdulrasool 15565c116a Adjust for SVN r298393 2017-03-22 07:44:03 -07:00
Slava Pestov 162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07:00
Erik Eckstein 41c17a5b0c IRGen: emit type metadata and (value) witness tables lazily.
This gives big code size wins for unused types and also for types, which are never used in a generic context.
Also it reduces the amount of symbols in the symbol table.
The size wins heavily depend on the project. I have seen binary size reductions from 0 to 20% on real world projects.

rdar://problem/30119960
2017-03-10 12:50:43 -08:00
Mikio Takeuchi 488d531846 Enhance -assume-single-threaded option (SR-3945) 2017-02-27 12:17:53 +09:00
Arnold Schwaighofer 39fa2f0228 Use the swift calling convention for swift functions
Use the generic type lowering algorithm described in
"docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion
type to the type expected by the ABI.

Change IRGen to use the swift calling convention (swiftcc) for native swift
functions.

Use the 'swiftself' attribute on self parameters and for closures contexts.

Use the 'swifterror' parameter for swift error parameters.

Change functions in the runtime that are called as native swift functions to use
the swift calling convention.

rdar://19978563
2017-02-14 12:17:57 -08:00
Hugh Bellamy f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Slava Pestov dca292c652 Serialization: Don't serialize contextual enum argument type
Storing this separately is unnecessary since we already
serialize the enum element's interface type. Also, this
eliminates one of the few remaining cases where we serialize
archetypes during AST serialization.
2017-01-30 00:08:53 -08:00
Arnold Schwaighofer 1f914eb4c4 Silence warn_unused_result warnings 2017-01-18 15:20:27 -08:00
practicalswift 6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Joe Shajrawi ee5ed7bdc6 [IRGen] Code Size Reduction: Outline Copy/Consume (Loadable) Enum 2016-12-22 17:08:15 -08:00
practicalswift 38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
Michael Gottesman 9189c5eb65 [gardening] Initialize pointer with nullptr. Found with clang-tidy.
It is technically assigned into dynamically in the loop below, but given
code-refactoring, this invariant could easily be broken yielding a use of an
uninitialized pointer. Better to just initialize and assert.
2016-12-06 23:54:49 -08:00
Hugh Bellamy 1aa951dfb2 Fix errors and warnings building swift/IRGen on Windows using MSVC (#5958) 2016-11-30 13:27:02 -08:00
practicalswift 797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00