The current implementation of dealloc_stack in IR-gen is a
no-op, but that's very much wrong for types with non-trivial
local allocation requirements, e.g. archetypes. So we need
to be able to do non-trivial code here. However, that means
modeling both the buffer pointer and the allocated address
in SIL.
To make this more type-safe, introduce a SIL-specific
'[local_storage] T' type that represents the required
allocation for locally storing a T. alloc_stack now returns
one of those in additon to a *T, and dealloc_stack expects
the former.
IR-gen still implements dealloc_stack as a no-op, but
that's now easy to fix.
Swift SVN r6937
The issue is truly diagnosed in SILGen and an unreachable instruction is
inserted in cases where the switch is not fully covered. However, we issue
the diagnostic later on in DataflowDiagnostics pass.
John has suggested that it's best to diagnose this after DCE because
we should not warn in cases where the switch is not fully covered,
but we can show that the non-covered cases are not reachable.
Swift SVN r6929
In SILParser, factor out lookupTopDecl and lookupMember.
lookupTopDecl finds the top-level ValueDecl or Module given a name and
lookupMember finds the ValueDecl given a type and a member name.
Update comments for parseSILDeclRef to match SIL.rst.
We now handle the case where the first component of a dotted path is a
module.
In SILPrinter, print the full path for builtin_function_ref, also
"!" is optional when printing SILDeclRef.
Swift SVN r6926
definite initialization, promoting boxes to stack, building ssa, and doing definite
initialization.
I'll build this in place, then kill off the other two passes when this subsumes them.
Swift SVN r6903
capture analysis is gone. This functionality is subsumed by SIL passes,
which turn boxes into stack allocations.
One minor detail of this is that dealloc_ref isn't implemented yet in IRGen
(rdar://14648382) and SILGen produces it for destructors (e.g. see
test/SILGen/lifetime.swift). To unblock progress, I just removed the
llvm_unreachable in IRGen.
Swift SVN r6890
cause an existential to escape. This (in conjunction with Joe's
patch to SILGen) allows us to handle the protocol case that the
old capture analysis was able to promote.
Swift SVN r6882
Have project_existential return $*This instead of $Builtin.OpaquePointer, and have protocol_method do the same for methods of opaque protocols. This makes it easier for passes to reason about the semantics of the projected address, since it's restricted by the semantics of SIL addresses.
Swift SVN r6872
Build a switch_union instruction over all the matched union elements, and check for exhaustiveness to see if we need to emit a default branch either for subsequent matches or to fall off the end and emit unreachable if we run out of cases.
Swift SVN r6870
Create a separate TERMINATOR xmacro in SILNodes.def that only expands for terminators. Use it in TermInst::getSuccessors to automatically delegate to leaf terminator getSuccessors implementations without requiring additional maintenance work when new terminator instructions are added in the future.
Swift SVN r6869
Since in SIL the basic blocks do not store the incoming arguments
(no PHI-nodes), the successor's arguments do not need to be adjusted
when predecessor drops the terminator instruction.
Swift SVN r6863
Emit the dispatch tree up-front instead of interleaving it with specializations. This doesn't have any user-visible effect yet, but will allow for dispatch to use switch-like instructions such as switch_oneof when appropriate.
Swift SVN r6847
As per code review discussion for r 6763.
The memory behavior enumeration is currently a subset of what it could be. Let’s add more kinds as needed.
Swift SVN r6830
Added types when printing these args in the SIL printer.
As a side effect, I've removed the assertions that check
that we have the correct number of arguments in the Branch instruction
creation routines. The reason is that we do not have a complete block when
parsing and creating the branch instruction and it is possible to add
arguments to a basic block after creation. The assertion will be checked
by the SIL verifier.
Swift SVN r6818
We need to handle three cases:
- If a protocol conformance has no associated types, or the associated type witnesses all have statically resolvable metadata, we can expose a *direct* witness table symbol.
- If a protocol conformance has associated types with runtime-instantiated metadata, we need to gate the witness table behind a *lazy* initializer function to fill in the metadata fields.
- If a protocol conformance has associated types where the type or one of its conformances are *dependent* on its parent's generic parameters, we need to instantiate multiple witness tables at runtime.
Swift SVN r6805
The epilog BB not taking an argument is enough by itself to determine whether we are allowed to fall into it; address-only returns do not use a BB argument to return. Break 'NeedsReturn' back out into its own bit and set it based on the Swift type passed to prepareEpilog.
Swift SVN r6802
Modules can be in either 'Raw' or 'Canonical' form, with different invariants on each. We don't actually distinguish those invariants yet, but this patch adds the field to SILModule and adds a "sil_stage" declaration to SIL printer/parser syntax.
Swift SVN r6793
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!
Swift SVN r6783
Funnel all top-level cleanups and returns through a single epilog block instead of re-emitting the cleanups and returns for every 'return' statement like an idiot.
This has some interesting interactions with other features that need additional work:
- ReturnInst's SILLocation is no longer naturally associated with a single source location, which complicates return analysis diagnostics. For now, I just save the location of the first ReturnStmt we see and tag the ReturnInst with that, but we should do better.
- We still duplicate cleanups below the top level like chumps. I still need to resurrect the CleanupOutflows stuff from the old IRGen backend.
- A DebugInfo test breaks. Adrian will have to look into that.
Swift SVN r6782
For nontrivial, non-address-only types, we want definitive analysis to be able to recognize destruction of unused, uninitialized variables without barfing on an apparent load of an uninitialized value. Definitive analysis will be responsible for canonicalizing destroy_addr to loads + releases for values where we can do so.
Swift SVN r6771