Skip to content

Update LogExecution pass to emit log ordinals in the wasm function ordinals order#5718

Open
juj wants to merge 9 commits intoWebAssembly:mainfrom
juj:log_function_order
Open

Update LogExecution pass to emit log ordinals in the wasm function ordinals order#5718
juj wants to merge 9 commits intoWebAssembly:mainfrom
juj:log_function_order

Conversation

@juj
Copy link
Copy Markdown
Collaborator

@juj juj commented May 12, 2023

Update LogExecution pass to emit log ordinals in the wasm function ordinals order, so that they can be correlated with functions afterwards.

This is something I found I needed to do in order to get a PGO based analysis to line up with wasm function indices.

…dinals order, so that they can be correlated with functions afterwards.
@juj juj requested review from kripken and tlively May 12, 2023 08:42
Comment thread src/passes/LogExecution.cpp Outdated
Comment thread src/passes/LogExecution.cpp Outdated
Comment thread src/passes/LogExecution.cpp Outdated
if (func->imported())
continue;

Index currentFunctionIndex = (Index)stringToIndex(func->name.toString().c_str());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Index currentFunctionIndex = (Index)stringToIndex(func->name.toString().c_str());
Index currentFunctionIndex = stringToIndex(func->name.toString().c_str());

Also, why try to convert function names to indices at all? It would be more robust to avoid trying to interpret the names so that all function names can be treated uniformly.

Copy link
Copy Markdown
Collaborator Author

@juj juj Sep 8, 2025

Choose a reason for hiding this comment

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

Hey @tlively, it's been a while, though I am now coming back to this functionality, and look to get this landed.

Updated the PR here: the idea here is to ensure that Wasm functions that do not have a debug symbol name string, would be guaranteed to get the log ID that matches its function ordinal. It gives consistency, and allows users to map the log IDs then to e.g. with external symbol maps.

Revised the PR to make sure this is the case always, even if some producer might e.g. give debug symbol names to only some of the functions, and not all.

@juj
Copy link
Copy Markdown
Collaborator Author

juj commented Sep 8, 2025

Updated this PR to latest, looking for a review. Thanks!

@juj
Copy link
Copy Markdown
Collaborator Author

juj commented Sep 15, 2025

@kripken Maybe you might be available to review?

Name LOGGER("log_execution");

struct LogExecution : public WalkerPass<PostWalker<LogExecution>> {
std::unordered_map<Function*, Index> functionOrdinals;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is a "function ordinal"? I don't see "ordinal" anywhere existing in src/.

If it is a new concept please add a comment explaining it.

If this is a function index, please rename it to that. Skimming the code below that might be the case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They are the function indices. Good idea, I'll rename.

I'll post this in a bit, I find there is some kind of bug in my use, and not sure if it could be related to this code path; so I'll investigate that and then update this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants