Commit Graph

1118 Commits

Author SHA1 Message Date
eeckstein
b861853f53 Merge pull request #6912 from eeckstein/dead-conf-elim
Remove dead witness tables, including dead witness functions.
2017-01-19 14:11:12 -08:00
swift-ci
0e8dc4443d Merge pull request #6916 from gottesmm/unmanaged_retainrelease_value 2017-01-19 14:05:08 -08:00
Michael Gottesman
2da18c7b47 [semantic-sil] Add special unmanaged_{retain,release}_value instructions for unpaired retain/release operations in semantic sil.
The reason why I am introducing special instructions is so I can maintain the
qualified ownership API wedge in between qualified SIL and the rest of the ARC
instructions that are pervasively used in the compiler.

These instructions in the future /could/ be extended to just take @sil_unmanaged
operands directly, but I want to maintain flexibility to take regular
non-trivial operands in the short term.

rdar://29791263
2017-01-19 13:23:08 -08:00
Erik Eckstein
89c9ff5ca0 SIL: ConformanceCollector utility for collecting all conformances which are used by a SIL instruction.
Also verify the correctness of ConformanceCollector in IRGen by checking if IRGen does not use a conformance which is not collected by the utility.
2017-01-19 09:41:09 -08:00
Arnold Schwaighofer
1f914eb4c4 Silence warn_unused_result warnings 2017-01-18 15:20:27 -08:00
Adrian Prantl
bb55c6d8a6 Clean up the constructors of DebugTypeInfo
and ensure that the DeclContext of the SILFunction is used when
mangling substituted archetypes found in inlined variable declarations
that have been reparented into the caller

<rdar://problem/28859432>
2017-01-13 15:56:27 -08:00
AnnaZaks
1122ebd731 Merge pull request #6453 from apple/asan
[tsan] Do not report races coming from deinitializers and _Block_release
2017-01-06 11:50:28 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Anna Zaks
18c10c566f [tsan] Do not report races coming from deinitializers and _Block_release
TSan does not observe the guaranteed syncronization between the ref
count drop to zero and object destruction. This can lead to false positive
reports.

This patch adds an attribute to deinitializers to ignore memory accesses
at run time. It also moves the logic to add sanitizer attributes from
IRGenFunction to IRGenSILFunction, which means that the automatically
generated code such as _Block_release handler will not be instrumented
and the accesses made in them will be invisible to TSan.

Solves a problem similar to what's addressed in clang commit:
https://reviews.llvm.org/D25857
2017-01-05 10:26:25 -08:00
practicalswift
f05a338e9a [gardening] Prefer (!foo) to (foo == false). Fix typo. 2016-12-21 21:25:58 +01:00
Arnold Schwaighofer
ebf63def8e IRGen: A lowered address can either be the address in a container or a regular address
When we optimize existential buffer allocation we stored a ContainedAddress (container and
uninitialized address) if we delay the buffer allocation to the first copy_addr [init].
2016-12-21 10:01:03 -08:00
Arnold Schwaighofer
a87f34372e Rename SILFunction::entryBB to getEntryBlock 2016-12-20 07:51:55 -08:00
Arnold Schwaighofer
cd1037b799 IRGen: Allocate generic/resilient values on the stack instead of on the heap
Allocate buffers for local generic/resilient values on the stack. alloc_stack
instructions in the entry block are translated using a dynamic alloca
instruction with variables size. All other alloc_stack instructions in addition
use llvm's stacksave/restore instrinsics to reset the stack (they could be
executed multiple times and with varying sizes).
2016-12-20 07:24:02 -08:00
Michael Gottesman
96c63e9e76 Merge pull request #6324 from practicalswift/cpp-gardening
[gardening] C++ gardening: Terminate namespaces, fix argument names, …
2016-12-16 23:30:33 -08:00
Joe Groff
4444d83756 SIL: Lower captures to boxes with an appropriate generic context.
Officially kick SILBoxType over to be "nominal" in its layout, with generic layouts structurally parameterized only by formal types. Change SIL to lower a capture to a nongeneric box when possible, or a box capturing the enclosing generic context when necessary.
2016-12-16 20:23:25 -08:00
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
Michael Gottesman
6213550239 [semantic-sil] Create copy_unowned_value.
This was in the first high level ARC instruction proposal, but I have not needed
it until now. The use case for this is to ahandle strong_retain_unowned (which
takes in an unowned value, asserts it is still alive, performs a strong_retain,
and returns the @owned value). This @owned value needs a destroy_value.

rdar://29671437
2016-12-14 19:22:24 -08:00
Michael Gottesman
66cff7e37e [semantic-arc] Add StoreBorrowInst and BeginBorrowInst. 2016-12-12 13:06:18 -08:00
Joe Groff
3871cda205 Push SILBoxType::getFieldType into SIL and make it take a SILModule.
Applying nontrivial generic arguments to a nontrivial SIL layout requires lowered SILType substitution, which requires a SILModule. NFC yet, just an API change.
2016-12-09 16:21:13 -08:00
Joe Groff
13bb6c649a SIL: Remove AllocBoxInst::getElementType().
There's no longer a single element type to speak of. Update uses to either iterate all box fields or to assert that they're working with a single-field box.
2016-12-02 16:37:34 -08:00
Hugh Bellamy
1aa951dfb2 Fix errors and warnings building swift/IRGen on Windows using MSVC (#5958) 2016-11-30 13:27:02 -08:00
Michael Gottesman
38ec08f45f [gardening] Standardize SILBasicBlock successor/predecessor methods that deal with blocks rather than the full successor data structure to have the suffix 'Block'.
This was already done for getSuccessorBlocks() to distinguish getting successor
blocks from getting the full list of SILSuccessors via getSuccessors(). This
commit just makes all of the successor/predecessor code follow that naming
convention.

Some examples:

getSingleSuccessor() => getSingleSuccessorBlock().
isSuccessor() => isSuccessorBlock().
getPreds() => getPredecessorBlocks().

Really, IMO, we should consider renaming SILSuccessor to a more verbose name so
that it is clear that it is more of an internal detail of SILBasicBlock's
implementation rather than something that one should consider as apart of one's
mental model of the IR when one really wants to be thinking about predecessor
and successor blocks. But that is not what this commit is trying to change, it
is just trying to eliminate a bit of technical debt by making the naming
conventions here consistent.
2016-11-27 12:32:51 -08:00
Michael Gottesman
96837babda Merge pull request #5920 from gottesmm/vacation_gardening
Vacation gardening
2016-11-25 09:17:21 -06:00
Michael Gottesman
bf6920650c [gardening] Drop BB from all argument related code in SILBasicBlock.
Before this commit all code relating to handling arguments in SILBasicBlock had
somewhere in the name BB. This is redundant given that the class's name is
already SILBasicBlock. This commit drops those names.

Some examples:

getBBArg() => getArgument()
BBArgList => ArgumentList
bbarg_begin() => args_begin()
2016-11-25 01:14:36 -06:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Adrian Prantl
dddd998c6d Push the debug info for the artificial error inout argument up to SIL.
Previously IRGen was using a heuristic to assign the argument number
to the $error variable that was not generally correct for optimizaed
code. This patch inserts a debug_value instruction in SILGen and thus
assigns the ArgNo together with all the other function arguments. This
is more robust and faster than than the old heuristic.

<rdar://problem/28748323>
2016-10-26 16:22:15 -07:00
Michael Gottesman
ab0ffa2c39 [semantic-arc] Wire up Parsing/Printing/IRGen/Serialization/Deserialization for copy_value, destroy_value.
rdar://28851920
2016-10-22 22:10:57 -07:00
Michael Gottesman
c41ead0b72 [semantic-arc] Add support for the load_borrow and end_borrow instructions to SIL, Serialization, Printing/Parsing.
I did not add it to the ownership verifier or to IRGen yet.

rdar://28685236
2016-10-20 10:53:44 -07:00
Joe Groff
aac85cb93f SIL: Introduce a 'closure' convention for unapplied invocation functions.
We don't want the machine calling conventions for closure invocation functions to necessarily be tied to the convention for normal thin functions or methods. NFC yet; for now, 'closure' follows the same behavior as the 'method' convention, but as part of partial_apply simplification it will be a requirement that partial_apply takes a @convention(closure) function and a box and produces a @convention(thick) function from them.
2016-10-17 15:55:04 -07:00
Michael Gottesman
8463e63df2 [semantic-arc] Implement IRGen support for ownership qualified load/store.
rdar://28685236
2016-10-15 19:33:02 -07:00
Huon Wilson
741c46b769 Merge pull request #4814 from huonw/sr-716-constant-struct-with-padding
SR 716: handle constant structs with padding
2016-10-06 10:08:18 -07:00
Erik Eckstein
db00c5e924 SIL: allow alloc_ref_dynamic to allocate tail elements.
It's the same thing as for alloc_ref: the optional [tail_elems ...] attribute specify the tail elements to allocate.
For details see docs/SIL.rst

This feature is needed so that we can allocate a MangedBuffer with alloc_ref_dynamic.
The ManagedBuffer.create() function uses the dynamic self type to create the buffer instance.
2016-10-06 08:46:23 -07:00
Huon Wilson
25b41906a2 [IRGen] Handle padding in global structs.
Previously there was a mismatch between SIL's concept of a
struct (padding is implicit) and LLVM's (padding is explicit) in IRGen's
constant evaluator. The explicit padding fields need to be given a value
in the IR.

This patch also moves the (currently small) list of constant evaluation
functions into their own file.

Fixes SR-716.
2016-09-29 05:21:49 -07:00
Adrian Prantl
7c763e6f72 Fix a compile time performance regression caused by redundant debug info.
Even at -Onone one SILValue can back up more than one local source variable.
This commit changes the list of variable values into a set.

<rdar://problem/28467349>
2016-09-26 17:33:20 -07:00
Adrian Prantl
c70d101ab0 Debug info: When skipping over cleanup locations in the middle of a
basic block, revert to line number 0 instead of reusing the last location.
This avoids emitting illegal IR if there was no previous location and the
instruction being emitted is a function call.

rdar://problem/28237133
2016-09-24 17:48:04 -07:00
Erik Eckstein
34a4e6df0a SIL: add new instructions to support tail-allocated arrays in SIL.
The new instructions are: ref_tail_addr, tail_addr and a new attribute [ tail_elems ] for alloc_ref.
For details see docs/SIL.rst

As these new instructions are not generated so far, this is a NFC.
2016-09-16 11:02:19 -07:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Dmitri Gribenko
fbb3cf35a5 Revert "New SIL instructions to support tail-allocated arrays in SIL." 2016-09-15 00:25:25 -07:00
Doug Gregor
ab70291b82 [IRGen] Handle 'super' method sends in ObjC partial application forwarders.
The Objective-C partial application forwarder that one gets when
using, e.g., "super.foo" as a function value was doing a normal
objc_msgSend. Fix the miscompile by threading all of the information
about the Objective-C message send through the forwarder.

Fixes rdar://problem/28140758.
2016-09-14 21:12:45 -07:00
Erik Eckstein
b11b60e658 SIL: add new instructions to support tail-allocated arrays in SIL.
The new instructions are: ref_tail_addr, tail_addr and a new attribute [ tail_elems ] for alloc_ref.
For details see docs/SIL.rst

As these new instructions are not generated so far, this is a NFC.
2016-09-14 14:54:18 -07:00
Adrian Prantl
56b7b08415 Debug Info: Handle vector types when extending variable live ranges.
rdar://problem/27891980
2016-08-17 18:53:18 -07:00
Joe Groff
42527ed18b IRGen: Don't attempt to emit debug info for type-erased generic params.
Fixes a crash when emitting debug info for ObjC generic extensions. Part of rdar://problem/26867815.
2016-08-11 14:38:16 -07:00
swift-ci
1f5301f0ec Merge pull request #3869 from adrian-prantl/25427596 2016-08-01 14:32:25 -07:00
Adrian Prantl
4136f07072 Debug Info: Use artificial locations for emitting aggregate shadow copies.
<rdar://problem/25427596>
2016-07-29 15:10:27 -07:00
Adrian Prantl
6e61b33584 Debug Info: Propagate dbg.value intrinsics into basic blocks that
contain a variable live range extension intrinsic.

This is working around a shortcoming of LLVM.
LiveDebugValues should be doing this but can't in general because it
currently only tracks register locations.

rdar://problem/27348117
2016-07-29 14:12:57 -07:00
Mark Lacey
122827ea00 Only emit empty inline asm instructions for cond_fail when optimizing.
These inline asm instructions are used to block branch folding when
optimizing, to ensure that we have unique trap locations (and associated
debug info) for each cond_fail.

We only need these when we're optimizing, and emitting them can block
fast isel, so only emit them when optimizing.
2016-07-26 15:38:47 -07:00
Adrian Prantl
3b3e308ed3 IRGenDebugInfo: Pass in the VarDecl separatly when emitting variables. (NFC) 2016-07-21 16:03:49 -07:00
Luke Larson
74e0498015 Revert "Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs."
This reverts commit 62d1fa760c.
2016-07-19 15:18:17 -07:00
Mishal Shah
62d1fa760c Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-07-19 22:31:34 +02:00
Andrew Trick
2b732d0af5 Introduce Builtin.bindMemory and SIL bind_memory. (#3573)
Required for SE-0107: UnsafeRawPointer.
2016-07-18 13:18:03 -07:00