-
Notifications
You must be signed in to change notification settings - Fork 825
LogExecution: optionally take a module name for the logger function #6629
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
LogExecution: optionally take a module name for the logger function #6629
Conversation
|
I agree that the automatic behavior here can be hard to use. But we do need a solution for the case where If so then to implement it see e.g. |
|
sure, making it an option works for me. |
|
You're right that a different order might work. But sometimes you want to add the logging after all optimizations have been done, maybe because the bug only shows itself then (maybe it's a bug in an optimization pass). In general I've personally found this pass useful on various wasm files, optimized and not, and I'm not sure how other people are using the pass, so I'd rather not remove functionality. |
ok. it makes sense. |
ce20d03 to
033d61d
Compare
|
i added the suggested option. |
kripken
left a comment
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 add a test for this. It could be similar to this test file that I just opened a PR for,
Maybe call it test/lit/passes/log-execution_arg.wast (adding _arg), and put a comment in it saying
;; Test the option to provide the module name as an argument.
Then you can just modify the wasm-opt command there. To update the expected output there use
./scripts/update_lit_checks.py test/lit/passes/log-execution_arg.wast
src/passes/LogExecution.cpp
Outdated
| Name LOGGER("log_execution"); | ||
|
|
||
| struct LogExecution : public WalkerPass<PostWalker<LogExecution>> { | ||
| IString logger_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.
| IString logger_module; | |
| // The module name the logger function is imported from. | |
| Name loggerModule; |
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.
done
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.
Aside from the comment, the diff also renamed the variable. loggerModule is more consistent with our naming conventions (compared to logger_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.
oops, i haven't noticed it. done.
033d61d to
08be7c2
Compare
done. |
08be7c2 to
8556a7e
Compare
| (func $nopp | ||
| (nop) | ||
| ) | ||
| ;; CHECK: (func $intt (result i32) |
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.
I think it's ok to stop this test here. The first 25 lines show that it uses "foo" and that it emits a valid call to log_execution.
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.
(That is, it doesn't need to be as comprehensive as the other test, as the focus here is just on the argument to the pass, which lines 1-25 test.)
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.
are you suggesting to minimize the test?
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.
done
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.
Yes, exactly.
kripken
left a comment
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.
Looks good aside from those last comments.
also, fix a crash on modules w/o imports.