Commit Graph

2592 Commits

Author SHA1 Message Date
Erik Eckstein
cceb2a4b66 DeadObjectElimination: reuse code
NFC
2020-05-14 14:38:44 +02:00
swift_jenkins
f375a35b29 Merge remote-tracking branch 'origin/master' into master-next 2020-05-14 02:19:22 -07:00
Erik Eckstein
8f2632939a Builtins to support copy-on-write SIL instructions
* Builtin.COWBufferForReading -> ref_element_addr [immutable] / ref_tail_addr [immutable]
* Builtin.beginCOWmutation -> begin_cow_mutation
* Builtin.endCOWmutation -> end_cow_mutation
2020-05-14 08:39:54 +02:00
swift_jenkins
10e1981971 Merge remote-tracking branch 'origin/master' into master-next 2020-05-13 13:37:47 -07:00
swift-ci
f90e0306bf Merge pull request #31690 from hamishknight/guilt-by-association 2020-05-13 13:26:58 -07:00
swift_jenkins
03c616626c Merge remote-tracking branch 'origin/master' into master-next 2020-05-12 01:38:59 -07:00
swift-ci
0560f8c427 Merge pull request #31133 from zoecarver/lva/dead-access 2020-05-12 01:32:47 -07:00
zoecarver
e22e7bcb20 [LVA] Support access instructions in DCE.
Simple check for the following pattern:
x = begin_access
end_access x
2020-05-11 23:18:00 -07:00
swift_jenkins
d5b48a87bf Merge remote-tracking branch 'origin/master' into master-next 2020-05-11 06:59:36 -07:00
Michael Gottesman
2599421c3b [semantic-arcopts] Teach optimizer how to convert load [copy] -> load_borrow from inout parameters that only have writes that do not overlap with the lifetime region of the load [copy]'s result.
rdar://58667192
2020-05-10 23:49:00 -07:00
Hamish Knight
2d9b63ed11 A SILModule Always Has An Associated Context
Now that the integrated REPL has been removed,
there is always an associated decl context, and
we can assert as such.
2020-05-10 19:56:12 -07:00
swift_jenkins
64add03f2e Merge remote-tracking branch 'origin/master' into master-next 2020-05-08 11:45:03 -07:00
Zoe Carver
3d532cbf35 Merge pull request #31134 from zoecarver/lva/ignore-in-dse
[LVA] Update ignore instructions RLE and DSE.
2020-05-08 11:07:47 -07:00
zoecarver
34ad7d0891 [LVA] Update ignore instructions RLE and DSE.
RLE can ignore end_access, set_deallocating, and dealloc_ref instructions.

DSE can ignore end_access and set_deallocating.
2020-05-07 08:48:17 -07:00
swift_jenkins
c60a485196 Merge remote-tracking branch 'origin/master' into master-next 2020-05-06 12:35:16 -07:00
Arnold Schwaighofer
970c27248f Merge pull request #31470 from aschwaighofer/fix_rdar62560867
SIL: Thread type expansion context through to function convention apis
2020-05-06 11:52:19 -07:00
swift_jenkins
46cddecf3d Merge remote-tracking branch 'origin/master' into master-next 2020-05-05 14:17:17 -07:00
swift-ci
75623f9358 Merge pull request #31565 from zoecarver/fix/bb-print-method 2020-05-05 14:01:20 -07:00
zoecarver
db553f2f04 [NFC] Remove ostream argument from SILBasicBlock::print.
The first argument, OS, was never used in the SILBasicBlock::print method. Keeping it would be misleading.
2020-05-05 11:42:53 -07:00
Arnold Schwaighofer
147144baa6 SIL: Thread type expansion context through to function convention apis
This became necessary after recent function type changes that keep
substituted generic function types abstract even after substitution to
correctly handle automatic opaque result type substitution.

Instead of performing the opaque result type substitution as part of
substituting the generic args the underlying type will now be reified as
part of looking at the parameter/return types which happens as part of
the function convention apis.

rdar://62560867
2020-05-04 13:53:30 -07:00
swift_jenkins
d732e19ada Merge remote-tracking branch 'origin/master' into master-next 2020-04-29 05:58:54 -07:00
Arnold Schwaighofer
4e1eb697da Outliner: Fix an iterator problem
We iterate from the bridged optional to the bridged apply, make sure
they are in the same block.

rdar://62494475
2020-04-28 08:22:23 -07:00
swift_jenkins
cb6baf756a Merge remote-tracking branch 'origin/master' into master-next 2020-04-27 19:30:31 -07:00
Meghana Gupta
013387eceb Update Devirtualizer's analysis invalidation (#31284)
* Update Devirtualizer's analysis invalidation

castValueToABICompatibleType can change CFG, Devirtualizer uses this api but doesn't check if it modified the cfg
2020-04-27 18:30:33 -07:00
swift_jenkins
219b4bb970 Merge remote-tracking branch 'origin/master' into master-next 2020-04-23 23:38:23 -07:00
Erik Eckstein
0f8c2fbc25 TempRValueOpt: fix a compile time crash in tryOptimizeStoreIntoTemp
Bail if there is any kind of user which is not handled in this transformation.
2020-04-23 15:22:50 +02:00
swift_jenkins
cd98af90ed Merge remote-tracking branch 'origin/master' into master-next 2020-04-23 02:17:23 -07:00
ematejska
4cd68edf8c [Autodiff upstream] Add DifferentiabilityWitnessDevirtualizer SILOptimizer pass (#30984)
Add DifferentiabilityWitnessDevirtualizer: an optimization pass that
devirtualizes `differentiability_witness_function` instructions into
`function_ref` instructions.

Co-authored-by: Dan Zheng <danielzheng@google.com>
2020-04-23 02:13:05 -07:00
swift_jenkins
dd4741434d Merge remote-tracking branch 'origin/master' into master-next 2020-04-22 23:57:31 -07:00
Meghana Gupta
4613d945b7 Handle begin_apply in TempRVO (#31063)
* Handle begin_apply in TempRVO

A tempobj passed to begin_apply instruction and cannot be modified by it
(is guaranteed and doesn't alias with other inout args) can be optimzed
away.
2020-04-22 23:52:05 -07:00
swift_jenkins
202434c7eb Merge remote-tracking branch 'origin/master' into master-next 2020-04-22 06:57:21 -07:00
Arnold Schwaighofer
16540fcfa1 Merge pull request #31175 from aschwaighofer/fix_outliner_61911131
Outliner: Fix a use after release issue
2020-04-22 06:45:30 -07:00
swift_jenkins
cb41829e4e Merge remote-tracking branch 'origin/master' into master-next 2020-04-21 11:37:12 -07:00
Arnold Schwaighofer
8e2da8d0e2 Outliner: Fix a use after release issue
If there is a release of the bridged value in between the bridge call
and the objective-c call we need to account for that and can't just use
a guaranteed convention.

rdar://61911131
2020-04-21 07:21:53 -07:00
Michael Gottesman
ba1ac78758 [semantic-arc-opts] Use all consuming uses instead of just destroying uses when validating if a LiveRange is alive in a scope.
The reason why this is important is that if our destroy_value is elided due to
the destroy_value being in a dead end block, we can promote a load [copy] to a
load_borrow even if the load [copy] has a forwarding consuming use outside of a
begin_access region.

I changed every place in SemanticARCOpts that did this sort of thing to use this
pattern instead of just destroys so that no one cargo cults the original pattern
by mistake.

<rdar://problem/61774105>
2020-04-20 16:10:23 -07:00
swift_jenkins
c6579edf01 Merge remote-tracking branch 'origin/master' into master-next 2020-04-16 06:18:57 -07:00
Erik Eckstein
fe9368294f RedundantPhiElimination: exclude allocation instructions.
Treating allocation instructions as the same value caused runtime crashes.

https://bugs.swift.org/browse/SR-12606
2020-04-16 13:11:33 +02:00
swift_jenkins
bca1982953 Merge remote-tracking branch 'origin/master' into master-next 2020-04-15 15:17:38 -07:00
Michael Gottesman
3eda1ea712 [arc-opts] Teach IsAddressWrittenToDefUseAnalysis how to track "well behaved" writes but don't do use it.
In a future commit, I am going to build on this to promote load [copy] ->
load_borrow from inout arguments where none of the writes overlap the load
[copy]'s result's lifetime. By committing this separately, I am using the
current pass's logic to validate the change.
2020-04-15 12:23:10 -07:00
swift_jenkins
1ff7e55ac9 Merge remote-tracking branch 'origin/master' into master-next 2020-04-10 21:59:39 -07:00
Erik Eckstein
1de19a1b32 SimplifyCFG: fix a compile time problem with block merging
When merging many blocks to a single block (in the wrong order), instructions are getting moved over and over again.
This is quadratic and can result in very long compile times for large functions.
To fix this, always move the instruction to smaller block to the larger block.

rdar://problem/56268570
2020-04-10 20:10:24 +02:00
swift_jenkins
bf9cd85a1a Merge remote-tracking branch 'origin/master' into master-next 2020-04-08 11:19:37 -07:00
Andrew Trick
b5570a1aa9 Merge pull request #30872 from atrick/cse-init-existential-metatype
Add init_existential_metatype to CSE.
2020-04-08 11:06:26 -07:00
swift_jenkins
3007a42cda Merge remote-tracking branch 'origin/master' into master-next 2020-04-08 10:23:04 -07:00
Erik Eckstein
380db3761a DeadCodeElimination: replace recursive post-dominator walks with iterative worklist algorithms.
This fixes stack-overflow crashes when compiling large functions.

rdar://problem/56268570
2020-04-08 11:46:51 +02:00
Andrew Trick
a22d0f229c Add init_existential_metatype to CSE.
So String decoding can be optimized.
2020-04-07 21:16:21 -07:00
swift_jenkins
5e7747af09 Merge remote-tracking branch 'origin/master' into master-next 2020-04-07 11:02:51 -07:00
Meghana Gupta
b1ea908e6d In TempRVO, be more explicit on handling non - onstack partial_apply (#30837)
We should not optimize away the copy_addr of a guaranteed parameter of a
non-onstack partial_apply.
This is not a bug currently, because TempRVO checks if the lifetime end
points of the temp object are destroy_addr's in
TempRValueOptPass::checkTempObjectDestroy.
This change makes it explicit on which partial_apply's are ok to
optimize.

rdar://61349083
2020-04-07 10:45:46 -07:00
swift_jenkins
e29ea742ed Merge remote-tracking branch 'origin/master' into master-next 2020-04-07 09:39:56 -07:00
Erik Eckstein
756c7f9c49 SILOptimizer: fix a compile time problem in the inliner
When inlining many functions in a very large basic block, the splitting of the block at the call sites is quadratic, when traversing in forward order.
Traversing backwards, fixes the problem.

rdar://problem/56268570
2020-04-07 15:00:48 +02:00