Commit Graph

368 Commits

Author SHA1 Message Date
Adrian Prantl
3c6af3610a Debug Info: type-unique enum types by virtue of their mangled name.
rdar://problem/20015686

Swift SVN r26104
2015-03-13 18:13:59 +00:00
Adrian Prantl
a100a3e6e9 Debug Info: Don't absolutize file paths.
Fixes <rdar://problem/19985842> REPL should set the default file to "repl.swift"

Swift SVN r26022
2015-03-12 02:56:49 +00:00
Adrian Prantl
d495d2110a Debug Info: Use the storage size for debug types where we previously
didn't and make the assertion about zero-sized types stricter.

<rdar://problem/19978910> Assertion failed: (Ty.getSizeInBits() && "type with size 0"), function getSizeInBits

Swift SVN r25599
2015-02-27 06:25:13 +00:00
Adrian Prantl
17c4a51f45 Debug info: Have a function's name default to its linkage name.
Swift SVN r25502
2015-02-24 17:27:35 +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
833a7f48a5 Adopt upstream LLVM API change.
Swift SVN r25183
2015-02-11 18:29:59 +00:00
Adrian Prantl
1d6d890e13 Adapt upstream LLVM API change.
Swift SVN r25109
2015-02-10 00:55:03 +00:00
David Farler
51f8070abe Serialize local types
Local type declarations are saved in the source file during parsing,
now serialized as decls. Some of these may be defined in DeclContexts
which aren't Decls and previously weren't serialized. Create four new
record kinds:

* PatternBindingInitializer
* DefaultArgumentInitializer
* AbstractClosureExpr
* TopLevelCodeDecl

These new records are used to only preserve enough information for
remangling in the debugger, and parental context relationships.

Finally, provide a lookup API in the module to search by mangled name.
With the new remangling API, the debugging lifecycle for local types
should be complete.

The extra LOCAL_CONTEXT record will compressed back down in a
subsequent patch.

Swift SVN r24739
2015-01-27 01:49:54 +00:00
Adrian Prantl
d1d4fd86f8 Don't emit debug info for global values with hidden visibility.
<rdar://problem/19313855> _TWVVSC26NSKeyValueObservingOptions shows up in global variables

Swift SVN r24695
2015-01-23 23:35:36 +00:00
Adrian Prantl
46edb2891d There are currently situations where two (types that
contains an) archetype(s) mangle to the same name but differ in
their storage size.
This is causing an assertion on some of the build bots.
This works around the problem by not caching them, until I can reproduce
the problem on a smaller scale and fix the mangler.

Swift SVN r24682
2015-01-23 05:39:03 +00:00
Adrian Prantl
15f18f79fa Use getFixedBufferSize() here to clarify the intention.
Swift SVN r24651
2015-01-22 19:56:54 +00:00
Adrian Prantl
5ee2fedc37 Debug info: Use 3xi8 as a fallback type size for %swift.opaque if we
can't determine the storage size.

Swift SVN r24649
2015-01-22 19:42:11 +00:00
Adrian Prantl
171035d974 Debug info: Don't emit a line number for tuple types. They are unnamed
and have no declaration, so the line number is nonsensical.

Swift SVN r24648
2015-01-22 19:42:11 +00:00
Adrian Prantl
723c9aa196 Debug Info: Fix the caching policy for types that cannot be cached,
either because they don't have a UID, or because their Swift type may
be more general than their specialized type.

Swift SVN r24647
2015-01-22 19:42:10 +00:00
Adrian Prantl
a2c9033ac2 Debug info: Don't emit a line number for inout types. They are unnamed
so the line number is nonsensical.

Swift SVN r24646
2015-01-22 19:42:09 +00:00
Adrian Prantl
9e66db8d95 remove stale comment.
Swift SVN r24645
2015-01-22 19:42:09 +00:00
Adrian Prantl
cf393e8766 Don't emit sugar typedefs for sugar types that don't have their own
mangling schema. Caught via the "conflicting types for UID" assertion
in getOrCreateType.

Swift SVN r24644
2015-01-22 19:42:05 +00:00
Greg Parker
6cc99440a5 Adopt llvm's removal of MDNodeFwdDecl.
Swift SVN r24544
2015-01-20 02:35:33 +00:00
Adrian Prantl
8c4355460b Remove the soft-fail from this assertion.
Swift SVN r24466
2015-01-16 01:11:25 +00:00
Adrian Prantl
23829b651e Add an assert message.
Swift SVN r24465
2015-01-16 01:11:25 +00:00
Adrian Prantl
c1d391aa66 Debug Info: Only verify the validity of scopes in debug builds as this is
quite an expensive operation and getOrCreateScope either returns a nullptr
or a valid scope.

Swift SVN r24464
2015-01-16 01:11:22 +00:00
David Farler
cad9f99929 Revert "Serialize local types and provide a lookup API"
Changing the design of this to maintain more local context
information and changing the lookup API.

This reverts commit 4f2ff1819064dc61c20e31c7c308ae6b3e6615d0.

Swift SVN r24432
2015-01-15 00:33:10 +00:00
David Farler
fab3d491d9 Serialize local types and provide a lookup API
rdar://problem/18295292

Locally scoped type declarations were previously not serialized into the
module, which meant that the debugger couldn't reason about the
structure of instances of those types.

Introduce a new mangling for local types:
[file basename MD5][counter][identifier]
This allows the demangle node's data to be used directly for lookup
without having to backtrack in the debugger.

Local decls are now serialized into a LOCAL_TYPE_DECLS table in the
module, which acts as the backing hash table for looking up
[file basename MD5][counter][identifier] -> DeclID mappings.

New tests:
* swift-ide-test mode for testing the demangle/lookup/mangle lifecycle
of a module that contains local decls
* mangling
* module merging with local decls

Swift SVN r24426
2015-01-14 22:08:47 +00:00
Adrian Prantl
a513e03680 Debug info: Push the non-handling of indirect pieces down to
IRGenDebugInfo.

NFC.

rdar://problem/19417227.

Swift SVN r24319
2015-01-09 18:38:32 +00:00
Adrian Prantl
53f9529e0c Debug info: Do not cache Archetypes based on their Swift type.
After the SILPasses, they may have different underlying storage types.

Discovered via <rdar://problem/19377246>.

Swift SVN r24191
2015-01-05 23:54:28 +00:00
Adrian Prantl
8a817d8dca Adapt to upstream LLVM API changes.
Swift SVN r24006
2014-12-18 17:07:57 +00:00
John McCall
169e4fe319 Add Builtin.UnsafeValueBuffer, which provides opaque
storage for arbitrary values.

A buffer doesn't provide any way to identify the type of
value it stores, and so it cannot be copied, moved, or
destroyed independently; thus it's not available as a
first-class type in Swift, which is why I've labelled
it Unsafe.  But it does allow an efficient means of
opaquely preserving information between two cooperating
functions.  This will be useful for the adjustments I
need to make to materializeForSet to support safe
addressors.

I considered making this a SIL type category instead,
like $@value_buffer T.  This is an attractive idea because
it's generally better-typed.  The disadvantages are that:
- it would need its own address_to_pointer equivalents and
- alloc_stack doesn't know what type will be stored in
  any particular buffer, so there still needs to be
  something opaque.

This representation is a bit gross, but it'll do.

Swift SVN r23903
2014-12-13 01:27:12 +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
883f2d3a24 Revert an accidentally comitted line and fix the build bots.
Swift SVN r23678
2014-12-04 03:49:01 +00:00
Adrian Prantl
3202823f3e Debug info: Emit the actual types for specialized variables instead of
their generic type.

NFC for unoptimized code, testcase for optimized code will come with
rdar://problem/18709125.

Swift SVN r23676
2014-12-04 02:13:46 +00:00
Adrian Prantl
41a30f5988 Support line table only DWARF for Swift. <rdar://problem/19106981>
The new option is called -gline-tables-only to mirror clang.

Swift SVN r23615
2014-12-02 17:44:23 +00:00
Adrian Prantl
6121e4267f Cleanup.
Swift SVN r23375
2014-11-17 18:46:12 +00:00
Adrian Prantl
6f42b37661 Fix a bug were a stack-allocated string was used as an index into a map.
<rdar://problem/19001254> DebugInfo/Imports.swift is broken

Swift SVN r23374
2014-11-17 18:46:09 +00:00
Adrian Prantl
c578ef6f02 Emit human-readable names for destructors in the debug info.
<rdar://problem/16653867> swift is emitting many "empty string" named items in the apple-names table

Swift SVN r23292
2014-11-13 00:11:27 +00:00
Adrian Prantl
dd4032ee41 Modify the Mangler to recursively deal with sugared types.
Unless DWARFmangling is set all methods still expect a CanonicalType.

Fixes <rdar://problem/17042576> [6A214t] Debug information has wrong type for dispatch queue

Swift SVN r23226
2014-11-11 01:32:12 +00:00
Adrian Prantl
993c72499b This week in debug info: global variables are now emitted as global variables.
rdar://problem/15859689 once again.

Swift SVN r23169
2014-11-08 00:29:38 +00:00
Adrian Prantl
801dc3d20e Debug info: Actually encode the Swift version number instead of constant 1.
<rdar://problem/18729762> CU's RuntimeVersion field should have the Swift runtime version number

Swift SVN r23087
2014-11-03 17:48:06 +00:00
Adrian Prantl
9fe784ea69 Debug Info: Make the local versions of variables in main appear as local.
<rdar://problem/15859689> Local variables should list top-level variables

Swift SVN r23048
2014-11-01 00:43:00 +00:00
Adrian Prantl
35488903d3 Change uses auto to auto* where applicable.
Swift SVN r22977
2014-10-28 01:49:08 +00:00
Joe Groff
5a2f48e3be Add a Builtin.BridgeObject type.
This is a type that has ownership of a reference while allowing access to the
spare bits inside the pointer, but which can also safely hold an ObjC tagged pointer
reference (with no spare bits of course). It additionally blesses one
Foundation-coordinated bit with the meaning of "has swift refcounting" in order
to get a faster short-circuit to native refcounting. It supports the following
builtin operations:

- Builtin.castToBridgeObject<T>(ref: T, bits: Builtin.Word) ->
  Builtin.BridgeObject

  Creates a BridgeObject that contains the bitwise-OR of the bit patterns of
  "ref" and "bits". It is the user's responsibility to ensure "bits" doesn't
  interfere with the reference identity of the resulting value. In other words,
  it is undefined behavior unless:

    castReferenceFromBridgeObject(castToBridgeObject(ref, bits)) === ref

  This means "bits" must be zero if "ref" is a tagged pointer. If "ref" is a real
  object pointer, "bits" must not have any non-spare bits set (unless they're
  already set in the pointer value). The native discriminator bit may only be set
  if the object is Swift-refcounted.

- Builtin.castReferenceFromBridgeObject<T>(bo: Builtin.BridgeObject) -> T

  Extracts the reference from a BridgeObject.

- Builtin.castBitPatternFromBridgeObject(bo: Builtin.BridgeObject) -> Builtin.Word

  Presents the bit pattern of a BridgeObject as a Word.

BridgeObject's bits are set up as follows on the various platforms:

i386, armv7:

  No ObjC tagged pointers
  Swift native refcounting flag bit: 0x0000_0001
  Other available spare bits:        0x0000_0002

x86_64:

  Reserved for ObjC tagged pointers: 0x8000_0000_0000_0001
  Swift native refcounting flag bit: 0x0000_0000_0000_0002
  Other available spare bits:        0x7F00_0000_0000_0004

arm64:

  Reserved for ObjC tagged pointers: 0x8000_0000_0000_0000
  Swift native refcounting flag bit: 0x4000_0000_0000_0000
  Other available spare bits:        0x3F00_0000_0000_0007

TODO: BridgeObject doesn't present any extra inhabitants. It ought to at least provide null as an extra inhabitant for Optional.

Swift SVN r22880
2014-10-23 00:09:23 +00:00
Adrian Prantl
c3a4ae056c Remove a hack that was obsoleted by LLVM r219798.
Swift SVN r22855
2014-10-20 23:04:10 +00:00
Adrian Prantl
d238a3f17b Don't emit line numbers for subprograms that are thunks / bare functions.
<rdar://problem/18670152> Stack trace is a lie

Swift SVN r22854
2014-10-20 23:04:06 +00:00
Adrian Prantl
f88dabb337 Top-level variable declarations should show up as local variables with static scope for the main() function in DWARF.
<rdar://problem/15859689> Local variables should list top-level variables

Swift SVN r22807
2014-10-17 00:43:56 +00:00
Adrian Prantl
5e023e205f Set the human-readable name for main, because the function is scope-less.
Testcase in the following commit.

Swift SVN r22806
2014-10-17 00:43:52 +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
a64a2691b1 Debug info: Use the end of a call expression as the location for a call.
Swift SVN r22740
2014-10-15 00:26:45 +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
807434e4a8 Work around an elusive crash in DwarfDebug::endFunction().
<rdar://problem/18592152> Unchecked Swift builder is sometimes crashing in AsmPrinter::EmitFunctionBody

DIBuilder adds all DIVariables to a temporary named MDNode in
order to add them to the variables field in their parent
DISubprogram in DIBuilder::finalize(). In the absence of an
llvm::Function DIBuilder uses the human-readable name as a name
for this temporary MDnode, which in the case of specialized
generic functions (which are then SILinlining and thus
zombiefied, making them loose their llvm::Function) is not
unique, because the specialization is not encoded in the
human-readable name. Until either of these problems are fixed,
use the mangled name as human-readable name IR-less functions
here.
Work is underway to upstream an assertion in LLVM that will
ensure this won't regress.

Swift SVN r22687
2014-10-11 04:07:31 +00:00
Doug Gregor
7d6ca8c2b8 Reinstate r22662 "Preserve the names of zombie functions and use them as linkage names in the debug info.""
It looks like Xcode badness caused the build breakage. Sorry, Erik!

Swift SVN r22677
2014-10-10 22:03:58 +00:00
Doug Gregor
5338a29f7f Revert "Preserve the names of zombie functions and use them as linkage names in the debug info."
This reverts commit r22662, which is causing the stdlib build to crash.

Swift SVN r22670
2014-10-10 17:46:30 +00:00