Commit Graph

143 Commits

Author SHA1 Message Date
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
Erik Eckstein
3751991798 Adapt to llvm debuginfo change: use DITypeArray instead of DIArray in some places
Swift SVN r20672
2014-07-29 15:13:21 +00:00
Adrian Prantl
0d2d2d32b1 Debug info: Improve handling of storage-less variables.
Swift SVN r20546
2014-07-25 16:47:59 +00:00
Adrian Prantl
b1a7a7af1b Reference-count inlined functions to keep them alive until we emit debug
info for them and generally clean up the inline scope handling a bit.
Fix the debug scope handling for all clients of SILCloner, especially
the SIL-level spezializers and inliners.
This also adds a ton of additional assertions that will ensure that
future optimization passes won't mess with the debug info in a way that
could confuse the LLVM backend.

Swift SVN r18984
2014-06-18 22:34:10 +00:00
Bob Wilson
2df66cf8c4 Implement inline scopes for the performance inliner.
Mandatory-inlined (aka transparent functions) are still treated as if they
had the location and scope of the call site. <rdar://problem/14845844>
Support inline scopes once we have an optimizing SIL-based inliner

Patch by Adrian Prantl.

Swift SVN r18835
2014-06-12 19:48:43 +00:00
Adrian Prantl
0b7f82bcc9 Linetable: Make sure the function prologue ends after manipulating the
stackpointer.
<rdar://problem/16903725> Line tables seem to assume prologue ends one instruction too early

Swift SVN r18284
2014-05-17 23:41:07 +00:00
Adrian Prantl
98383a5c6a Debug info: Use WeakVHs in DIRefMap so LLDB can safely invoke IRGen more
than once (at least as far as IRGenDebugInfo is concerned).

No new testcases, but it comes with new assertions.

Part of <rdar://problem/15283227> A crash in llvm's getFnAttributes when IRGen is called more than once.

Swift SVN r18214
2014-05-16 21:26:06 +00:00
Adrian Prantl
fcc346c874 Run clang-format on IRGenDebugInfo.*
Swift SVN r18035
2014-05-13 22:48:35 +00:00
Adrian Prantl
bb9be80edf Debug Info: Factor out createPointerSizedStruct for leaf types that
have mangled names.

Swift SVN r18034
2014-05-13 22:48:31 +00:00
John McCall
d7b44f2dc6 Correctly substitute field types when building debug info
for specializations of generic types.

Also remove some impossible error handling and simplify an API.

Swift SVN r17989
2014-05-13 02:09:22 +00:00
Adrian Prantl
c0b5da0d7f [please update LLVM] Debug info: Support multi-valued explosions, e.g.,
tuples and structs that are passed to a function by value.

<rdar://problem/15928331> Need to support DW_OP_piece for multi-Value variables/arguments
<rdar://problem/16599747> Variables not displayed at all in SwiftDemo02b_Closure (back again)

Swift SVN r17923
2014-05-12 03:31:07 +00:00
Adrian Prantl
f68f0e81d1 Debug info: represent function pointers as indirect function types.
<rdar://problem/14960518> Incorrect debug info for function pointer

Swift SVN r16716
2014-04-23 20:59:45 +00:00
Adrian Prantl
0851268d4f Run clang-format on this IRGenDebugInfo.h
Swift SVN r16715
2014-04-23 20:59:44 +00:00
Adrian Prantl
b1d9d186a0 [please update llvm] Debug info: Use the mangled name as unique identifier
for types where possible.

We use the DICompositeType's UniqueIdentifier field to store the mangled
name, the name field to store the base name and Apple-llvm will emit the
unique identifier as DW_AT_name if RunTimeLang == Swift. This way the
metadata format is compatible between swift and non-Apple clang.
As bonus, we get mangled-name-based type uniquing for swift.

<rdar://problem/16303510> apple-types accelerator table should include basename for swift types

Swift SVN r16665
2014-04-22 21:55:32 +00:00
Adrian Prantl
a17c8cccc0 Debug Info: Emit all types (with the exception of builtins and qualified
types) in their actual context rather than the context of their first use.
Fixes several FIXMEs and <rdar://problem/16654720>.

Swift SVN r16596
2014-04-20 19:32:35 +00:00
Adrian Prantl
9306fef294 Debug info: Emit the appropriate decl_file/line for import declarations.
rdar://problem/16565308

Swift SVN r16353
2014-04-15 03:08:22 +00:00
Adrian Prantl
79feaa894f [update LLVM] Debug info: Emit modules as DW_TAG_module.
<rdar://problem/16513629> Cleanup DWARF output for WWDC
<rdar://problem/16565308> Fix debug info for modules after LLVM r205685

Swift SVN r16352
2014-04-15 02:31:10 +00:00
Adrian Prantl
3db3eab09c Debug info: Cleanup: use a single catch-all for all internal opaque types.
Swift SVN r16132
2014-04-09 22:09:03 +00:00
Adrian Prantl
8d0e1d3376 [PLEASE UPDATE LLVM/CLANG] Debug info: Rebase DWARF output for imported
modules on LLVM/trunk.
This should fix most open module related bugs and in a way that is
compatible with upstream LLVM.

<rdar://problem/16539726> Fix debug info for modules after LLVM r205685
<rdar://problem/16504765> Emit DW_TAG_namespace entry for the current module into DWARF

Swift SVN r16086
2014-04-09 00:11:02 +00:00
Greg Parker
a11eff260f Adapt to header file changes in llvm r203038 and r203046.
Swift SVN r14716
2014-03-06 02:04:32 +00:00
Dmitri Hrybenko
a39d5b4f42 Track LLVM ToT header file name changes
This should unbreak the buildbot.


Swift SVN r14642
2014-03-04 13:11:01 +00:00