Commit Graph

453 Commits

Author SHA1 Message Date
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
Erik Eckstein
bdfb461569 Preserve the names of zombie functions and use them as linkage names in the debug info.
Swift SVN r22662
2014-10-10 13:26:28 +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
Adrian Prantl
16f0bf1859 Add additional sanity checks to the debug scope creation while
fixing an off-by-one error in the boolean condition.

Swift SVN r22631
2014-10-09 20:16:42 +00:00
Dave Abrahams
8bd164610c Revert "Add additional sanity checks to the debug scope creation."
This reverts r22625 as it breaks my
RelWithDebInfo/SWIFT_OPTIMIZED=NO/INTERNAL_CHECKS=ON build:

Assertion failed: (DS->SILFn != Parent->SILFn && "non-inlined parent scope from different function?"), function parentScopesAreSane, file swift/lib/IRGen/IRGenDebugInfo.cpp, line 383.
...
1.	While emitting IR SIL function @_TFSs10minElementUSs12SequenceType_USs13GeneratorType_Ss10Comparable__FQ_QQQ_9Generator7Element for 'minElement' at /Users/dave/src/s/swift/stdlib/core/Algorithm.swift:12:8

Swift SVN r22630
2014-10-09 18:51:22 +00:00
Adrian Prantl
17c16c71a2 remove redundant check.
Swift SVN r22626
2014-10-09 18:04:34 +00:00
Adrian Prantl
cad7462342 Add additional sanity checks to the debug scope creation.
Swift SVN r22625
2014-10-09 18:04:34 +00:00
Adrian Prantl
689621e34a Debug Info: Make several soft assertions into hard ones.
Swift SVN r22613
2014-10-09 03:21:17 +00:00
Adrian Prantl
0420d9f2a2 Make the intention of the fallback logic for computing the linkage name
of a function clearer.

Swift SVN r22610
2014-10-09 02:14:57 +00:00
Adrian Prantl
d39d5702e9 Debug info: Stop abusing the Local flag for the calling convention.
The calling convention is encoded into the mangled name.

Swift SVN r22591
2014-10-08 01:13:13 +00:00
Adrian Prantl
f477b2685c Fix two IR correctness bugs related to not using the LLVM datatype in
DebugTypeInfo.

Swift SVN r22567
2014-10-07 17:33:39 +00:00
Joe Groff
cac5807ae2 SILGen: Emit "main" as a SIL function.
Eliminate the intermediate top_level_code function. Now that SIL is expressive enough to express a "main" function, there's no reason for it, and this eliminates a bunch of mystery code in IRGen to thunk from main to top_level_code by reaching for hardcoded symbol names. Demystify the special code for setting up C_ARGC and C_ARGV by having SILGen look for a transparent "_didEnterMain" hook in the stdlib and emit a call to it.

Swift SVN r22525
2014-10-05 04:13:24 +00:00
Adrian Prantl
d769498ccd Update for upstream LLVM API change.
Swift SVN r22456
2014-10-02 01:33:24 +00:00
Dmitri Hrybenko
e16e29b660 Update for upstream LLVM API changes
Swift SVN r22350
2014-09-29 13:17:35 +00:00
Erik Eckstein
35cfa7d2a0 fix a memory corruption introduced in r22301
(Don't increment refcounts of inlined SILFunctions for the purpose of debug info generation.)



Swift SVN r22349
2014-09-29 09:12:27 +00:00
Erik Eckstein
92dc4ee237 Don't increment refcounts of inlined SILFunctions for the purpose of debug info generation.
This prevented dead function removal of inlined dead functions. Beside the stdlib it's mostly
an issue of SIL size (and therefore compiletime), because llvm did remove such functions anyway.



Swift SVN r22301
2014-09-26 16:07:26 +00:00