Commit Graph

25 Commits

Author SHA1 Message Date
Andrew Trick
5c4104ebc1 NFC: Separate the "mayBindDynamicSelf" property from CallGraph.
We don't want passes directly querying the CallGraph because managing
invalidation will be so difficult.

This is still a workaround for the proper fix to AST/SIL type
substitution: <rdar://problem/21025088> SIL should properly represent
binding dynamic self to generic parameters.
2015-11-12 10:41:19 -08:00
Mark Lacey
0cd6a76849 Revert "Add support for deinits in the call graph."
This reverts commit 309f9630a6.

There is some concern this could break things now or in the future so it
makes sense to preemptively revert this until those concerns are
addressed.
2015-11-10 10:56:01 -08:00
Mark Lacey
309f9630a6 Add support for deinits in the call graph.
We'll now include edges for instructions that can potentially result in
a release (and thus call to a deinit).

Unhandled are release_value and anything involving archetypes, which
will involve more work.
2015-11-09 23:31:04 -08:00
Mark Lacey
94d7dcfd94 Inliner/generic specializer prep for handling deinit in call graph.
A little bit of generalizing so that we can maintain the call graph in
the inliner/specializer once we support tracking deinits in the call
graph.
2015-11-07 13:23:56 -08:00
Argyrios Kyrtzidis
156607c6e4 Fix -Wunused-variable warnings. 2015-11-05 19:04:09 -08:00
Mark Lacey
5c820508fa Begin to generalize call graph for non-apply instructions.
We need to be able to support non-apply instructions that result in
calling things like deinits. This is the first mechanical pass of
converting interfaces and data over.
2015-11-04 08:17:23 -08:00
Mark Lacey
203c9808d3 Remove dead functions from callee sets.
Rather than completely recomputing callee sets in the call graph after
removing dead functions, we should instead remove these functions from
the existing callee sets. Recomputing callee sets can lead to the callee
sets differing from the edges present in the call graph since we are
still doing some deserialization during call graph construction.

This change also updates CallGraphEditor::dropAllReferences() to remove
all the edges from the node representing the function we're dropping
references from because that's a sensible thing to do as part of that
function.
2015-11-03 11:22:36 -08:00
Mark Lacey
d36dac643a Update edge removal API in call graph.
Add a parameter for a function the call site is in, rather than using
the call site to determine the function.

This is necessary for enabling invalidation of call graph information
for individual functions. If we're not maintaining the call graph during
a pass, we may delete an instruction and be left with a dangling pointer
in the call graph edge. This allows us to still remove the edge properly
without trying to look at the instruction it represents.
2015-11-02 19:41:49 -08:00
Mark Lacey
bc679c1dd2 Use tryGetCallGraphEdge in places where the edge may not exist.
We now assert in getCallGraphEdge that we find the edge, so use
tryGetCallGraphEdge in cases where the edge might not exist.
2015-11-02 19:21:19 -08:00
Mark Lacey
0ceb04019d Add const to a bunch of call graph functions.
Change the declaration of the functions that do not modify the call
graph data structure to const to make it easier to know which ones do
modify the call graph at a glance.

Swift SVN r32930
2015-10-28 01:00:13 +00:00
Mark Lacey
401ce4c7ef Improve support for witness_method in the call graph.
Previously we handled only cases where we had concrete types and knew
exactly what would be called. Now we compute callee sets for the cases
where we have generic types.

We currently default in these cases to assuming we could call unknown
functions. Improving that will come in a future commit.

Swift SVN r32814
2015-10-21 23:09:19 +00:00
Mark Lacey
0b46c2a1ee Determine which class_method call sites might call unknown functions.
Previously we conservatively assumed any class_method call site could
call unknown functions.

With this commit we now determine which call sites really can call
unknown functions. For those that cannot, we know all possible callees,
and can use that fact in interprocedural analyses like side-effect
analysis and capture analysis.

Swift SVN r32772
2015-10-20 05:11:57 +00:00
Mark Lacey
73098dfa6d Rename canCallArbitraryFunction to canCallUnknownFunction.
Swift SVN r32749
2015-10-18 22:22:37 +00:00
Mark Lacey
4327e0b7b7 Update a comment regarding unknown callees for class methods.
Swift SVN r32746
2015-10-18 03:08:50 +00:00
Mark Lacey
8537e8efb2 Change call graph SCCs to be composed of SILFunction *.
This is another step in hiding implementation details.

Swift SVN r32745
2015-10-18 02:25:51 +00:00
Mark Lacey
25abe9d750 Refactor and improve the representation of sets of callees.
There is now a separate class to abstract the notion of a set of
callees. The class itself is very compact - always a pointer in size,
but distinguishes singleton callees, true sets of callees, and in the set
case whether that set is incomplete. The sets are cached in the call
graph as before, but that cache now caches whether the sets are
incomplete or not, which will enable correctly computing and caching
that information for method calls so that the call graph can correctly
represent whether those are known to be incomplete sets, or whether we
really know all the possible callees at a call site.

This also hides more implementation details of the call graph, and
provides a new interface getCallees() which provides a way to iterate
over the SILFunctions rather than CallGraphNodes.

More clean-up and refactoring coming in future commits.

Swift SVN r32737
2015-10-17 00:11:13 +00:00
Mark Lacey
437d5b873e Use SmallSetVector for callee sets.
SmallSetVector takes more space than SmallPtrSet, but the number of
these that we actually allocate is bounded by the number of unique
method decls we see in vtables, so total memory usage won't grow by
much.

This allows us to remove the sorting that we're doing at various points
in processing as well as enabling the use of ArrayRefView (in a later
commit) to hide call graph nodes and instead just vend the called
SILFunctions.

Swift SVN r32723
2015-10-16 16:45:20 +00:00
Mark Lacey
76c06bac60 In dump of call graph stats, print # of callee sets allocated.
Swift SVN r32705
2015-10-15 06:16:52 +00:00
Mark Lacey
94ddaf22b9 Remove the getComplete* functions from call graph.
Rename the getPartial* functions to get* in each case.

The intent in splitting these into two APIs was to catch bugs, but it
adds complexity without really adding much safety since a client could
call getPartial* and treat the results as if they are complete.

Swift SVN r32685
2015-10-14 21:32:57 +00:00
Mark Lacey
b5bc5c5e14 Remove unused method from call graph.
Swift SVN r32664
2015-10-13 20:29:43 +00:00
Mark Lacey
2e86c9a8d6 Move a couple helper classes into namespaces.
OrderedCallGraph, which is only available in debug builds, needs to be a
friend of CallGraph (which will happen in a subsequent commit), so it
cannot go into an anonymous namespace.

Swift SVN r32653
2015-10-13 05:56:54 +00:00
Mark Lacey
9eca7dbaac Add a couple helpers to CallGraphEditor.
Swift SVN r32601
2015-10-10 06:55:34 +00:00
Mark Lacey
0538553520 Change call site numbering in call graph.
They were being created in reverse order of discovery, resulting in call
sites being renumbered any time new code is added to the end of a file,
which isn't great for testing.

Swift SVN r32464
2015-10-06 18:03:14 +00:00
Mark Lacey
555f8e4ac8 Minor refactoring of call graph interface.
We only need to know whether a callee set for a class_method is complete
when we go to create the call graph edge, so defer that determination
until that point. This is currently just hard coded to false, but a
subsequent commit will actually make that determination.

Swift SVN r32463
2015-10-06 18:03:03 +00:00
Mark Lacey
c08d25e4a8 Separate the call graph data structure code from the analysis.
Split off the main code from the analysis class (which ends up as just a
header).

Swift SVN r32405
2015-10-02 20:53:35 +00:00