Commit Graph

19 Commits

Author SHA1 Message Date
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Slava Pestov
b2ffac54d3 IRGen: Fulfill pack metadata from tuple metadata
When the SelfMetadata in a witness thunk is the tuple type (repeat each Self),
we can fulfill the pack shape and type metadata for Pack{repeat each Self}
from tuple metadata.

The length is trivially projected; the type metadata pack is slightly more
involved, because tuple metadata stores a list of element/offset pairs, so
we must stack allocate a pack and fill it in.
2023-08-24 17:57:10 -04:00
Slava Pestov
59fd29551e IRGen: Emitting metadata for function types containing pack expansion parameters 2023-08-03 22:12:05 -04:00
Slava Pestov
8dfeeebeb5 IRGen: Support tuple labels in emitDynamicTupleTypeMetadataRef() 2023-07-27 13:39:52 -04:00
Nate Chandler
d1ec1e6693 [IRGen] Dealloc metadata packs on dom frontier.
Deallocate dynamic allocas done for metadata/wtable packs.  These
stackrestore calls are inserted on the dominance frontier and then stack
nesting is fixed up.  That was achieved as follows:

Added a new IRGen pass PackMetadataMarkerInserter; it
- determines if there are any instructions which might allocate on-stack
  pack metadata
- if there aren't, no changes are made
- if there are, alloc_pack_metadata just before instructions that could
  allocate pack metadata on the stack and dealloc_pack_metadata on the
  dominance frontier of those instructions
- fixup stack nesting

During IRGen, the allocations done for metadata/wtable packs are
recorded and IRGenSILFunction associates them with the instruction that
lowered.  It must be the instruction after some alloc_pack_metadata
instruction.  Then, when visiting the dealloc_pack_metadata instructions
corresponding to that alloc_pack_metadata, deallocate those packs.
2023-06-05 08:11:28 -07:00
Nate Chandler
c9f79861f1 [GenPack] NFC: Stack de/alloc traffics in shapes.
When allocating, the shape is computed, and it (its constant value if
any) is needed when deallocating, so return the shape along with the
address.  And when deallocating, accept the shape, which the client
received during allocation, rather than requiring that the caller
compute the fixed size.
2023-06-03 07:30:09 -07:00
Nate Chandler
6e7952b4ad [IRGen] Mask off metadata pack passed to DebugInfo
When a metadata pack is heap allocated, the pointer's LSB is set.
But lldb is expecting a real pointer.  So mask it off.

Companion PR has a test: https://github.com/apple/llvm-project/pull/6961

rdar://110195273
2023-06-03 07:30:09 -07:00
Slava Pestov
8563229c4a IRGen: Fix binding element archetypes when we have concrete pack conformances 2023-03-31 22:18:09 -04:00
Nate Chandler
6378efee04 [IRGen] Bound all reqs of open_pack_element.
Previously, only the element archetypes that corresponded to the
relevant pack generic parameters were bound, and the wtables that were
bound for them were based on looking up what they conform to.  Here, the
requirements of the generic signature are used to find which archetypes
must be bound to metadata and which conformances must be bound to
wtables.
2023-02-16 15:29:45 -08:00
Nate Chandler
da5b5c1ea5 [IRGen] Lowered de/alloc_pack. 2023-02-09 07:24:01 -08:00
Nate Chandler
58954ab405 [IRGen] Added getPackElementSize. 2023-02-07 20:51:03 -08:00
nate-chandler
ddf09369ba Merge pull request #63502 from nate-chandler/variadic-generics/irgen/open_pack_element_witnesses
[IRGen] Bind wtables at open_pack_element.
2023-02-07 20:46:36 -08:00
nate-chandler
1703b93a6d Merge pull request #63424 from nate-chandler/variadic-generics/irgen/witness-table-packs
[IRGen] Emit witness table packs.
2023-02-07 18:13:13 -08:00
Nate Chandler
cd7e675bce [IRGen] Bind wtables at open_pack_element.
Call out to the infrastructure for emitting witness table packs to emit
references to individual witness tables when binding opened archetypes
during open_pack_element.
2023-02-07 12:40:46 -08:00
Nate Chandler
210ef1f75a [IRGen] Emit witness tables for packs.
This mostly mirrors what's already implemented for metadata pack emission.
2023-02-07 10:30:08 -08:00
John McCall
27142e42f6 Add SIL instructions to get and set pack elements 2023-02-07 01:10:15 -05:00
Nate Chandler
a442245925 [IRGen] Lowered open_pack_element. 2023-02-02 12:48:40 -08:00
John McCall
374c202b99 Add SIL instructions to generate pack indices 2023-01-19 23:57:22 -05:00
Slava Pestov
9bc0f2543f IRGen: Metadata pack emission 2022-12-17 04:13:54 -05:00