Commit Graph

127 Commits

Author SHA1 Message Date
Michael Gottesman
62a744a9b9 [dead-function-elim] When deleting functions, use a vector instead of itereating over the module functions twice.
We already know the set of dead functions when we drop the bodies, so instead of
iterating over all of the modules in a function (which is a linked list btw),
just use a vector that we create as we drop the bodies. Then in cases where we
are only eliminating a small amount of functions, we only perform a small amount
of work when deleting function bodies.

This is just a small optimization that I saw as I read through the code to make
sure dead function elimination was an idempotent optimization [which it is].

rdar://29650781
2016-12-19 12:55:18 -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
483388c9a6 [sil-bug-reducer] Wire up SILPassManager to SILPassManagerPipeline.
We also either remove or make private the addPass* functions on SILPassManager,
so the only way to execute passes via SILPassManager is by creating a
SILPassPipelinePlan. This beyond adding uniformity ensures that we always
resetAndRemoveTransformations properly after a pipeline is run.
2016-12-12 14:42:46 -08:00
Michael Gottesman
9dd7074d96 [sil-func-extractor] Rather than manually creating a pass manager just to run DFE, just
add a high level API to perform the operation.
2016-12-12 09:16:04 -08: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
Roman Levenstein
d09dd0622f [sil-dead-function-elimination] Don't change the fragility of pre-specialized functions.
The old code was changing the fragility of some pre-specialized symbols which made them invisible outside of their own object files, which resulted in linking errors.

Fixes radr://problem/28615847
2016-10-04 13:25:43 -07:00
Erik Eckstein
0c5d87e6a6 Always ensure that we generate code for referenced transparent functions.
We didn't do this if the transparent function was only reachable via a vtable/witness table.

rdar://problem/28294466
2016-09-26 15:40:41 -07:00
John McCall
afdda3d107 Implement SE-0117.
One minor revision: this lifts the proposed restriction against
overriding a non-open method with an open one.  On reflection,
that was inconsistent with the existing rule permitting non-public
methods to be overridden with public ones.  The restriction on
subclassing a non-open class with an open class remains, and is
in fact consistent with the existing access rule.
2016-08-02 07:46:38 -07:00
Jordan Rose
508e825ff2 Split 'fileprivate' and 'private', but give them the same behavior.
'fileprivate' is considered a broader level of access than 'private',
but for now both of them are still available to the entire file. This
is intended as a migration aid.

One interesting fallout of the "access scope" model described in
758cf64 is that something declared 'private' at file scope is actually
treated as 'fileprivate' for diagnostic purposes. This is something
we can fix later, once the full model is in place. (It's not really
/wrong/ in that they have identical behavior, but diagnostics still
shouldn't refer to a type explicitly declared 'private' as
'fileprivate'.)

As a note, ValueDecl::getEffectiveAccess will always return 'FilePrivate'
rather than 'Private'; for purposes of optimization and code generation,
we should never try to distinguish these two cases.

This should have essentially no effect on code that's /not/ using
'fileprivate' other than altered diagnostics.

Progress on SE-0025 ('fileprivate' and 'private')
2016-07-25 13:13:35 -07:00
Jordan Rose
740ddd8400 [SIL] Don't assume we always have an associated DeclContext. (#2730)
...in code that I wrote. The integrated REPL, deprecated though it may
be, does not have an associated DeclContext because its SourceFile is
not considered complete. (The proper LLDB REPL does not suffer from
this problem because they use a new SourceFile for every block of
input.)

Elsewhere, tighten up code that may have hit similar bugs, though we
haven't seen anything hit these yet.

rdar://problem/26476281
2016-05-26 18:31:47 -07:00
Michael Gottesman
da9c13a9f8 [upstream-update] SmallPtrSet can now only have at most 32 elements inline.
(cherry picked from commit 88250e0e69)
(cherry picked from commit 4008ec83f6)
(cherry picked from commit 3a031eb1f8548e5ce55fb323118fbd05b5929a33)
2016-05-13 22:04:12 -07:00
Xin Tong
1603b0f153 Handle dead functions in CallerAnalysis.
Add an invalidateAnalysisForDeadFunction API. This API calls the invalidateAnalysis
by default unless overriden by analysis pass themselves. This API passes the extra
information that this function is dead and going to be removed from the module.

CallerAnalysis overrides this API and only invalidate caller/callee relations but
does not push this into the recompute list.

We also considered the possibility of keeping a computed list, instead of recompute
list but that would introduce a O(n^2) complexity as every time we try to complete
the computed list, we need to walk over all the functions that currently exist in the
module to make sure the computed list is complete.

I feel eventually we can do a handleDeleteNotification for function deletion and we
wont need the API added in this change.
2016-03-17 09:55:12 -07:00
Xin Tong
0b930234ed Fix use-after-free in DFE 2016-03-16 14:20:45 -07:00
Xin Tong
a5b0270ab9 Remove unused variable 2016-03-16 07:38:31 -07: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
Xin Tong
7808fb3034 Make dead function elim respect optimize.sil.never. Its possible these functions
can be called from something external of the program, e.g. debugger
2016-02-08 13:35:23 -08:00
Slava Pestov
6a254042ee SILOptimizer: Functions referenced from sil_default_witness_table are alive 2016-02-08 00:05:57 -08:00
Xin Tong
3391140ed1 Remove unnecessary header. NFC. 2016-02-05 22:43:29 -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
Michael Gottesman
ca1fcd9375 Eliminate two never-read variables.
Found by the clang static analyzer.
2016-01-08 19:28:42 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
81e7439a9a Fix typos. 2015-12-23 11:16:34 +01:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Chris Lattner
fd465ff520 Merge pull request #526 from practicalswift/fix-typos-30
Fix typos (30 of 30)
2015-12-14 18:13:19 -08:00
Roman Levenstein
3a4184dad9 Extend a few lookup APIs to use AbstractFunctionDecl instead of FuncDecl. NFC.
This is required for upcoming changes in the devirtualizer.
2015-12-14 10:11:46 -08:00
practicalswift
67f6f9308d Fix typo: visiblity → visibility 2015-12-14 00:12:38 +01:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00