Commit Graph

3664 Commits

Author SHA1 Message Date
Max Moiseev
885b564bf5 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 17:16:37 -08:00
John McCall
2840478147 When preparing necessary bindings, we sometimes decide to capture
bound generic type metadata rather than its individual components.
Don't crash when actually restoring that metadata.

Fixes SR-901.
2016-03-09 15:12:27 -08:00
Adrian Prantl
f6b969ff2e Revert "IRGenDebugInfo: Replace an obsolete workaround with an assertion."
This reverts commit ad4f065ad6.
2016-03-09 14:01:38 -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
ad4f065ad6 IRGenDebugInfo: Replace an obsolete workaround with an assertion.
rdar://problem/21470869
2016-03-09 13:51:33 -08:00
Max Moiseev
1fae0d1325 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-08 12:48:48 -08:00
Adrian Prantl
053d7cf277 Debug Info: Don't emit shadow stack copies for local variables.
The effect of this tiny change is that local variables will be described
by llvm.dbg.values, which will get lowered into an accurate location list
instead of a stack slot that is valid for the entire scope of the variable.
This means the debugger can now accurately track the liveness of variables
knowing exactly when they are initialized and when there values go away.
Function arguments are still kept in stack slots because (1) they are
already initialized at the function entry and (2) LLDB really needs self
to be available at all times for the expression evaluator.

This was made possible by recent advancements in LLVM such as the live
debug variables pass and various related bugfixes.

<rdar://problem/15746520>
2016-03-08 11:10:02 -08:00
Chris Lattner
fe9fe47b7e Implement support for generic typealiases. 2016-03-07 22:20:16 -08:00
David Farler
4fc146a14a [GenReflection] Use declared type for associated type record keys
Similiar to the change to field reflection metadata, don't use the
interface for the key of associated type lookup, because the nominal
type descriptors don't include generics in their mangled name strings.
2016-03-07 17:43:13 -08:00
David Farler
b8345e2ffd [GenReflection] Use pretty stack trace when emitting metadata 2016-03-07 17:43:13 -08:00
David Farler
96386b03be Don't use interface type as field descriptor key
Nominal type descriptors use declared types for their mangled names,
so we need to use them when scanning the fieldmd section for a
matching record. This is fine because the descriptor can tell us
about the type's generics. Individual field records continue to use
the interface type.
2016-03-07 17:43:12 -08:00
David Farler
cd6d05e23f Move paltry linker section name length assert into Mach-O case
This is where it really matters - the section name has to be 16
characters or less.
2016-03-07 17:43:12 -08:00
David Farler
161a56ce8f Remove unnecessary if auto check - NFC 2016-03-07 17:43:12 -08:00
Max Moiseev
7fe6916bf6 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-07 12:10:47 -08:00
Chris Lattner
868a795566 Introduce a new class between TypeDecl and NominalTypeDecl named GenericTypeDecl.
This factors the DeclContext and generic signature behavior out of NTD, allowing
it to be reused in the future.  NFC.
2016-03-04 23:09:15 -08:00
David Farler
bd6d657411 Get typerefs for existential type metadata 2016-03-04 17:10:40 -08:00
Adrian Prantl
c451db4403 Debug Info: Only bind the archetypes referenced by variable types early
at -Onone.

Thanks to rjmccall for the feedback!
2016-03-04 16:54:15 -08:00
Roman Levenstein
5eca6e4df4 Get rid of a workaround for the JIT symbol lookup.
The underlying LLVM JIT problem is solved now and there is no need for any workarounds.
2016-03-03 16:03:50 -08:00
Joe Groff
be71ab28e2 SIL: Add an MarkUninitializedBehavior instruction for behavior DI.
This instruction creates a "virtual" address to represent a property with a behavior that supports definite initialization. The instruction holds references to functions that perform the initialization and 'set' logic for the property. It will be DI's job to rewrite assignments into this virtual address into calls to the initializer or setter based on the initialization state of the property at the time of assignment.
2016-03-03 15:04:38 -08:00
Max Moiseev
cf4bafe9e3 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-03 13:22:03 -08:00
David Farler
e958f99acf Revert "Mangle declared interface type into NominalTypeDescriptor's Name"
This reverts commit 2262bd579a.

This information isn't necessary for field descriptor lookup,
after all. It's only the fields that need to have generic information,
which is already in the field descriptor.
2016-03-03 12:55:35 -08:00
David Farler
2262bd579a Mangle declared interface type into NominalTypeDescriptor's Name
Previously, the mangling didn't include generics, but these are
needed to key off of the new field descriptor metadata, as well
as to construct type references for the nominal type.
2016-03-03 12:14:38 -08:00
Slava Pestov
b3103ac7b7 Runtime: Fix alignment issue in default witness tables
The size of a protocol's metadata was not a multiple of 8 bytes, so
on 64-bit platforms, the runtime would copy default witnesses from
the wrong address, because IRGen metadata does not add alignment padding,
whereas the in-memory structure does.

Fix this by adding a 32-bit padding field at the end of the protocol
descriptor. Technically this is not necessary on 32-bit, but this keeps
things simpler for now.

The test case for this is a library evolution test exercising resilient
default protocol requirements, but it is not quite ready to go in yet.
2016-03-03 07:36:59 -08:00
Slava Pestov
874607ba48 SIL: Include all witnesses in SILDefaultWitnessTable, not just resilient defaults
Previously SILDefaultWitnessTables only included "resilient" default
implementations, which are currently defined as those that appear at the
end of a protocol, after any requirements without defaults.

However, this was too inflexible. Instead, include all entries in the
SILDefaultWitnessTable, with invalid entries standing in for requirements
without defaults.

Previously, the minimum witness table size was a separate parameter, also
appearing in SIL syntax; now it can be calculated by looking at the entries
themselves. The getResilientDefaultEntries() method of SILDefaultWitnessTable
returns the same result as getEntries() did previously.
2016-03-03 07:00:20 -08:00
David Farler
744806a742 [Reflection] Add Foreign, ObjC, and Opaque type references
These likely don't have Swift type metadata but might be useful to
record or instantiate based on what kind of metadata is encountered for
the sake of memory tools.
2016-03-02 21:25:04 -08:00
practicalswift
77e777ded0 Merge pull request #1510 from practicalswift/fix-c-style-comment
[gardening] When using C style comments, stick to the one line form.
2016-03-02 21:24:29 +01:00
Adrian Prantl
7d0b345772 Emit type metadata for values referenced by debug info eagerly at -Onone.
This is a hotfix for recent regressions in the LLDB testsuite caused
by lazy loading of metadata.

Long-term we will explore emitting DWARF expressions for accessing the
type metadata.

rdar://problem/24781494, SR-797
2016-03-02 12:03:10 -08:00
Xin Tong
6d006adbcc Revert "Debug Info: Don't emit shadow stack copies for local variables."
This reverts commit 1cb9c24b2f.

Broke OSX incremental build and others.
2016-03-02 07:55:33 -08:00
practicalswift
795b86004b [gardening] When using C style comments, stick to the one line form.
In the rare cases where C style comments are needed sticking with the
one line form is preferred to allow for quick comment analysis by
simple methods such as:

$ git grep -E '(//|/\*.*\*/)'

When using the single line form the command above is guaranteed to
include all comment content (+ some non-comment content), which
greatly simplifies quick comment analysis.
2016-03-02 10:06:55 +01:00
Adrian Prantl
1cb9c24b2f Debug Info: Don't emit shadow stack copies for local variables.
The effect of this tiny change is that local variables will be described
by llvm.dbg.values, which will get lowered into an accurate location list
instead of a stack slot that is valid for the entire scope of the variable.
This means the debugger can now accurately track the liveness of variables
knowing exactly when they are initialized and when there values go away.
Function arguments are still kept in stack slots because (1) they are
already initialized at the function entry and (2) LLDB really needs self
to be available at all times for the expression evaluator.

This was made possible by recent advancements in LLVM such as the live
debug variables pass and various related bugfixes.

<rdar://problem/15746520>
2016-03-01 18:47:34 -08:00
Joe Groff
2ac5b8b3ee Update outdated comment. NFC 2016-03-01 16:39:06 -08:00
swiftix
2573782c8b Merge pull request #1357 from swiftix/wip-runtime-calling-convention
Prepare the ground for using a new calling convention for functions from the runtime library
2016-03-01 16:22:37 -08:00
Max Moiseev
859db53d87 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-01 12:56:26 -08:00
AnnaZaks
767d9ca914 Merge pull request #1434 from apple/asan
[asan] Add basic support for Address Sanitizer function instrumentation
2016-02-29 18:58:40 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Michael Gottesman
aebc5baf84 Add a new frontend option for debugging called '-disable-incremental-llvm-codegen'.
Currently IRGen stores hashes of the bitcode generated by swift in object files.
This is then used to reduce compile time by not re-codegening if a subsequent
compilation yields a bit code with the same hash.

This is good for users and general compilation, but can result in confusion when
attempting to measure the "real" compile time of the compiler.

By default it is off.
2016-02-28 18:50:19 -08:00
Andrew Trick
445cdff829 Merge pull request #1468 from atrick/attr-kind
Move enums into AttrKind.h.
2016-02-27 21:20:11 -08:00
Mark Lacey
11e56f67fd Sort file names in IRGen/CMakeLists.txt. 2016-02-26 21:40:46 -08:00
Andrew Trick
ff02652108 Move enums into AttrKind.h.
This reorganization allows adding attributes that refer to types.
I need this for a @_specialize attribute with a type list.

PrintOptions.h and other headers depend on these enums. But Attr.h
defines a lot of classes that almost never need to be included.
2016-02-26 21:10:22 -08:00
zaks
2110235fd3 [asan] Cleanup based on Jordan's review comments 2016-02-26 16:02:40 -08:00
Nadav Rotem
4380075e7f [IRGen] Fix an unused variable warning. 2016-02-26 14:55:34 -08:00
Adrian Prantl
310b0433a9 Reapply "Serialize debug scope and location info in the SIL assembler language.""
This ireapplies commit 255c52de9f.

Original commit message:

Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 13:28:57 -08:00
Adrian Prantl
255c52de9f Revert "Serialize debug scope and location info in the SIL assembler language."
Temporarily reverting while updating the validation test suite.

This reverts commit c9927f66f0.
2016-02-26 11:51:57 -08:00
Chris Lattner
fe8d814ec2 add some newlines to silence warnings. 2016-02-26 11:30:47 -08:00
Adrian Prantl
c9927f66f0 Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 10:46:29 -08:00
John McCall
4c74d97f16 Remove some now-unnecessary special code for binding archetypes
in associated type accessors.

The only remaining use of getAll{DependentTypes,Archetypes} in IRGen
is in code that interprets Substitution arrays, which is unavoidable
absent a change to that representation.
2016-02-25 12:49:30 -08:00
Adrian Prantl
13203bf749 Fix a crash when building the swift stdlib caused by the debug info
for a alloc_stack, debug_value, and debug_value_addr disagreeing on the
type of the same variable.

For -Onone, this commit is NFC.

A testcase for generic specialization will follow as soon as SIL debug
info serialization efforts are complete.
<rdar://problem/24785336>
2016-02-25 12:36:06 -08:00
Max Moiseev
488b464f10 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-25 12:21:56 -08:00
John McCall
3ce1ba3e65 Only store the minimal requirements in generic metadata, where
"minimal" is defined as the set of requirements that would be
passed to a function with the type's generic signature that
takes the thick metadata of the parent type as its only argument.
2016-02-25 10:33:33 -08:00