Commit Graph

490 Commits

Author SHA1 Message Date
Adrian Prantl
73ac8296c4 Cleanup: Don't store VarDecls in DebugTypeInfo. 2016-07-22 09:42:15 -07:00
Adrian Prantl
3b3e308ed3 IRGenDebugInfo: Pass in the VarDecl separatly when emitting variables. (NFC) 2016-07-21 16:03:49 -07:00
Adrian Prantl
3ffaa762bc Don't emit line table entries for SIL functions marked as thunks.
rdar://problem/26221951
2016-07-07 19:03:28 -07:00
Adrian Prantl
361beff9c0 Emit pointer-sized structs only when -gdwarf-types is specified.
rdar://problem/25498103
2016-07-05 17:03:10 -07:00
Adrian Prantl
0847225962 Only emit DWARF types for enums when -gdwarf-types is specified. 2016-07-05 16:00:09 -07:00
Adrian Prantl
33ac7eb351 Only emit DWARF types for tuple types under -gdwarf-types. 2016-07-05 15:18:05 -07:00
Adrian Prantl
5504a188a3 Only emit DWARF types for structs when -gdwarf-types is specified. 2016-07-05 15:17:37 -07:00
Adrian Prantl
e2f05f046b Only emit DWARF types for function pointers when -gdwarf-types is specified. 2016-07-05 15:16:42 -07:00
Adrian Prantl
6b1263bf5a [Driver] Add a -gdwarf-types option and set it up as an alias for -g (NFC-ish)
Background
----------

Now that Swift AST type support in LLDB has matured, we can stop emitting DWARF
type information by default to reduce compile time and ibject file size.
A future commit will change -g to emit only AST type references.

The full set of debug options will be
-gnone
-gline-tables-only
-g                 // AST types (= everything that LLDB needs)
-gdwarf-types      // AST types + DWARF types (for legacy debuggers)
2016-07-05 12:06:23 -07:00
Adrian Prantl
b4d3059051 Debug Info: Unique forward declarations generated for scopes and types.
This is mostly a cleanup and results slightly more efficient debug info.

rdar://problem/25965038
2016-07-01 12:03:39 -07:00
Adrian Prantl
6cb7d56500 Cache the previous result of IRGenDebugInfo::createInlinedAt().
This saves ~4 seconds of a -r --no-assertions stdlib build and lowers
the contribution of llvm::SourceMgr::getLineAndColumn() to the total
runtime from 6% to 2%.

<rdar://problem/27016577>
2016-06-29 15:57:47 -07:00
Adrian Prantl
022a8b1345 Fix a bug that prevented setting a DebugLoc if the first SILInstruction
in the function is setup code for a closure and re-enable the assertions
that caught this on the bots.

rdar://problem/26955467
2016-06-29 10:47:11 -07:00
Adrian Prantl
75e10a66cc This fixes a bot failure in the LLDB testsuite.
This removes an assertion that no longer serves its purpose and
relaxes the IRBuilder checks for debug info when generating code
inside the debugger.

When LLDB is JIT-compiling expressions, it will not generate a
SWIFT_ENTRY_POINT_FUNCTION (there will be one per expression)
but it will still generate the equivalent of top level code.

rdar://problem/26955467
2016-06-28 10:33:40 -07:00
Adrian Prantl
935b702a07 Add an assertion to IRBuilder to prevent function calls with no debug location
It is not valid LLVM IR to have a function call without a location to an
inlinable function inside a function with debug info — this makes it impossible
to construct inline information.

This patch adds an assertion and fixes up several places across IRGen where
such a situation could happen.

rdar://problem/26955467
2016-06-27 19:04:51 -07:00
Adrian Prantl
cf3fdff042 Simplify the definition of isExplicitClosure().
NFC.
2016-06-25 13:44:39 -07:00
Adrian Prantl
bffda8a78d Debugging: Extend the live ranges of local values at -Onone.
For many local values we can avoid a shadow alloca by directly
describing them with a dbg.value. This also enables precise liveness
so variables don't show up in the debugger before they are
initialized. Unfortunately this also means that values will disappear
when they are no longer needed.

This patch inserts an empty inline assembler expression depending on
the llvm::Value that is being described in the blocks dominated by it.
This uses less stack space than full shadow copies *and* allows us to
track the liveness of the variable completely. It may cause values to
be spilled onto the stack, though.

<rdar://problem/26627376>
2016-06-24 10:35:45 -07:00
Adrian Prantl
1d02b3de59 Cleanup: Factor out common functionality in IRGenDebugInfo. 2016-06-07 11:30:20 -07:00
Adrian Prantl
4cee546841 Emit debug info for global variables without storage.
As with local variables this is done by emitting a constant 0 location
and a type of size zero.


<rdar://problem/26660971>
2016-06-06 17:06:20 -07:00
Adrian Prantl
dba926be30 Debug info: Fix the storage size of zero-size types.
This removes an obsolete workaround that prevented zero-sized types from
being emitted with the correct byte size.
2016-06-06 17:06:10 -07:00
Adrian Prantl
ff839429e4 Emit debug info for storage-less variables as constant 0 instead of undef.
LLVM drops debug intrinsics for undef values in SelectionDAG and FastISel.
Until this is fixed, emit a constant 0 to force the variable to be emitted.

<rdar://problem/26429250>
2016-06-06 15:20:18 -07:00
Adrian Prantl
0fac43e11f Adapt to upstream LLVM changes.
<rdar://problem/25949511+25962000>

(cherry picked from commit df9dfac609d17cd26d6107f17024c937b1b5b1a2)
2016-05-13 22:04:00 -07:00
Jacob Mizraji
7b7122fc11 Update ClangImporter and IRGenDebugInfo to build with upstream clang
(cherry picked from commit dab04d0517)
(cherry picked from commit d6b6594d77e01f5bb006897a42ec0a65665fcb9d)
2016-05-13 22:03:27 -07:00
John McCall
560f71fa5d Remove IRGenDebugInfo's dependency on querying the IRGenerator during construction.
Also remove unused IsLibrary flag.
2016-04-27 10:06:21 -07:00
John McCall
6c92c324f6 Rename IRGenModuleDispatcher to just IRGenerator and transfer
ownership of some of the basic structures to it.
2016-04-27 09:42:03 -07:00
Slava Pestov
a656fcdc8e Fix some compiler warnings with asserts disabled 2016-04-07 11:14:22 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Slava Pestov
5f8426b206 IRGen: More precise logic in debug info emission for globals
Previously we were using "has public visibility" as a proxy for
"comes from user code", which was OK because all global variables
had public linkage, even if they were internal or private in
the AST.

Now that this is about to change, let's check that we have a
SILLocation instead.
2016-03-28 14:14:49 -07:00
Erik Eckstein
b895a6498a IRGen: deal with DebugLoc locations in function scopes.
Plus a little bit refactoring.
2016-03-18 13:44:08 -07:00
Adrian Prantl
35fd887b69 Remove dead code. 2016-03-10 12:18:57 -08:00
Adrian Prantl
c0c8fbe1d2 Remove unused function. 2016-03-10 12:17:45 -08:00
Adrian Prantl
55607b2dbe Move IRGenDebugInfo Doxygen comments into the header file, LLVM-style.
NFC
2016-03-10 12:15:48 -08:00
Adrian Prantl
1f48b05f1f Debug Info: Retrieve the layout information of exploded values from the
explosion schema rather than from the debug type information and retire
a bunch of heuristics that are no longer necessary.

To enable this, this commit also includes a bugfix to debug info for
opaque data structures with the correct size and alignment information.

<rdar://problem/21470869+22707597>

This reapplies ad4f065ad6 and 7e489db9 after fixing the problem
uncovered by this commit in 5726370c1.
2016-03-10 10:16:02 -08:00
Adrian Prantl
5726370c1a Debug Info: Improve the accuracy of enum elements' sizes within the
limitations of LLVM.
2016-03-10 10:13:51 -08:00
Adrian Prantl
f6b969ff2e Revert "IRGenDebugInfo: Replace an obsolete workaround with an assertion."
This reverts commit ad4f065ad6.
2016-03-09 14:01:38 -08:00
Adrian Prantl
f2596958d6 Revert "Debug Info: Retreive the layout information of exploded values from the"
This reverts commit 7e489db91b.
2016-03-09 14:01:35 -08:00
Adrian Prantl
7e489db91b Debug Info: Retreive the layout information of exploded values from the
explosion schema rather than from the debug type information and retire
a bunch of heuristics that are no longer necessary.

To enable this, this commit also includes a bugfix to debug info for
opaque data structures with the correct size and alignment information.

<rdar://problem/21470869+22707597>
2016-03-09 13:51:33 -08:00
Adrian Prantl
ad4f065ad6 IRGenDebugInfo: Replace an obsolete workaround with an assertion.
rdar://problem/21470869
2016-03-09 13:51:33 -08:00
Chris Lattner
fe9fe47b7e Implement support for generic typealiases. 2016-03-07 22:20:16 -08:00
Chris Lattner
868a795566 Introduce a new class between TypeDecl and NominalTypeDecl named GenericTypeDecl.
This factors the DeclContext and generic signature behavior out of NTD, allowing
it to be reused in the future.  NFC.
2016-03-04 23:09:15 -08:00
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
John McCall
e249fd680e Destructure result types in SIL function types.
Similarly to how we've always handled parameter types, we
now recursively expand tuples in result types and separately
determine a result convention for each result.

The most important code-generation change here is that
indirect results are now returned separately from each
other and from any direct results.  It is generally far
better, when receiving an indirect result, to receive it
as an independent result; the caller is much more likely
to be able to directly receive the result in the address
they want to initialize, rather than having to receive it
in temporary memory and then copy parts of it into the
target.

The most important conceptual change here that clients and
producers of SIL must be aware of is the new distinction
between a SILFunctionType's *parameters* and its *argument
list*.  The former is just the formal parameters, derived
purely from the parameter types of the original function;
indirect results are no longer in this list.  The latter
includes the indirect result arguments; as always, all
the indirect results strictly precede the parameters.
Apply instructions and entry block arguments follow the
argument list, not the parameter list.

A relatively minor change is that there can now be multiple
direct results, each with its own result convention.
This is a minor change because I've chosen to leave
return instructions as taking a single operand and
apply instructions as producing a single result; when
the type describes multiple results, they are implicitly
bound up in a tuple.  It might make sense to split these
up and allow e.g. return instructions to take a list
of operands; however, it's not clear what to do on the
caller side, and this would be a major change that can
be separated out from this already over-large patch.

Unsurprisingly, the most invasive changes here are in
SILGen; this requires substantial reworking of both call
emission and reabstraction.  It also proved important
to switch several SILGen operations over to work with
RValue instead of ManagedValue, since otherwise they
would be forced to spuriously "implode" buffers.
2016-02-18 01:26:28 -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
Michael Gottesman
c684568042 [upstream-fix] llvm::RoundUpToAlignment was renamed to llvm::alignTo. 2016-02-06 11:22:27 -08:00
Adrian Prantl
b6a7d6906a Debug Info: Fix the lowering of the SILDebugScope tree to the LLVM
inlined-at chain.

The previous implementation was only correct for cases where the inliner
inlined bottom-up in the call graph, which happened to cover the majority
of all cases.

rdar://problem/24462475
2016-02-05 13:53:34 -08:00
Adrian Prantl
d42bb45d23 Debug Info: Remove an obsolete workaround that prevented witness functions
from having a DISubprogram attached.
2016-02-03 16:34:26 -08:00
Adrian Prantl
0854b3ce6d SILDebugScope: Add accessors for the parent SIL functions and use them in
assertions. (NFC)
2016-02-03 14:48:06 -08:00
Adrian Prantl
e0e83d3bf9 Refactor IRGenDebugInfo::createInlinedAt to take the inlined call site as
argument. (NFC)
2016-02-03 14:48:06 -08:00