Commit Graph

213 Commits

Author SHA1 Message Date
Adrian Prantl
0e9c8e9db4 Update for LLVM API change D20147. 2016-09-20 18:14:03 -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
33ac7eb351 Only emit DWARF types for tuple types under -gdwarf-types. 2016-07-05 15:18:05 -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
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
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
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
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
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
69c70b8563 Remove unnecessary #includes. 2016-03-10 12:15:48 -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
d8bbe8a258 Reformat doxygen comment. 2016-03-10 10:13:51 -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
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
d7734e4dad [upstream-fix] Include the declaration of SILDebugScope into IRGenDebugInfo.h so that we do not run into forward declaration issues. 2016-02-06 11:22:27 -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
59226f383d Debug Info: Fix a backend crash by removing obsolete linetable heuristics.
Recent versions of LLDB can deal with line 0 locations much better and
due to a subtle bug in the heuristic instructions immediately following
the prologue could end up without debug locations which can cause serious
problems for the LLVM inliner when constructing inline debug scope info.

<rdar://problem/24394944>
2016-02-01 13:05:52 -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
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
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
practicalswift
c6e8459187 Fix typos. 2015-12-14 11:13:30 +01:00
Leo Shimonaka
70e66973ee Fix spelling error in documentation / comments / method name 2015-12-05 00:28:08 -05:00
Adrian Prantl
0d300206cd Remove wrapper functions that added little value. (NFC) 2015-12-04 11:05:26 -08:00
Adrian Prantl
8ab1e2dd50 Unify debug scope and location handling in SILInstruction and SILBuilder.
The drivers for this change are providing a simpler API to SIL pass
authors, having a more efficient of the in-memory representation,
and ruling out an entire class of common bugs that usually result
in hard-to-debug backend crashes.

Summary
-------

SILInstruction

Old                   New
+---------------+     +------------------+    +-----------------+
|SILInstruction |     |SILInstruction    |    |SILDebugLocation |
+---------------+     +------------------+    +-----------------+
| ...           |     | ...              |    | ...             |
|SILLocation    |     |SILDebugLocation *| -> |SILLocation      |
|SILDebugScope *|     +------------------+    |SILDebugScope *  |
+---------------+                             +-----------------+

We’re introducing a new class SILDebugLocation which represents the
combination of a SILLocation and a SILDebugScope.
Instead of storing an inline SILLocation and a SILDebugScope pointer,
SILInstruction now only has one SILDebugLocation pointer. The APIs of
SILBuilder and SILDebugLocation guarantees that every SILInstruction
has a nonempty SILDebugScope.

Developer-visible changes include:

SILBuilder
----------

In the old design SILBuilder populated the InsertedInstrs list to
allow setting the debug scopes of all built instructions in bulk
at the very end (as the responsibility of the user). In the new design,
SILBuilder now carries a "current debug scope" state and immediately
sets the debug scope when an instruction is inserted.
This fixes a use-after-free issue with with SIL passes that delete
instructions before destroying the SILBuilder that created them.

Because of this, SILBuilderWithScopes no longer needs to be a template,
which simplifies its call sites.

SILInstruction
--------------

It is neither possible or necessary to manually call setDebugScope()
on a SILInstruction any more. The function still exists as a private
method, but is only used when splicing instructions from one function
to another.

Efficiency
----------

In addition to dropping 20 bytes from each SILInstruction,
SILDebugLocations are now allocated in the SILModule's bump pointer
allocator and are uniqued by SILBuilder. Unfortunately repeat compiles
of the standard library already vary by about 5% so I couldn’t yet
produce reliable numbers for how much this saves overall.

rdar://problem/22017421
2015-11-19 09:31:26 -08:00
Adrian Prantl
3356f7ac59 Pass the debug info settings through to Clang and ensure that compile units
created by Swift and Clang set the CU's compilation dir similarly.

rdar://problem/22692266

Swift SVN r32637
2015-10-12 22:20:58 +00:00
Michael Gottesman
f1967716b6 Adapt IRGenDebugInfo::emitVariableDeclaration() to new LLVM API.
Swift SVN r31803
2015-09-09 04:37:20 +00:00
Frederic Riss
f3816e6dfa DebugInfo: Do not infinite loop on indirect enums.
When computing the locations for local indirect enums, we could enter
an infinite loop if the first field is a recursive reference.
Just bail out of the field-splitting logic if we encounter an indirect
case. More work might be needed if indirect enums get exploded.

rdar://problem/21927941

Swift SVN r30717
2015-07-28 17:18:02 +00:00
Adrian Prantl
c5dd8bea82 Debug Info: Migrate from MDModule to DIModule.
MDModule was a bitcode-incompatible internal-only extension that has
since been replaced with a blessed IR node on trunk.

<rdar://problem/20965932> Upstream DIModule and support it in clang-700, swiftlang-700, and lldb-700

Swift SVN r29832
2015-07-01 02:25:22 +00:00
Erik Eckstein
daaea3705f Fix a debug-info bug in multi-threaded compilation mode.
The compilation-unit's filename was not set correctly. This led to warnings printed by dsymutil.
There is no radar for this problem.



Swift SVN r28424
2015-05-11 18:12:10 +00:00
Duncan Exon Smith
c6d42db070 Adapt to MD* => DI* renaming of debug info types
Applied the upgrade script from r236120 (LLVM) and r236121 (CFE).  This is the
final step of rdar://problem/20434113.



Swift SVN r27925
2015-04-29 21:40:21 +00:00
Adrian Prantl
a1da38c3aa Adapt IRGenDebugInfo to upstream LLVM IR Metadata changes.
Swift SVN r27709
2015-04-24 20:59:09 +00:00
John McCall
9f38d8da50 Require a GenericSignature for dependent AbstractionPatterns.
We still don't actually handle these correctly, but at least
we have sensible information for them now.

Also, remember that we're working with canonical generic
signatures in more places.

Swift SVN r27388
2015-04-16 23:27:00 +00:00
Joe Groff
ad0d20c07a Fold "AbstractCC" into SILFunctionType::Representation.
These aren't really orthogonal concerns--you'll never have a @thick @cc(objc_method), or an @objc_block @cc(witness_method)--and we have gross decision trees all over the codebase that try to hopscotch between the subset of combinations that make sense. Stop the madness by eliminating AbstractCC and folding its states into SILFunctionTypeRepresentation. This cleans up a ton of code across the compiler.

I couldn't quite eliminate AbstractCC's information from AST function types, since SIL type lowering transiently created AnyFunctionTypes with AbstractCCs set, even though these never occur at the source level. To accommodate type lowering, allow AnyFunctionType::ExtInfo to carry a SILFunctionTypeRepresentation, and arrange for the overlapping representations to share raw values.

In order to avoid disturbing test output, AST and SILFunctionTypes are still printed and parsed using the existing @thin/@thick/@objc_block and @cc() attributes, which is kind of gross, but lets me stage in the real source-breaking change separately.

Swift SVN r27095
2015-04-07 21:59:39 +00:00
Adrian Prantl
55e76bf15a Debug Info: Be sure to reset the debug location before entering a new basic
block in IRGenSIL.

Fixes <rdar://problem/19675260> Step over function to debug Swift code doesn't work correctly.

Swift SVN r25287
2015-02-13 23:01:43 +00:00
Adrian Prantl
271dae3a60 fix formatting.
Swift SVN r24683
2015-01-23 05:39:04 +00:00
Adrian Prantl
b4c7b90c4a Fix rdar://19309057 a little harder. ArtificialLocation cannot be used
after we emitted the return block.

Swift SVN r24036
2014-12-19 19:01:43 +00:00
Adrian Prantl
9ee65d5ff0 Adapt swift for Duncan's upstream LLVM change r223802.
<rdar://problem/19192991> Upstream LLVM MDNode changes break Swift

Swift SVN r23811
2014-12-09 20:25:43 +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
d6e5caf634 Assert monotonically increasing line numbers within the same basic block
at -Onone. This is currently turned off by default because it
also reports false positives, but it is an incredibly useful mechanism
to find linetable bugs.

Swift SVN r22738
2014-10-15 00:26:33 +00:00
Adrian Prantl
aa6c57fc6b Remove special-casing of avaliable_externally functions when emitting
debug info for them and unconditionally emit debug info for all
functions.

Swift SVN r22653
2014-10-10 03:47:32 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Adrian Prantl
d769498ccd Update for upstream LLVM API change.
Swift SVN r22456
2014-10-02 01:33:24 +00:00