Commit Graph

11224 Commits

Author SHA1 Message Date
Dmitri Gribenko
f5153572d7 stdlib: rename count labels in underscored protocols
lengthInBytes => utf8CodeUnitCount

numberOfCodeUnits => utf16CodeUnitCount
2016-01-21 17:18:15 -08:00
Erik Eckstein
ec172cde5b Remove SILValue::replaceAllUsesWith.
It's not needed anymore because we can use ValueBase::replaceAllUses
2016-01-21 16:04:30 -08:00
Erik Eckstein
f2c0283437 Simplify DebugUtils
With the changes in SILValue there is no need for template functions in DebugUtils anymore.
2016-01-21 16:04:30 -08:00
Erik Eckstein
2db6f3d213 SIL: remove multiple result values from SILValue
As there are no instructions left which produce multiple result values, this is a NFC regarding the generated SIL and generated code.
Although this commit is large, most changes are straightforward adoptions to the changes in the ValueBase and SILValue classes.
2016-01-21 10:30:31 -08:00
Xin Tong
63713e044e Port alias analysis to use the NewProjection from the (old) Projection. This passes all validation
tests, including alias analysis SIL tests based on AAdumper.
2016-01-21 09:29:08 -08:00
practicalswift
6d0eee9b8c Remove unused variables. 2016-01-21 10:33:17 +01:00
Xin Tong
894aa621cd Make Fix_lifetime instruction inert from a store prospective 2016-01-20 16:52:53 -08:00
Roman Levenstein
696aad7582 [sil-global-opt] Teach GlobalOpt to handle alloc_global
Global let propagation works again with this change. The corresponding test-case is enabled again.

rdar://24229640
2016-01-20 16:33:58 -08:00
Xin Tong
9f8dcfab07 Make Fix_lifetime instruction inert from a load prospective 2016-01-20 15:01:56 -08:00
Max Moiseev
9a018bd77d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-20 14:38:22 -08:00
practicalswift
244160fa30 [gardening] Fix recently introduced typo 2016-01-20 21:15:27 +01:00
Erik Eckstein
b7ea3b9bb2 [SIL] Let alloc_existential_box return a single value.
And use the new project_existential_box to get to the address value.
SILGen now generates a project_existential_box for each alloc_existential_box.
And IRGen re-uses the address value from the alloc_existential_box if the operand of project_existential_box is an alloc_existential_box.
This lets the generated code be the same as before.
2016-01-20 11:27:06 -08:00
Erik Eckstein
4dab67c582 SIL: add a new project_existential_box instruction.
It will be used as a replacement for the second return value of alloc_existential_box.
2016-01-20 11:27:06 -08:00
Doug Gregor
7d70b704e4 Merge commit '5e11e3f7287427d386636a169c4065c0373931a8' into swift-3-api-guidelines 2016-01-19 23:18:20 -08:00
Chris Lattner
dd18e9cfd0 Merge pull request #1014 from practicalswift/typo-fixes-20160119
[gardening] Fix recently introduced typo
2016-01-19 20:29:47 -08:00
Michael Gottesman
e25cd8860c Remove all uses of ilist_node::getNextNode() and ilist_node::getPrevNode() in favor of just using iterators.
This change is needed for the next update to ToT LLVM. It can be put
into place now without breaking anything so I am committing it now.

The churn upstream on ilist_node is neccessary to remove undefined
behavior. Rather than updating the different ilist_node patches for the
hacky change required to not use iterators, just use iterators and keep
everything as ilist_nodes. Upstream they want to eventually do this, so
it makes sense for us to just do it now.

Please do not introduce new invocations of
ilist_node::get{Next,Prev}Node() into the tree.
2016-01-19 14:44:58 -06:00
practicalswift
e765b5b671 [gardening] Fix recently introduced typo 2016-01-19 19:59:42 +01:00
Erik Eckstein
8110b1ebc8 [SIL] Let alloc_box return a single value.
And use project_box to get to the address value.
SILGen now generates a project_box for each alloc_box.
And IRGen re-uses the address value from the alloc_box if the operand of project_box is an alloc_box.
This lets the generated code be the same as before.

Other than that most changes of this (quite large) commit are straightforward.
2016-01-19 08:59:24 -08:00
Mark Lacey
5948ac38a6 Fix coding style: capitalize member variable 2016-01-18 22:38:29 -08:00
Andrew Trick
e8fc64cdae [SILOpt] Fix speculative devirtualization miscompile.
Properly handle limiting the number of speculative checks.
This bug dates back to 2015-09-15, Swift 2.1.

Fixes rdar:23228386.
2016-01-17 17:08:59 -08:00
Chris Lattner
7c247f2096 Further improve the error message when self escapes in a root class before
its fields are initialized.  Before:

   t.swift:18:24: error: variable 'self.B' captured by a closure before being initialized

after:

t.swift:19:24: error: 'self' captured by a closure before all members were initialized
    self.A.withCString {  cString -> () in
                       ^
t.swift:14:7: note: 'self.B' not initialized
  var B: Int
      ^

This drives home the fact that 'self' is being captured here, not the individual
properties.
2016-01-16 22:54:27 -08:00
Chris Lattner
ce94e0af53 Fix rdar://23013334 DI QoI: Diagnostic claims that property is being used when it actually isn't
Partial applications of a root self value are an escape point, not a load.  This
improves the diagnostic in this case from:

t.swift:18:24: error: variable 'self.B' used before being initialized
    self.A.withCString {  cString -> () in
                       ^

to:

t.swift:18:24: error: variable 'self.B' captured by a closure before being initialized
    self.A.withCString {  cString -> () in
                       ^
2016-01-16 22:41:02 -08:00
Chris Lattner
9c9ddf9e6c Fix <rdar://problem/22723281> QoI: [DI] Misleading error from Swift compiler when using an instance method in init()
When a root class delegates to a non-class-bound protocol method, the self value
gets wrapped up in a SIL alloc_stack so it can be passed by address.  Recognize
that the store involved is doing this, so we can provide a more specific diagnostic.

Before this, we produced:
variable 'self.x' used before being initialized

Now we produce:
error: use of 'self' in method call 'getg' before all stored properties are initialized
note: 'self.x' not initialized
2016-01-16 22:08:34 -08:00
Michael Gottesman
6099702789 Fixes requested by Jordan when reviewing 389238e801.
These were all small fixes suggested by Jordan. All of the changes are cosmetic
except for 1 removal of a sort that was not needed.
2016-01-15 22:58:10 -08:00
Erik Eckstein
afe9cf6091 CSE: handle project_box 2016-01-15 16:01:56 -08:00
Mark Lacey
ab138b9839 Don't assert on alloc_stack with only debug_value_addr uses.
This came up with other changes I have to modify the optimizer
pipeline. We shouldn't assert if we have an alloc_stack/dealloc_stack
where the only other use of the alloc_stack is a debug_value_addr.

It's easy to avoid this by removing allocations that don't have real
uses prior to attempting to handle the ones that do have real uses (as
opposed to the other way around).
2016-01-15 16:40:34 -05:00
Erik Eckstein
1c781f8470 AliasAnalysis: handle project_box in TBAA 2016-01-15 12:35:29 -08:00
Erik Eckstein
25e52a0ba0 treat project_box as projection in SILValue and SideEffectAnalysis 2016-01-15 12:35:29 -08:00
Erik Eckstein
e5ad57c77b EscapeAnalysis: less conservative handling of @box types and partial_apply with @box arguments 2016-01-15 12:35:29 -08:00
Michael Gottesman
551b94b7ae [rc-id] Make RCIdentity strip off single-pred arguments.
This was already done in a few different places in the compiler. There is no
reason not to have it in RCIdentity directly.

rdar://24156136
2016-01-14 18:59:42 -08:00
Michael Gottesman
2f3709443d [rc-id] Make RCIdentity strip off single-pred arguments.
In a bunch of use-cases we use stripSinglePredecessorArgs to eliminate this
case. There is no reason to assume that this is being done in the caller of
RCIdentity. Lets make sure that we handle this case here.

rdar://24156136
2016-01-14 18:19:54 -08:00
Xin Tong
f5a77cd5ad Remove release instructions in non-arc-inert termination block. rdar://24011383 2016-01-14 15:37:10 -08:00
Erik Eckstein
eff88d8703 EscapeAnalysis: don't crash in case a function_ref is passed to a C-function pointer argument.
Fixes rdar://problem/24183323
2016-01-14 15:20:13 -08:00
Xin Tong
e08f0d43c7 Move ProgramTerminationAnalysis from ARC/ to swift/Analysis/. This analysis can be useful for other optimizations 2016-01-14 14:06:35 -08:00
Erik Eckstein
5b31b94db4 EscapeAnalysis: handle strong_pin and strong_unpin instructions. 2016-01-13 17:03:10 -08:00
Erik Eckstein
dc84f4151b EscapeAnalysis: add API for checking the escape status of parameters of a function call. 2016-01-13 17:03:10 -08:00
Michael Gottesman
f93b8559f5 [gardening] Add some textual flags and organize the code a little bit. NFC. 2016-01-12 14:43:19 -08:00
Michael Gottesman
1b83009456 [gardening][rc-id] Move the main RCIdentityRoot analysis entry point into the RCIdentityRoot analysis section. 2016-01-12 14:31:10 -08:00
Erik Eckstein
7b5741df71 SideEffectAnalysis: consider that @callee_owned calls implicitly release the context.
fixes rdar://problem/24112977
2016-01-11 17:32:15 -08:00
Max Moiseev
08e1e4a043 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-11 16:51:11 -08:00
Michael Gottesman
5b1ebe12a9 Remove the case 'Invalid' from the TermKind enum and just use an unreachable in the ValueKind -> TermKind switch instead.
In all of the cases where this is being used, we already immediately perform an
unreachable if we find a TermKind::Invalid. So simplify the code and move it
into the conversion switch itself.
2016-01-11 15:44:05 -08:00
John McCall
5fe5fa41a7 Handle indirect conformance when devirtualizing existentials.
While I'm in this code, generalize it to propagate the original
type information in more cases, including when the original type
is still dependent, and teach it to handle existential metatypes.

rdar://24114020
2016-01-08 22:33:45 -08:00
Michael Gottesman
a7bbdd0846 Remove nullptr access. NewBr here is always nullptr.
Found with clang static analyzer.
2016-01-08 19:28:43 -08:00
Michael Gottesman
24bd1e3974 Remove variable that is written to but never read. Found by the clang static analyzer. 2016-01-08 19:28:43 -08:00
Michael Gottesman
8344beccef Another potential nullptr access found by the clang static analyzer! 2016-01-08 19:28:43 -08:00
Michael Gottesman
88929f8e99 Fix implicit assumption that RetainArray is not nullptr.
The code in question was the following:

  auto *RetainArray = dyn_cast_or_null<StrongRetainInst>(getInstBefore(Call));
  if (!RetainArray && MayHaveBridgedObjectElementType)
    return false;
  auto *ReleaseArray = dyn_cast_or_null<StrongReleaseInst>(getInstAfter(Call));
  if (!ReleaseArray && MayHaveBridgedObjectElementType)
    return false;
  if (ReleaseArray &&
      ReleaseArray->getOperand() != RetainArray->getOperand())
    return false;

There is no check in the last if if RetainArray is not nullptr even though it is
possible for it to be so.

Found by clang static analyzer.
2016-01-08 19:28:42 -08:00
Michael Gottesman
ca1fcd9375 Eliminate two never-read variables.
Found by the clang static analyzer.
2016-01-08 19:28:42 -08:00
John McCall
5112864dad Remove the archetype from Substitution.
This eliminates some minor overheads, but mostly it eliminates
a lot of conceptual complexity due to the overhead basically
appearing outside of its context.
2016-01-08 15:27:13 -08:00
Mark Lacey
c37697d38e Add the stand-alone generic specializer pass back to the pipeline.
On the whole it looks like this currently benefits performance.

As with the devirtualization pass, once the updated inliner is
committed, the position of this pass in the pipeline will change.
2016-01-08 08:21:00 -08:00
Mark Lacey
57abe19198 Add the stand-alone devirtualizer pass back to the pipeline.
It looks like this has minimal performance impact either way. Once the
changes to make the inliner a function pass are committed, the position
of this in the pipeline will change.
2016-01-08 00:40:03 -08:00