Commit Graph

1020 Commits

Author SHA1 Message Date
Michael Gottesman
34ec32bc14 [semantic-arc] Handle the rest of the unqualified mem opts in SILGen.
Keep in mind that these are approximations that will not impact correctness
since in all cases I ensured that the SIL will be the same after the
OwnershipModelEliminator has run. The cases that I was unsure of I commented
with SEMANTIC ARC TODO. Once we have the verifier any confusion that may have
occurred here will be dealt with.

rdar://28685236
2016-11-09 11:37:52 -08:00
practicalswift
106c63e396 [gardening] Use American English: "analyse" → "analyze" 2016-11-06 14:13:45 +01:00
Michael Gottesman
05c5fcca95 [gardening] Now that the old TypeLowering::LoweringStyle::Deep is gone, rename TypeLowering::LoweringStyle::DeepNoEnum => TypeLowering::LoweringStyle::Deep. 2016-10-30 18:39:31 -07:00
Michael Gottesman
bffa7addaf [semantic-arc] Eliminate default {Load,Store}OwnershipQualification argument to SILBuilder::create{Load,Store}(...)
Today, loads and stores are treated as having @unowned(unsafe) ownership
semantics. This leaves the user to specify ownership changes on the loaded or
stored value independently of the load/store by inserting ARC operations. With
the change to Semantic SIL, this will no longer be true. Instead loads, stores
have ownership semantics that one must reason about such as copy, take, and
trivial.

This change moves us closer to that world by eliminating the default
OwnershipQualification argument from create{Load,Store}. This means that the
compiler developer cannot ignore reasoning about the ownership semantics of the
memory operation that they are creating.

Operationally, this is a NFC change since I have just gone through the compiler
and updated all places where we create loads, stores to pass in the former
default argument ({Load,Store}OwnershipQualifier::Unqualified), to
SILBuilder::create{Load,Store}(...). For now, one can just do that in situations
where one needs to create loads/stores, but over time, I am going to tighten the
semantics up via the verifier.

rdar://28685236
2016-10-30 13:07:06 -07:00
Michael Gottesman
e1dab994aa [semantic-arc] When cloning a function, propagate forward the qualified ownership bit.
rdar://28851920
2016-10-29 20:11:06 -07:00
Michael Gottesman
a1f489f450 [semantic-arc] Make sure to use TypeLowering methods in the OwnershipModelEliminator when creating lowered ARC operations.
Since we set the unqualified flag before we eliminate any instructions, this
will do the *right* thing and emit the most optimal lowered representation
whether it is a strong_* or *_value instruction.

This ensures that passes that expect values to have the most lowered
representation of instruction to be able to pattern match correctly.

This can up when alloc-box-to-stack was pattern matching on strong_retain on
Boxes, but I was being lazy and emitted retain_value.

rdar://28851920
2016-10-29 20:11:06 -07:00
Bob Wilson
b227f45b7e Merge remote-tracking branch 'origin/master' into master-next 2016-10-27 22:28:28 -07:00
Michael Gottesman
f9b4ac714b [semantic-arc] Make sure that the ownership model eliminator sets the unqualified flag before it runs.
Otherwise, we will trigger verification in SILBuilder?!

rdar://28851920
2016-10-25 22:31:05 -07:00
Andrew Trick
a296ced6df Generic inline (#5467)
* [sil-performance-inliner] Re-factor the isProfitableToInline logic. NFC.

* [sil-performance-inliner] Introduce a pre-filter to decide of a generic function should be inlined

This logic is unconditional and is does not require any complex cost models.
The outcome of the check is one of:
- yes, inline this generic function
- no, do not inline this generic function
- None, don't know if it should be inline. Further more complex checks are required.

* [sil-performance-inliner] Handle inlining of generic functions into cold blocks

Generic functions should be inlined into cold blocks only if they should be unconditionally inlined (e.g. when they are always_inline or transparent).

* Allow generic inlining under -sil-inline-generics.
2016-10-25 17:27:02 -07:00
Michael Gottesman
8b41745b37 [semantic-arc] Change TypeLowering APIs to use the words {Copy,Destroy}Value instead of {Retain,Release}Value. NFC.
This is an attempt to separate functional from superficial changes in the
semantic arc changes.

rdar://28851920
2016-10-24 23:49:11 -07:00
Joe Groff
e4c67e2d5a SIL: Give project_box a field index operand.
Allow project_box to get the address of any field in a multi-field box.
2016-10-24 13:10:41 -07:00
Michael Gottesman
bb9197c7ff [semantic-arc] Move the Ownership Model Eliminator and management of SILFunction::hasQualifiedOwnership in front of SILOptions::EnableSILOwnership.
This is a NFC change, since verification still will be behind the flag. But this
will allow me to move copy_value, destroy_value in front of the
EnableSILOwnership flag and verify via SILGen that we are always using those
instructions.

rdar://28851920
2016-10-23 18:30:43 -07:00
Michael Gottesman
813facfcff [gardening] Refactor out setting Insertion Point and Debug Scope from each visitor to beforeVisit in the OwnershipModelEliminator. 2016-10-22 22:26:07 -07:00
Michael Gottesman
271e3909df [semantic-arc] Implement OwnershipModelEliminator support for copy_value, destroy_value.
rdar://28851920
2016-10-22 22:26:06 -07:00
Michael Gottesman
b0539a9a15 [semantic-arc] Only run the ownership model eliminator on functions with qualified ownership and make it after running change such functions to have unqualified ownership.
rdar://28685236
2016-10-21 17:42:39 -07:00
Michael Gottesman
85269c767a [semantic-arc] Implement eliminating end_borrow and load_borrow from the OwnershipModelEliminator.
rdar://28685236
2016-10-20 12:30:18 -07:00
Michael Gottesman
abaed64e20 [semantic-arc] Refactor the ownership model eliminator to use a visitor type.
rdar://28685236
2016-10-20 12:24:15 -07:00
Doug Gregor
dc2777e283 Revert "[sil-performance-inliner] Re-introduce inlining of generics as a staging feature behind a flag" 2016-10-19 15:15:59 -07:00
Roman Levenstein
91f5b9dac1 [sil-performance-inliner] Re-introduce inlining of generics as a staging feature behind a flag
Use the following options to enable this flag: -Xllvm -sil-inline-generics

Generic inlining is now handled by a dedicated logic in isProfitableToInlineGeneric. This makes it easier to find this logic. And it will make it easier to extend and improve it in the future.

The initial policy for generic inlining is:
- unconditionally inline generic functions if the -sil-inline-generics flag is used.
- If the flag is not used, only perform generic inlining of always_inline and transparent functions.

There are slight standard library's code-size regressions with this policy. They will be addressed by the future work on the generic inlining.
2016-10-18 16:52:50 -07:00
Bob Wilson
1caba3e209 Merge remote-tracking branch 'origin/master' into master-next 2016-10-17 11:52:21 -07:00
practicalswift
265a4605a0 [gardening] Fix typos. 2016-10-16 12:53:49 +02:00
practicalswift
5d7bf22381 [gardening] Improve header consistency 2016-10-16 12:41:09 +02:00
Michael Gottesman
e48e7b7fca [semantic-arc] Add a new pass called the OwnershipModelEliminator that eliminates SILOwnership from the IR.
It currently just breaks up qualified loads/stores into their unqualified
constituant parts.

rdar://28685236
2016-10-15 21:35:34 -07:00
Bob Wilson
8e3226096e Use pointer_iterator for GraphTraits nodes_iterators.
llvm r279326 changed to consistently dereference iterators to pointers,
so we need to do the same for several of the GraphTraits iterators.
2016-10-15 11:02:20 -07:00
practicalswift
ae5542609e [gardening] Fix accidental \t:s 2016-10-13 20:24:09 +02:00
Roman Levenstein
785b4ebf48 Merge pull request #5262 from swiftix/wip-generics-inlining-flag
[sil-performance-inliner] Re-factoring: Split the performance inliner into a main driver and a set of utility files. NFC.
2016-10-12 17:29:29 -07:00
Roman Levenstein
0cc7043599 [sil-performance-inliner] Re-factoring: Split the performance inliner into a main driver and a set of utility files. NFC.
- Move the common performance inliner functionality into PerformanceInlinerUtils.cpp.
- Move the functionality specific to non-generic inlining into NonGenericPerformanceInliner.cpp
- Temporarily disable the inlining of generics. It will be enabled in the subsequent commit.
2016-10-12 16:48:06 -07:00
Francis Ricci
66dcad0d34 SIL: Avoid dereferencing sentinel nodes in ilist_iterators
The behaviour of ilist has changed in LLVM.  It is no longer permissible to
dereference the `end()` value.  Add a check to ensure that we do not
accidentally dereference the iterator.
2016-10-12 11:46:31 -07:00
Joe Shajrawi
b05d3c2985 Merge pull request #5138 from shajrawi/copy_addr_to_moves
Comment on why we can't replace copy_addr instructions with moves in arc-inert blocks
2016-10-11 16:50:50 -07:00
Joe Shajrawi
13b7bd5775 Add a discussion that sums-up why we can’t replace copy_addr with moves in ARC-inert BBs 2016-10-11 15:54:33 -07:00
Roman Levenstein
7cc11a56ec [sil-inliner] Introduce a staging flag to enable the inlining of generics.
Use the following options to enable this flag: -Xllvm -sil-inline-generics
2016-10-11 10:10:52 -07:00
Roman Levenstein
20a6d35985 Fix a case of ArrayRef capturing compiler temps.
Fixes rdar://28684618
2016-10-08 17:50:09 -07:00
practicalswift
2e9b699f48 Merge pull request #4837 from practicalswift/typo-fixes-20160916b
[gardening] Fix recently introduced typos
2016-09-16 21:21:53 +02:00
practicalswift
7c63623ffc [gardening] Fix 13 recently introduced typos. 2016-09-16 20:30:57 +02:00
Erik Eckstein
bd0d2bfed4 Remove the LLVM stack promotion pass and related SIL optimization logic.
It's not needed anymore because array buffers are now allocated with alloc_ref instead of a swift_bufferAllocate runtime call.
2016-09-16 11:02:19 -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
Xin Tong
d00cec75db If we do not move the retain/release instruction, we do not need to
delete it and recreate new one

This is a compilation time improvement

There are a few small modifications to the tests, as we try to create
different, but equivalent retain/release before even though we can reuse
the old ones.

rdar://28329689
2016-09-15 20:51:32 -07:00
swift-ci
40483d470a Merge pull request #4767 from practicalswift/inconsistent-headers 2016-09-15 12:14:44 -07:00
Roman Levenstein
a4a1432989 [sil-stack-promotion] Don't try to promote an already promoted allocation.
It just saves some compile time. NFC.
2016-09-15 08:17:49 -07:00
Dmitri Gribenko
fbb3cf35a5 Revert "New SIL instructions to support tail-allocated arrays in SIL." 2016-09-15 00:25:25 -07:00
eeckstein
644dfc1b81 Merge pull request #4722 from eeckstein/tail-alloc
New SIL instructions to support tail-allocated arrays in SIL.
2016-09-14 20:36:11 -07:00
Erik Eckstein
6ae818c9d1 Remove the LLVM stack promotion pass and related SIL optimization logic.
It's not needed anymore because array buffers are now allocated with alloc_ref instead of a swift_bufferAllocate runtime call.
2016-09-14 14:54:18 -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
practicalswift
9185c052a9 [gardening] Fix inconsistent headers 2016-09-14 20:48:28 +02:00
Slava Pestov
185921f6ab AST: Remove slow version of Substitution::subst()
When applying substitutions to substitution lists in SIL, we would
unpack the ArrayRef<Substitution> into a SubstitutionMap on each
iteration over the original ArrayRef<Substitution>. Discourage
this sort of thing by removing the API in question and refactoring
surrounding code.
2016-09-13 22:58:58 -07:00
Xin Tong
0ad481cd8b Rename RetainRelease to ARC. NFC 2016-09-13 16:01:39 -07:00
Xin Tong
dff83e993a Rename RetainReleaseCodeMotion to ARCCodeMotion
This is usually how we call things that deal retains and releases
2016-09-13 15:54:12 -07:00
Xin Tong
bfc7924995 Merge pull request #4748 from trentxintong/wireup-FSO
Wire up new epilogue release matcher with DSE and RLE
2016-09-13 11:32:30 -07:00
Xin Tong
65ba367beb Wire up new epilogue release matcher with DSE and RLE
rdar://26446587
2016-09-13 10:58:28 -07:00