Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@ScottCarda-MS
Copy link
Contributor

@ScottCarda-MS ScottCarda-MS commented Jun 10, 2020

When Entry Points are present in the compilation, the Call Graph Walker should build a call graph solely off of those entry points and their dependencies, recursively. This will result in smaller, more manageable call graphs that contain info on only the callables that are used.

Other changes:

  • Part of the call graph data structure was updated to use a lookup rather than a dictionary as it is more in line with how that component is used and this simplifies some of the logic.
  • Copy constructors are added for the node and edge classes.
  • Unit tests covering the new functionality of the entry point logic on the call graph.

@ScottCarda-MS ScottCarda-MS marked this pull request as ready for review June 11, 2020 17:25
// Type arguments need to be resolved for the whole expression to be accurate
// ToDo: this needs adaption if we want to support type specializations
var typeArgs = tArgs;
var typeArgs = QsNullable<ImmutableArray<ResolvedType>>.Null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think we have a couple of loose ends here. The additional argument to track which type arguments are associated with a particular call graph node is more generally applicable then just if we had type specializations. Rather than the caller and called type arguments only capturing the type specialization (if we were to support them), they should in fact contain the resolutions for all type parameters. Right now the built graph works perfectly fine for libraries (with some spare handles that are never used); let me see if I can also populate the spare handles when we have an executable (assuming it doesn't contain any call graph cycles that it shouldn't). The handles should either be removed or be used, but I think we can use them.

Copy link
Contributor

@bettinaheim bettinaheim Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here would be an implementation for populating the type argument handles that are currently unused: #456
The idea would be that the cycle check would be run for each library and the source code separately, and then the full call graph containing the full type information can be build and stored with the compilation (just watch out to keep what is stored with the compilation immutable). As discussed previously, a way to invalidate the call graph if needed would be to just use a guid that is set upon construction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this comment is addressing or what the linked implementation does. What is the issue you are trying to address here?

Copy link
Contributor

@bettinaheim bettinaheim Jun 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The todo's in the code; the handles for type arguments are not only applicable if we have type specializations, but make sense to populate in any case if the compilation has entry point(s).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to wait to make changes on this topic until it can be worked into the design doc for the call graph. I will create a separate task for this and its implementation will be a separate PR. For now, this PR needs to be merged in so that work can continue on the feature.

@IrinaYatsenko
Copy link

IrinaYatsenko commented Jun 12, 2020

    /// to ensure that the same type parameters will have the same hash.

You are not providing a hash function for the CallGraphEdge anymore, but I presume the position info will still be in the way of Equals, right? #Closed


Refers to: src/QsCompiler/Transformations/CallGraph.cs:144 in 4a7c6bb. [](commit_id = 4a7c6bb, deletion_comment = False)

@IrinaYatsenko
Copy link

IrinaYatsenko commented Jun 12, 2020

    public static CallGraphEdge CombineEdges(CallGraphNode targetNode, params CallGraphEdge[] edges)

From the summary comment I'd name this method something like CombinePathIntoSingleEdge. On the other hand, if for correctness of this method it's required to provide a continuous path of edges in edges array, why would you need to filter the type resolutions by target? Aren't all type resolutions on a given edge specific to its target call node?

Oh! I think I'm getting it! The goal is to select the subset of type resolutions on the path that actually reach the target. Correct? #Closed


Refers to: src/QsCompiler/Transformations/CallGraph.cs:206 in 4a7c6bb. [](commit_id = 4a7c6bb, deletion_comment = False)

Copy link
Contributor Author

@ScottCarda-MS ScottCarda-MS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n/a

@ScottCarda-MS ScottCarda-MS requested a review from cesarzc June 30, 2020 18:42
Copy link
Contributor

@bamarsha bamarsha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had a chance to look at the tests yet, but here are a couple minor comments on the other code.

Copy link
Contributor

@bamarsha bamarsha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the context for @bettinaheim's comment about type arguments in the graph, but other than that it looks good.

@ScottCarda-MS ScottCarda-MS merged commit b80e14b into features/CallGraphWalker Jul 7, 2020
@ScottCarda-MS ScottCarda-MS deleted the sccarda/CallGraphFromEntryPoints branch August 13, 2020 21:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants