Commit Graph

89 Commits

Author SHA1 Message Date
Erik Eckstein
cf0030b587 Make isSlowPath() a public member of ColdBlockInfo.
Swift SVN r24108
2014-12-23 09:11:57 +00:00
Michael Gottesman
a4318845cc Add in a few comments. NFC.
Swift SVN r23717
2014-12-05 02:08:38 +00:00
Michael Gottesman
8eb9ad4591 Change file to fit LLVM coding standard. NFC.
Swift SVN r23716
2014-12-05 02:08:37 +00:00
Michael Gottesman
ebfcc123a3 [callgraph] Teach the callgraph how to determine for simple cases if we have a complete caller set.
We specifically only handle cases of functions that are not visible externally
and for whom all function_refs to the function only have apply inst users.

<rdar://problem/19137435>

Swift SVN r23714
2014-12-05 02:08:36 +00:00
Michael Gottesman
7a2e1fb4d3 [arc-opts] After the arc optimizer converges, run another round of the ARC
optimizer freezing releases in the epilogue of functions that match to
SILArguments. This allows us to treat all such SILArguments throughout the
entire function as having a post dominating release.

<rdar://problem/18923030>

Swift SVN r23253
2014-11-11 23:37:09 +00:00
Arnold Schwaighofer
06a0a23562 Add a destructor memory effect analysis
This adds an analysis to the compiler that identifies types that are may store
to memory on destruction.

It adds a compiler known protocol _DestructorSafeContainer that allows the
standard library to identify containers whose destructor's memory effects
depends strictly on the type parameters of the container.

Array<T> : _DestructorSafeContainer {} may not store to memory during
destruction if the bound T is a type that does not store to memory on
destruction.

This is needed to deduce that for example Array<Array<Int>> is does not store to
memory on destruction (e.g during a call to release).

rdar://18940376

Swift SVN r23242
2014-11-11 19:27:41 +00:00
Michael Gottesman
3d396f8b12 [arc-analysis] Refactor OwnedArgToEpilogueReleaseMatcher from FunctionSigOpts.
Given a function F, this utility class attempts to match up owned arguments with
releases in the epilogue of the function.

I am refactoring this from FunctionSigOpts so I can use it in the ARC optimizer.

<rdar://problem/18923030>

Swift SVN r23219
2014-11-11 00:42:30 +00:00
Michael Gottesman
7b34373bf4 [aa] Add PartialAlias. This currently is not returned by any routine or used anywhere.
rdar://18831605

Swift SVN r23059
2014-11-02 00:41:12 +00:00
Michael Gottesman
a014c65205 Expose canInstUseRefCountValues as swift::canNeverUseValues.
canInstUseRefCountValues should have always been named
canInstNotUseRefCountValues. I don't remember how it get renamed as such. Even
though it is a little weird to have a "canNever" in a function name, it makes
sense here to contrast it with canUseValue which returns if a specific user can
use a ptr in a way that requires the ptr to be alive. This in contrast says that
a user can never use a ptr in a manner where the ptr must be alive. I.e. this is
a universal quantifier.

Swift SVN r22961
2014-10-27 09:15:57 +00:00
Joe Groff
e3f9a2035c SIL: Move SILGen and passes over to use "builtin" instead of "apply (builtin_function_ref)".
Swift SVN r22785
2014-10-15 23:37:22 +00:00
Mark Lacey
445afdc031 Delete the old call graph code.
Swift SVN r22598
2014-10-08 07:47:32 +00:00
Roman Levenstein
5e91fd3a62 Extend ClassHierarchyAnalysis to provide information about indirect subclasses. This is used e.g. by the upcoming devirtualizer changes.
Swift SVN r22521
2014-10-04 09:49:47 +00:00
Jordan Rose
3fcdfd40e9 Remove the "swift/Basic/Optional.h" header.
llvm::Optional lives in "llvm/ADT/Optional.h". Like Clang, we can get
Optional in the 'swift' namespace by including "swift/Basic/LLVM.h".

We're now fully switched over to llvm::Optional!

Swift SVN r22477
2014-10-02 18:51:45 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Michael Gottesman
f541019660 [codemotion] Extract out isARCInertTrapBB into ARCAnalysis from GARCOpts and teach SILCodeMotion to use it to not move retains into trap bbs.
This reduces the number of retains, releases in the stdlib by another 5% to
15167.

rdar://18328074

Swift SVN r21936
2014-09-13 03:15:29 +00:00
Michael Gottesman
04d9f968fd [rc-id] Make sure when stripping off arguments that the resulting stripped value dominates the argument.
This is important since to be more aggressive we are ignoring incoming values
that are no-payload enums since as far as we are concerned they do not matter
since retains, releases on those values are no-ops.

Swift SVN r21932
2014-09-12 22:21:06 +00:00
Michael Gottesman
4609513593 Remove SILValue::stripRCIdentityPreservingArgs and teach all uses of that method to use the new RCIdentityAnalysis.
Currently, the pass just calls a local version of that function. After OzU, I
will enable the full pass (which is currently disabled behind a flag).

Swift SVN r21894
2014-09-11 22:29:31 +00:00
Michael Gottesman
4647eb9601 Create RCIdentityAnalysis a cache for stripRCIdentityPreservingOps.
The cache is needed to ensure we do not run into compile time problems once we
start looking through Phi Nodes.

The analysis is currently disabled and just returns
SILValue::stripRCIdentityPreservingOps. I am going to thread it through the rest
of the passes that use that call. Then I am going to hide
stripRCIdentityPreservingArgs. Finally post OzU, I am going to enable the pass.

rdar://18300069

Swift SVN r21891
2014-09-11 21:51:29 +00:00
Roman Levenstein
a81a99776f Improve optimization of builtin operations that may overflow. Remove overflow checks if it can be proven that no overflow can happen.
Swift SVN r21874
2014-09-11 16:00:54 +00:00
Michael Gottesman
3275fc669d LLVM_DELETED_FUNCTION => = delete. NFC.
Swift SVN r21867
2014-09-11 05:41:12 +00:00
Michael Gottesman
24c138f29c Move SILLoopInfo into swiftSIL from swiftSILAnalysis so that we match the separation in between analysis and IR entities.
This follows the model of dominance info and allows me to create reachability
methods on SILBasicBlock without creating dependencies from swiftSIL to
swiftSILAnalysis.

Swift SVN r21866
2014-09-11 03:03:06 +00:00
Michael Gottesman
6e485700c6 Move SimplifyInstruction into SILAnalysis since it is an analysis.
This will hopefully make it clearer as we onboard people that
SimplifyInstruction should not add instructions to the IR by making it clearer
that it is an analysis, not a pass.

Swift SVN r21752
2014-09-05 22:56:26 +00:00
Michael Gottesman
e5fcbc6d59 [func-sig-opts] Add get{Known,}CallerCallSites to the CallGraph.
This returns an ArrayRefView that allows one to iterate over the CallSites of a
functions callers in a clean way.

Swift SVN r21730
2014-09-04 23:34:35 +00:00
Roman Levenstein
933e4bff17 [sil-simplify] Peepholes for (trunc (s_to_u (zext x)))->x and (trunc (u_to_s (zext (lshr x 1) Word -> Int64)) Int64 -> Word) -> (lshr x 1).
Related to rdar://17433082 and rdar://17406327

Swift SVN r21700
2014-09-04 10:27:08 +00:00
Michael Gottesman
6d1fef172a Small LLVM style fixups. NFC.
Swift SVN r21617
2014-08-31 19:59:44 +00:00
Michael Gottesman
5561b3f538 Convert Nothing_t::Nothing => Nothing.
Swift SVN r21605
2014-08-30 03:11:55 +00:00
Mark Lacey
6a695f3099 Move DeadFunctionElimination to using the new call graph.
The old call graph remains, but the new call graph can obtained by
calling getCallGraph() on the analysis pass.

I'll move the few other passes that use the call graph over soon and
then rip out the old call graph.

No diffs in the stdlib.

Swift SVN r21565
2014-08-29 05:03:31 +00:00
Mark Lacey
dc625f7c19 Minor API change in call graph.
Swift SVN r21553
2014-08-29 00:32:17 +00:00
Mark Lacey
36365d79df In the new call graph, find the SCCs in bottom-up order.
With this change we generate the SCCs in the call graph (for the kinds
of calls we currently recognize) in bottom-up, which we can then
iterate over directly or in reverse for invocation- and
reverse-invocation-order traversal of the call graph.

(This still isn't hooked up - but will be after some dumping routines
and verification of the output).

Swift SVN r21552
2014-08-29 00:32:17 +00:00
Michael Gottesman
75d8e4d748 [sil-combine] Move isZeroValue out of SILCombine and into ValueTracking.
Swift SVN r21540
2014-08-28 21:27:53 +00:00
Michael Gottesman
b617d1b6d1 [arc] Change valueHasARC*InInstructionRange to return either the offending instruction or Nothing_t::None instead of a bool.
This enables us to both check if any instructions may use or decrement a value
in an instruction range and if we find such an instruction know the furthest
where we can move the retain or release.

Swift SVN r21522
2014-08-28 08:00:44 +00:00
Andrew Trick
292d9b3bb2 Fix SILCodeMotion: do not move retains across isUniquelyReferenced.
Sinking retains will simply make the unique check useless and eliminate
Array copies even when we need them.

Fix for:
<rdar://problem/18109082> ARC: make _isUniquelyReferenced a barrier to avoid lost copies

Swift SVN r21485
2014-08-27 18:28:36 +00:00
Mark Lacey
3494d6ab39 Track call graph roots with a SmallVector rather than DenseSet.
This will allow us to search in the order the roots are added which
should improve stability of our output. There is also an ordinal on each
node that we can use to choose order of traversing edges at a given call
site.

Swift SVN r21484
2014-08-27 16:59:50 +00:00
Mark Lacey
dee10cb164 Update the new call graph so that edges have sets of call graph nodes.
Previously we tracked a set of functions that could be called from a given
call site. Now we track a set of call graph nodes (each of which
represents a callable function). As a result we now create call graph
nodes for declarations rather than just definitions.

Swift SVN r21483
2014-08-27 15:54:34 +00:00
Mark Lacey
a3350db69c Add statistics to call graph construction.
Also stub out some of the cases we'll need to handle to build a more
complete call graph.

Swift SVN r21430
2014-08-23 05:48:54 +00:00
Mark Lacey
34a1050222 Add data structures for a new, more detailed, call graph.
This is not yet hooked up. I want to add a dumper and some tests, and
need to implement code to do invocation- and reverse-invocation-ordering
over the SCCs of the call graph before it can fully replace the existing
code.

This call graph has edges for each call site, so it's really a
multigraph. Each call site tracks the set of functions that can be
called from that point. Currently that set is always a singleton since
we only handle applies of direct function_refs (like the existing call
graph). In time it will be expanded to handle other types of function
application.

Swift SVN r21407
2014-08-22 07:46:53 +00:00
Mark Lacey
7b30e832e4 Move contents of CallGraph.h into CallGraphAnalysis.h.
Swift SVN r21393
2014-08-22 00:00:04 +00:00
Mark Lacey
f1f3025838 Add call graph edges based on direct calls.
We were adding call graph edges based on seeing a function_ref. Instead,
we'll only add them now based on a direct apply of a function_ref.

Also a minor refactoring to move the code that walks the blocks and
instructions of a function into its own method.

Swift SVN r21243
2014-08-15 23:29:37 +00:00
Arnold Schwaighofer
86d43be559 IndVars: Store the increment of an induction variable
Such that we don't need to repeat part of the analysis in ABCOpts.

No functionality change.

Swift SVN r21211
2014-08-14 18:18:38 +00:00
Mark Lacey
d5a619bbad Small refactoring of call graph code.
This is a first step towards building a better call graph.

Swift SVN r21152
2014-08-12 18:20:21 +00:00
Nadav Rotem
685bb84c15 Minor cleanup. NFC.
Swift SVN r20851
2014-07-31 21:22:17 +00:00
Nadav Rotem
1b980052b1 Cache the class hierarchy construction.
Before this commit we scanned the vtables every time we wanted to know who are the subclasses of a class. Now we scan the vtables just once.



Swift SVN r20847
2014-07-31 21:07:11 +00:00
Nadav Rotem
0cb8bf0ab8 Implement polymorphic inline caches.
Swift SVN r20740
2014-07-30 07:43:47 +00:00
Nadav Rotem
898bf23738 Move the CallGraphAnalysis to a new file.
Swift SVN r20714
2014-07-29 23:18:56 +00:00
Nadav Rotem
7faa5883df Add a basic Class Hierarchy Analysis. At this point it only lists classes that are inherited from in this module.
Swift SVN r20710
2014-07-29 23:01:01 +00:00
Arnold Schwaighofer
c50e396103 Add APIs to update preserved analysis information for dominance and loop info
Use it in loop rotation.

The pattern to update analysis information is:

  // The AnalysisInfo was preserved for this function.
  if (Changed) {
    // Preserve the analyis for this function by decoupling it from the analysis
    // cache.
    auto PreservedAnalysis = Analysis.preserveAnalysis(Function);

    // Invalidate analysis for this function.
    PM.invalidateAnalysis(Function, InvalidationKind::CFG);

    // Update the preserved analysis for this function.
    Analysis.updateAnalysis(F, std::move(PreservedAnalysis));
  }

Swift SVN r19918
2014-07-14 03:42:39 +00:00
Arnold Schwaighofer
12cb97d284 PassManager: Reset state and remove all currently owned transformations
In the current setup analysis information is not reused by new pass managers.
There is no point in having different pass managers. Instead, we can just remove
transformations, reset the internal state of the pass manager, and add new
transformation passes. Analysis information can be reused.

Reuse one pass manager in the pass pipeline so that we don't have to
unnecessarily recompute analysis information.

Swift SVN r19917
2014-07-14 03:42:39 +00:00
Michael Gottesman
e998695670 [g-arc-opts] Refactor global arc opts to use the PostOrderAnalysis.
Swift SVN r19915
2014-07-14 01:32:27 +00:00
Michael Gottesman
7d5751594d Add in a post order analysis that lazily recomputes post orders for functions when they are invalidated.
This ensures that if we have a bunch of passes in a row which modify the CFG, we
do not continually rebuild the post order, while at the same time preserving the
property of multiple passes which do not touch the CFG sharing the same post
order, reverse post order rather than recomputing them.

rdar://17654239

Swift SVN r19913
2014-07-14 01:32:24 +00:00
Michael Gottesman
8685173e21 [arc-analysis] Add two functions for applying canUseValue and canDecrementValue to a contiguous range of instructions in the same BB.
The two functions are:

1. valueHasARCUsesInInstructionRange.
2. valueHasARCDecrementsInInstructionRange.

They operate on the range [Start, End).

I am going to use them in enum simplification and sil code motion.

Swift SVN r19893
2014-07-13 06:32:44 +00:00