-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print out callgraph of a specific entry point #6354
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we don't have a test for this pass. If you want to extend it then I suggest we first land a PR that adds a test for the old functionality. Then this PR can land later, and the test will show nothing regressed.
src/passes/PrintCallGraph.cpp
Outdated
} | ||
} | ||
Name caller = getPassOptions().getArgumentOrDefault( | ||
"func", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a convention we use the pass in the name of the flag (unless the flag applies to more than one pass somehow). See for example the --jspi
pass which uses jspi-*
names:
Lines 88 to 97 in 6a42941
auto stateChangingImports = String::trim(read_possible_response_file( | |
options.getArgumentOrDefault("jspi-imports", ""))); | |
String::Split listedImports(stateChangingImports, ","); | |
// Find which exports should create a promise. | |
auto stateChangingExports = String::trim(read_possible_response_file( | |
options.getArgumentOrDefault("jspi-exports", ""))); | |
String::Split listedExports(stateChangingExports, ","); | |
bool wasmSplit = options.hasArgument("jspi-split-module"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 10f8643
src/passes/PrintCallGraph.cpp
Outdated
|
||
void constructCallgraph(Name caller) { | ||
if (caller.toString().empty()) { | ||
// whole callgraph, no filters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand in this comment, it is not obvious to me what "no filters" means.
Also please add a comment in the else
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 10f8643
src/passes/PrintCallGraph.cpp
Outdated
Module* module; | ||
Function* currFunction; | ||
std::set<Name> visitedTargets; // Used to avoid printing duplicate edges. | ||
std::vector<Function*> allIndirectTargets; | ||
CallPrinter(Module* module) : module(module) { | ||
std::multimap<Name, Name> full_graph; // First param is the caller/parent, second is the callee/child |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::multimap<Name, Name> full_graph; // First param is the caller/parent, second is the callee/child | |
std::multimap<Name, Name> fullGraph; // First param is the caller/parent, second is the callee/child |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 10f8643
I found it useful for my use case and was sharing in the case where others will be able to benefit from it as well. If there's not much traction on this, I'll probably leave it as is. |
I do think this can be useful! My comments weren't meant to discourage you, but just to explain how I think it best to proceed to get this landed. It's probably also fine to add a test in this PR for both cases, as the pass is simple enough. |
} | ||
Name caller = getPassOptions().getArgumentOrDefault( | ||
"callgraph-entry", | ||
""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this flag in the top comment (line 20 or so).
Allows us to generate / print out a callgraph for a specific entry point which we'd like to focus on.
Sample usage:
wasm-opt foobar.wasm --print-call-graph -pa=callgraph-entry@foo > foo.dot