Commit Graph

35 Commits

Author SHA1 Message Date
Adrian Prantl
310b0433a9 Reapply "Serialize debug scope and location info in the SIL assembler language.""
This ireapplies commit 255c52de9f.

Original commit message:

Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 13:28:57 -08:00
Adrian Prantl
255c52de9f Revert "Serialize debug scope and location info in the SIL assembler language."
Temporarily reverting while updating the validation test suite.

This reverts commit c9927f66f0.
2016-02-26 11:51:57 -08:00
Adrian Prantl
c9927f66f0 Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 10:46:29 -08:00
Adrian Prantl
40c7a1abee Separate underlying storage and location kind in SILLocation and
remove the mixed concept that was SILFileLocation.
Also add support for a third type of underlying storage that will be used
for deserialized debug lcoations from textual SIL.

NFC

<rdar://problem/22706994>
2016-02-19 11:16:48 -08:00
Adrian Prantl
5dd6e6f5f4 Move the functionality to extract the debug location from a SILLocation
into SILLocation, since this will become useful for serialization.

NFC

<rdar://problem/22706994>
2016-02-09 11:58:15 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Chris Lattner
95b7b4d5e4 rename CleanupLocation::getCleanupLocation -> CleanupLocation::get, NFC.
Swift SVN r26994
2015-04-04 22:56:01 +00:00
Adrian Prantl
45544727ac Mark reabstraction thunk helpers as auto-generated.
Fixes <rdar://problem/18670152> Stack trace is a lie.

Swift SVN r25362
2015-02-18 00:46:25 +00:00
Adrian Prantl
d3fcfc832d Handle toplevel locations in InlinedLocation. This fixes a crash that
with the unoptimized stdlib caught by the buildbots.

Swift SVN r22799
2014-10-16 16:27:15 +00:00
Adrian Prantl
d80af7ba67 Simplify handling of SILFIle locations in SILLocation.
Swift SVN r22798
2014-10-16 16:27:12 +00:00
Adrian Prantl
d1c9f71a73 Enhance SILLocation so it can hold separate locations for diagnostics
and debug info. Drop most of the special SILLocation handling from
IRGenDebugInfo and eliminate lots of redundant code.

Swift SVN r22781
2014-10-15 23:05:57 +00:00
Adrian Prantl
bb726461b0 Ensure that the line table for the new SIL-generated main function begins
with user code and that the boilerplate is counted towards the prologue.

<rdar://problem/18563763> Setting a breakpoint on "main" in a Swift program doesn't stop at user code

Swift SVN r22611
2014-10-09 02:15:00 +00:00
Joe Groff
cac5807ae2 SILGen: Emit "main" as a SIL function.
Eliminate the intermediate top_level_code function. Now that SIL is expressive enough to express a "main" function, there's no reason for it, and this eliminates a bunch of mystery code in IRGen to thunk from main to top_level_code by reaching for hardcoded symbol names. Demystify the special code for setting up C_ARGC and C_ARGV by having SILGen look for a transparent "_didEnterMain" hook in the stdlib and emit a call to it.

Swift SVN r22525
2014-10-05 04:13:24 +00:00
Michael Gottesman
2eb34c35a4 [sil-inliner] Ensure that all special flags are propagated when we create a CleanupLocation, MandatoryInlinedLocation, or InlinedLocation from a SILLocation.
This corresponds to the fix I spoke of in r11595.

Swift SVN r11600
2013-12-23 06:35:38 +00:00
Michael Gottesman
90cbfb2e57 [sil-inliner] Removed invalid assert.
Given a destructor that is not implicit, one will have a decl that is not
autogenerated implying that this assert will always be hit.

I am going to submit an additional patch after this that changes
InlineLocation/MandatoryInlinedLocation/CleanupLocation that ensures that
the special flags on SILLocation are propagated appropriately (which they are
not right now).

Swift SVN r11595
2013-12-23 06:00:54 +00:00
Michael Gottesman
dffa7fe5bf [sil-inliner] Add support for Stmt, Pattern ASTNodes to Inlined/MandatoryInlined Location as per my discussion with Anna.
Swift SVN r11456
2013-12-19 00:16:21 +00:00
Anna Zaks
e5eb77ea6e [SIL] Mark these locations as cleanup.
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
2013-10-29 22:27:25 +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
6775516a7c [SIL] Propagate [transparent] from decl to apply inst for constructor.
Swift SVN r8225
2013-09-13 23:21:40 +00:00
Dmitri Hrybenko
796eac4b3f Make SILLocation::dump() more informative
Swift SVN r8130
2013-09-12 00:25:32 +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
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
8fae98d5c6 [SIL] Specialize the source locations for ReturnLocation and ImplicitReturnLocation.
Swift SVN r7913
2013-09-04 21:57:44 +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
b52166a2f3 [SILGen] Propagate location info through InitializeTupleValues
The test displays "<invalid loc>" even though the SIL location is
non-null because the corresponding AST node (Expr) does not have a location.

Swift SVN r7066
2013-08-08 23:59:08 +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
Chris Lattner
26fda44bc4 make SILLocation tolerate null locations, which is what it gets when parsing .sil files.
Swift SVN r6980
2013-08-07 16:50: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
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