Commit Graph

138 Commits

Author SHA1 Message Date
Adrian Prantl
5bbe0afb9f Debug info: Properly handle the function prologue in the line table.
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
2013-10-26 00:12:20 +00:00
Anna Zaks
27328ac459 Warn on unreachable code due to a constant condition in a switch over enum.
Swift SVN r9679
2013-10-25 21:55:12 +00:00
Adrian Prantl
5cf8999985 Debug info: some more refactoring for rdar://problem/14845534.
Swift SVN r9571
2013-10-21 23:38:18 +00:00
Adrian Prantl
3fafb6c7e7 Debug info: Make the ret instruction in the function epilogue a cleanup
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
2013-10-19 00:20:44 +00:00
Anna Zaks
4d50044dd8 Add MandatoryInlinedLocation SIL location type.
This will allow us to differentiate from regular inlined code (as in optimization inlining). Some passes(AllocBocToStack) and debug info would be allowed to be more aggressive/preserve less debug info with mandatory inlined code.

Swift SVN r9339
2013-10-15 00:17:51 +00:00
Anna Zaks
f031eeeeb9 [SIL] Improve the comment.
Swift SVN r8733
2013-09-27 20:29:26 +00:00
Adrian Prantl
c4ece4ec9f Revisit scopes and locations in the light of SIL-based transparent inlining.
Swift SVN r8625
2013-09-25 16:14:47 +00:00
Dmitri Hrybenko
429633b18a Let the type checker create implicit DestructorDecls
Improve the type checker to create implicit DestructorDecls, tighten the
assertion in ImplicitReturnLocation::getImplicitReturnLoc(), and add a verifier
check that a class in a type checked AST always has exactly one destructor.

SILGen used to generate a destructor if the class does not have a
DestructorDecl.  SILGen used to put the ClassDecl inside the SILLocation for
the destructor SIL code.  This is not a very clean solution: in this case
ImplicitReturnLocation SILLocations contain ClassDecl, which is surprising.

rdar://14970972 Implicit destructors should have AST nodes


Swift SVN r8498
2013-09-20 17:34:22 +00:00
Dmitri Hrybenko
f2cc4cb303 Rename CapturingExpr -> AbstractClosureExpr
Swift SVN r8299
2013-09-16 21:58:44 +00:00
Dmitri Hrybenko
536ed954ad Remove FuncExpr. Add CaptureInfo to FuncDecl. Introduce AnyFunctionRef.
AnyFunctionRef is a universal function reference that can wrap all AST nodes
that represent functions and exposes a common interface to them.  Use it in two
places in SIL where CapturingExpr was used previously.

AnyFunctionRef allows further simplifications in other places, but these will
be done separately.


Swift SVN r8239
2013-09-14 02:15:48 +00:00
Anna Zaks
6775516a7c [SIL] Propagate [transparent] from decl to apply inst for constructor.
Swift SVN r8225
2013-09-13 23:21:40 +00:00
Dmitri Hrybenko
e08eee270e Move some of SILGen for functions to use FuncDecl instead of FuncExpr
This changes most SILLocations to point to FuncDecls instead of FuncExprs,
thus SIL diagnostics had to be fixed up for this change.


Swift SVN r8132
2013-09-12 00:32:18 +00:00
Anna Zaks
3997330530 [SIL] Remove the redundant secondary AST node.
We don’t use it for anything right now.

Swift SVN r8109
2013-09-11 20:54:33 +00:00
Anna Zaks
e7e3c10fec [SIL] Add appropriate SILLocations to the inlined code.
The inlined locations should point to the call site.

Swift SVN r8108
2013-09-11 20:54:31 +00:00
Anna Zaks
39b7a43cc0 [SIL] Mark locations of implicit constructors/destructors as auto-generated.
(Also, renames getArtificialLocation -> getAutoGeneratedLocation).

Swift SVN r8085
2013-09-10 22:52:43 +00:00
Anna Zaks
c06bd83358 [SIL] Remove the last few uses of SILLocation constructor.
This also removes the constructor itself, which forces future users of
SILLocation to construct a valid location.

Swift SVN r8056
2013-09-09 22:34:05 +00:00
Anna Zaks
369a948248 [SIL] Minor auto-generated SILLocation API rename/refactor.
Swift SVN r8018
2013-09-06 23:57:27 +00:00
Anna Zaks
42f87d7725 [SIL] Represent module-level locations.
These are used for code that is usually associated with the enclosing decl such as epilog code and cleanups.

Swift SVN r8017
2013-09-06 23:57:25 +00:00
Anna Zaks
1ba2554fb2 [SIL] Ensure that all loop branches have valid locations.
Also, change the location of "looping back to head" branch to point to the closing brace of the body, which is a more natural source location than the beginning of the enclosing loop statement.

Swift SVN r7989
2013-09-06 17:46:15 +00:00
Anna Zaks
781ee9bdab [SIL Loc] Allow CleanupLocations that point to the beginning of the AST node.
Swift SVN r7817
2013-08-30 23:41:36 +00:00
Anna Zaks
fbcf5d458f [SIL Loc] Use a separate bit to represent auto-generated code
Auto generated location should not be a separate location kind since
we might have different kinds of auto generated locations (ex: cleanup,
return). Even though the kind info might not be necessary for diagnostics or
debug info, it allows us to better use type system, for example, only pass
CleanupLocation where expected.

Swift SVN r7816
2013-08-30 23:41:33 +00:00
Anna Zaks
8f3c9002d0 [SIL] Add cleanup locations to SIL instructions.
I've decided to keep only the location of the scope AST node that corresponds to the cleanup. (Currently, there is no user that needs the originator expression, which caused the cleanup. So keeping things simple.)

Added the cleanup location to the Scope and JumpDest classes, which gets assigned on construction of those. The Scope's and JumpDest locations are used when we emit the cleanup instructions.

We now give better location info for 2 existing tests for definitive initialization.

(+ Rather sparse testing of all this.)

Swift SVN r7764
2013-08-29 23:14:22 +00:00
Anna Zaks
b67f3c3552 [SIL] Use the ReturnLocation/ImplicitReturnLocation instead of generic SILLocations.
We mark the branch instructions leading into single epilog code with ReturnLocation/ImplicitReturnLocation. If SIL Gen simplifies the code and merges the code representing the return into the epilog block, the terminator of the epilog block (the ReturnInst) will have the return location info on it. Otherwise, the ReturnInst has the RegularLocation, which represents the enclosing FunctionExpr or Constructor/Destructor Decls.
(I've discussed dropping the optimization from SILGen, and keeping the epilog code canonical, with Adrian; but he said that there might not be any wins in doing so, so keeping it for now.)

Added AutoGeneratedLocation to represent segments of code generated by SILGen. This will be used for thunks and other auto-generated segments.

Swift SVN r7634
2013-08-27 22:16:24 +00:00
Anna Zaks
440631f86a [SIL] Add the SILLocation hierarchy.
Now we should be ready to start using these.

Swift SVN r7632
2013-08-27 22:16:18 +00:00
Anna Zaks
aaa4b2c332 [SIL Printer] Add optional source location printing.
Added a -v(verbose) option to swift that will trigger verbose printing in SIL
Printer. SIL Printer will print the location info only in the verbose mode.

Here is the example of the format - only the line and colon are displayed for
brevity:

%24 = apply %13(%22) : $[cc(method), thin] ((), [byref] Bool) -> Builtin.Int1 // user: %26 line:46:10

(This will be used to test the validity of SILLocation info.)

Swift SVN r6991
2013-08-07 18:39:48 +00:00
Chris Lattner
e2611273fc extend SILLocation to be able to store locations in SIL files.
This doubles SILLocation to being two words, since SourceLocations
can't be dumped into a PointerUnion, but it is due for a redesign someday
anyway, so I'm not going to worry about it.


Swift SVN r6989
2013-08-07 18:36:45 +00:00
John McCall
eaf693aace Constify SILLocation.
Swift SVN r6965
2013-08-07 00:10:56 +00:00
John McCall
9f6e2bf9bb Permit Patterns in SILLocation as well.
Swift SVN r6798
2013-08-01 01:28:38 +00:00
Anna Zaks
4d2e985a33 Cleanup: Forward declare SourceLoc instead of including it
Swift SVN r6285
2013-07-16 01:50:32 +00:00
Anna Zaks
f6d1ec48f0 [SIL] Refactor SILLocation not to derive from PointerUnion3 but to include it as a member
As per Chris's suggestion (review of r6152), further refactored SILLocation not to derive from PointerUnion3 but to include it as a member.

In addition, added some template magic to make sure we don't have to chain dyn_casts, which I suspect will be/is happening a lot with SILLocation:
Ex:
-  if (auto E = Func.dyn_cast<Expr*>()) {
-    if (const FuncExpr *FE = dyn_cast<FuncExpr>(E))
-      return SILLocation(FE->getBody())
+  if (const FuncExpr *FE = Func.getAs<FuncExpr>())
+    return SILLocation(FE->getBody());

Swift SVN r6283
2013-07-16 01:50:29 +00:00
Anna Zaks
4078785192 Turn SILLocation out of typedef and into a class.
Swift SVN r6154
2013-07-11 17:12:13 +00:00
Anna Zaks
2e4170e249 Add the first SIL-based waring - "missing return"
Add a warning on a missing return statement.
(This is not yet an error since we need to handle no-return functions.)

Swift SVN r6153
2013-07-11 17:12:12 +00:00
Joe Groff
7a0d879307 SILGen: Handle tuple explosions systematically.
Introduce an 'RValue' object in SILGen that behaves like a simplified version of IRGen's 'Explosion' object, holding a destructured tuple in a naturally destructured state. This cleans up a bunch of ad-hoc scattered code that destructured tuples in various places. Update SILGenFunction so that the expression visitors all pass around RValues, and update CallEmission to handle argument clauses as RValues instead of a pre-destructured string of arguments. Implement "emit into" optimization of TupleExpr and ScalarToTupleExpr, now that that's easy to do.

Swift SVN r4667
2013-04-10 23:00:18 +00:00
Joe Groff
c2f9b197ad SIL: Add DeallocExistentialInst.
Needed to represent deinitializing a partially-initialized existential in which the value witness table has been populated by alloc_existential but the value has not been initialized yet.

Swift SVN r3565
2012-12-20 20:18:54 +00:00
Chris Lattner
2c009210a4 rework a bunch of instructions to have a single constructor (and builder) form
that takes a generic SILLocation... instead of having duplicated constructors.


Swift SVN r3251
2012-11-27 01:28:23 +00:00
Chris Lattner
57eea530a9 more random changes CFG -> SIL
Swift SVN r3133
2012-11-07 01:31:27 +00:00
Chris Lattner
eab0962c5f rename many references to CFG to SIL.
Swift SVN r3130
2012-11-07 01:06:19 +00:00
Chris Lattner
93ae03891d rename the SIL/CFG*.h headers to SIL/SIL*.h
Swift SVN r3128
2012-11-07 00:56:21 +00:00