Commit Graph

1132 Commits

Author SHA1 Message Date
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
Michael Gottesman
cf5dd16bd3 Merge pull request #2546 from compnerd/DL-update
[master-next] update DL method name
2016-06-25 01:50:07 -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
Saleem Abdulrasool
e93b391b87 [upstream-update] update DL method name
Update the name as per SVN r269456.
2016-05-16 11:54:38 -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
Mark Lacey
5e41d3ffd9 Fixes for TypedDINodeRef API change. 2016-05-03 17:08:44 -07:00
Mark Lacey
182b6dfb18 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	tools/driver/CMakeLists.txt
	tools/swift-reflection-dump/swift-reflection-dump.cpp
2016-05-03 14:23:20 -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
Doug Gregor
d1c81aa68f Adjust to LLVM r265077 and Clang r265711, courtesy of Chris Willmore 2016-04-12 17:14:02 -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
Adrian Prantl
75fc840126 Merge the parent scope and function fields of SILDebugScope into a
PointerUnion.

This saves 8 bytes per SILDebugScope.

rdar://problem/22706994
2016-01-29 17:21:26 -08:00
Adrian Prantl
1d61e31654 Debug Info: Use the major runtime version only to populate the
DW_AT_APPLE_major_runtime_vers attribute.

LLDB currently doesn't use this field, so this discontinuity is still safe.
Because of the dependency on the version number this is hard to write a
testcase for.

rdar://problem/24176158
2016-01-19 17:03:12 -08:00
Slava Pestov
552d52b7e8 IRGen: Stop using SIL TypeConverter::getArchetypes() in type lowering, NFC
Let's use the ArchetypeBuilder from the ASTContext, which was
recently added by Doug.

Also refactor away GenericsRAII helper class.
2016-01-14 22:55:43 -08:00
Adrian Prantl
b58522b8af Debug info: Emit nested functions in the proper nested scope.
rdar://problem/24102282
2016-01-11 14:47:40 -08:00
practicalswift
ca92efc8e6 Use consistent formatting of header comments.
Correct format:
```
//===--- Name of file - Description ----------------------------*- Lang -*-===//
```

Notes:
* Comment line should be exactly 80 chars.
* Padding: Pad with dashes after "Description" to reach 80 chars.
* "Name of file", "Description" and "Lang" are all optional.
* In case of missing "Lang": drop the "-*-" markers.
* In case of missing space: drop one, two or three dashes before "Name of file".
2016-01-04 23:00:53 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Chris Lattner
feace85d5a Enhance SubscriptDecl to be a DeclContext, so it can hold its indices.
This is necessary for some other work I'm doing, which really wants
paramdecls to have reasonable declcontexts.  It is also a small step
towards generic subscripts.
2015-12-31 12:38:28 -08:00
practicalswift
db13bcb22e Fix typos. 2015-12-26 14:11:42 +01:00