Commit Graph

1132 Commits

Author SHA1 Message Date
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
John McCall
16cb523c3a AST support for accessors.
Swift SVN r22228
2014-09-23 20:34:19 +00:00
John McCall
75050f8166 Generate an implicit 'materializeForSet' accessor
along with getters and setters.

Just generate it for now.

Swift SVN r22011
2014-09-17 08:08:03 +00:00
Adrian Prantl
4dca38a8b3 Debug info: Remove the special handling of AnyFunctionType to add an extra
OpDeref to function objects (since Swift doesn't have function *pointer*
types). It confuses the debugger and is inconsistent with how we handle
other types such as classes.

<rdar://problem/18272602> Function pointers in local variables have incorrect DWARF locations

Swift SVN r21792
2014-09-08 23:39:27 +00:00
Adrian Prantl
3de439e574 Support debug info when compiling textual SIL files.
- Use SILFileLocations when compiling .sil with -g.
- Fix a crash when trying to find the Builtin module.

Part of <rdar://problem/17999350> `swiftc -g` crashes in some Swift tests

Swift SVN r21425
2014-08-22 22:48:12 +00:00
Dmitri Hrybenko
e45fe991b0 Update for upstream LLVM API changes in debug info gerenation
Swift SVN r21408
2014-08-22 08:27:57 +00:00
Jordan Rose
903cfacfa5 [DebugInfo] When looking up an imported module, don't include the scope.
i.e. for "import func Darwin.C.sqrt", use the module path "Darwin.C",
not the full path "Darwin.C.sqrt".

<rdar://problem/17895650>

Swift SVN r21097
2014-08-07 21:26:34 +00:00
Adrian Prantl
9fafa1c13c Make deserialized locations default to line 0, which tells the debugger
to ignore them, while still referencing the module file needed to perform
type lookups, etc.
<rdar://problem/17648201> After setting a breakpoint, the first step action is malfunctioning

Swift SVN r20801
2014-07-31 01:39:12 +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
f205552b61 [LLVM sync] Adopt the new API introduced in LLVM r214115.
Swift SVN r20651
2014-07-28 22:41:10 +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
b4b2b31dd1 Remove debug code that was accidentally committed.
Swift SVN r20504
2014-07-24 18:34:16 +00:00
Jordan Rose
b6818046a8 Eliminate optimization levels 0-3 in favor of -Onone/-O/-Ofast.
We were already effectively doing this everywhere /except/ when building
the standard library (which used -O2), so just use the model we want going
forward.

Swift SVN r20455
2014-07-24 01:12:59 +00:00
Dmitri Hrybenko
e7b4e6c370 Punycode encoder/decoder: separate core and parts that depend on UTF8
encoder/decoder


Swift SVN r20309
2014-07-22 15:01:12 +00:00
Dmitri Hrybenko
734c0a9ba1 Revert "Punycode encoder/decoder: separate core and parts that depend on UTF8"
It broke tests.

Swift SVN r20308
2014-07-22 14:44:20 +00:00
Dmitri Hrybenko
56342b0cfa Punycode encoder/decoder: separate core and parts that depend on UTF8
encoder/decoder


Swift SVN r20307
2014-07-22 14:37:37 +00:00
Dmitri Hrybenko
e33bb4c8de Demangler: remove SmallVector from punycode encoder and decoder interface
Swift SVN r20250
2014-07-21 14:37:16 +00:00
Joe Groff
45eec9a2e9 Remove 'interface' from the method names of SILFunctionType.
SILFunctionTypes are always interface types now. NFC.

Swift SVN r19952
2014-07-14 22:03:46 +00:00
Adrian Prantl
400f1774e9 Add support for a #line directive.
This patch extends the syntax with a new #line directive that is inspired
by the homonymous CPP directive. It can be specified in all locations a #if
is legal (Stmt, Decl).

Semantics
---------

#line 42 "file.swift"
This makes diagnostics and debug information behave as if the subsequent
lines came from file.swift+42.

#line // without arguments
This switches back to the main source file and the switches back to the
normal line numbering. Any previous #line directives will result in gaps
in the main file.

Rationale
---------

LLDB and the REPL need this for making expressions that are entered into
the expression evaluator or REPL debugable. For more info see
<rdar://problem/17441710> Need #line directive or something similar so we can enhance the debugging of expressions and REPL

Also, I believe the stdlib would benefit from this and it would allow us
to get rid of the line-directive wrapper script.

Swift SVN r19384
2014-06-30 23:50:11 +00:00
Adrian Prantl
3ae5326d21 Tweak the scope guessing for instructions without SILDebugScopes to reuse
the scope of the previous instruction.

<rdar://problem/17021591> Gap in lexical block coincides with the first line-table entry for a line => no variables at that line

Swift SVN r19318
2014-06-28 02:08:26 +00:00
Doug Gregor
07a7059934 Preserve dictionary type sugar in the type system.
Another piece of <rdar://problem/17460972>.


Swift SVN r19253
2014-06-26 21:12:19 +00:00
Greg Clayton
707505f3f5 Revert fix for being able to generate debug info in JIT'ed expressions until we can pass all regression tests.
Swift SVN r19111
2014-06-24 00:12:18 +00:00