Now that the stack allocation for an abstraction change is in a predictable place, we can cleanly deallocate it at the end of dispatch. Fixes <rdar://14835992>.
Swift SVN r10024
In SILGen, when we emit the enum external definition, emit the methods in addition to the case constructors for the enum. Make sure they get thunk linkage.
Swift SVN r10017
Previously, the Parser and BranchStmt typedef-ed ExprStmtOrDecl as a pointer union. Using typedef made the objects compatible, but did not allow us to extend the type with helper methods, such as getSourceRange(), which is something you can get on all of the AST objects. This patch introduces ASTNode that subclasses from PointerUnion and is used by both parser and BranchStmt.
Swift SVN r9971
<rdar://problem/14835992> happens because, when we emitted a chain of checked casts for 'is' patterns in a 'switch', we would emit abstraction changes for each individual cast that required them. This is both redundant and makes cleaning up messier, because the number of branches with different stack heights increases. Instead, let's emit one abstraction change up front for all of the casts. No functionality change yet, but this is a step on the way to fixing <rdar://problem/14835992>.
Swift SVN r9921
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few. If you find something, please
let me know.
rdar://15346654
Swift SVN r9886
When destructuring the 'is Int' pattern in:
func f<T, U>(t: T, u: U) {
switch t {
case is Int: println("Int")
case is U: println("U")
case _: println("other")
}
}
there is the possibility that 'U' is 'Int', so it needs to be included in the specialization on 'is Int' using a concrete-to-archetype cast from Int to U. This wasn't handled correctly and we tried to do a super-to-archetype class cast instead, which blew up because 'Int' is neither a class nor statically related to U. Fixes <rdar://problem/14826416>.
Swift SVN r9869
Ideally this wouldn't be necessary, but the type substitution APIs required by generic specialization and SIL verification currently require a Module* pointer, and it's obnoxious to have to pass it down separately everywhere it's needed. Longer-term the reliance on Modules for type substitution might be able to go away.
Swift SVN r9866
If a local function tried to reference a local typealias, we were trying to emit a SIL variable reference and freaking out, causing <rdar://problem/15360605>. For now, don't emit any capture arguments for local typealiases. Any context a local typealias requires should be handled by capturing the external context's generic parameters.
Swift SVN r9865
Whatever kind of Swift decl we cons up for a Clang enum, add it to the externals list so we can pick it up and emit Swift metadata for it in IRGen. Fixes <rdar://problem/15242452>.
Swift SVN r9801
The empty tuple used for return value when none is supplied does not really correspond to user code. (We don’t have epilog, so mark it as pert of cleanup.)
The destroy_addr instructions are doing the cleanup.
Swift SVN r9765
so they can be easily identified by the inout deshadowing pass. This does
not mark the alloc_box as autogenerated though, since it is a user variable
when the variable escapes.
- Fix some wonky indentation in SILLocation.
Swift SVN r9700
Introduces a new flag in SILLocation: InPrologue to mark instructions
that setup the stack and allocate storage for local variables/arguments.
Fixes rdar://problem/15290023: Breakpoint set on prologue - crash ensues.
Swift SVN r9686
Anywhere that assumes a single input file per TU now has to do so explicitly.
Parsing still puts all files in a single SourceFile instance; that's next on
the list.
There are a lot of issues still to go, but the design is now in place.
Swift SVN r9669
Once we've opened method references via the interface type, we then
fold all levels of generic argument specialization into the
DeclRefExpr, rather than using SpecializeExpr. For reference, the call
to x.f in this example:
struct X<T> {
func f<U>(u : U) { }
}
func honk(x: X<Int>) {
x.f("hello")
}
goes from this double-specialized AST:
(specialize_expr implicit type='(u: String) -> ()'
(with U = String)
(dot_syntax_call_expr type='<U> (u: U) -> ()'
(specialize_expr implicit
type='(@inout X<Int>) -> <U> (u: U) -> ()'
(with T = Int)
(declref_expr type='<T> @inout X<T> -> <U> (u: U) -> ()'
decl=t.X.f@t.swift:2:8 specialized=no))
to the cleaner, SpecalizeExpr-free:
(dot_syntax_call_expr type='(u: String) -> ()'
(declref_expr type='(@inout X<Int>) -> (u: String) -> ()'
decl=t.X.f@t.swift:2:8 [with T=Int, U=String]
specialized=no)
which handles substitutions at both levels together. The minor SILGen
tweak
Note that there are numerous other places where we are still generated
SpecializeExprs.
Swift SVN r9614
We already know how to call external functions in SILGen, why reimplement all that in IRGen? Instead of representing the thunk operation as a SIL instruction, let's just emit the thunk using existing SILGen machinery. Fixes <rdar://problem/14097136>.
Swift SVN r9576
And tweak the verifier to allow 'convert_cc' over a static FunctionRefInst to remain thin. The SILGen part of <rdar://problem/14097136>.
Swift SVN r9556
Rather than wrapping a DeclRefExpr in a SpecializeExpr for a reference
to a generic free function, just use the substitutions stored within
the DeclRefEXpr. Such DeclRefExprs will always have a concrete
type. One tiny nail in the SpecializeExpr coffin.
Swift SVN r9539
When destructuring a NominalTypePattern, keep the aggregate around as an extra column of the destructured matrix so we can still match non-NominalTypePatterns against it. This handles 'is T' patterns on the same type, and should also handle other fancy high-level patterns we might add in the future.
Swift SVN r9538
According to Maranget this heuristic gave the best results over a large corpus of Ocaml code. Luckily, it's really easy to implement too—just count through each column until we hit a wildcard, and specialize on the column with the most non-wildcard pattern nodes before a wildcard.
Swift SVN r9533
If we see nominal type patterns in a switch column, grab all of the needed properties for all of the patterns when destructuring so we only need to do it once. For now, only handle stored properties. John's in the middle of reinventing the world for SIL functions and I don't want to create merge problems.
There's an issue handling the temporary allocation for address-only properties that I don't have time to address right now but will fix soon.
Swift SVN r9520
Give ClauseMatrix a dump method that gives nice columnar output of the current decision matrix, and add DEBUG output to emitSwitchStmt so there's more visibility into decision tree generation.
Swift SVN r9519
location rather than a regular location to avoid the linetable jumping
back to the beginning of the function.
Add a large number of testcases that check the sanity of the return
locations in various scenarios involving implicit/explicit returns,
cleanups, and multiple return locations per function.
rdar://problem/14845534
Swift SVN r9511