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

Add `-Z instrument-mcount` #57220

Merged
merged 1 commit into from Dec 31, 2018

Conversation

Projects
None yet
5 participants
@quark-zju
Copy link
Contributor

quark-zju commented Dec 30, 2018

This flag inserts mcount function call to the beginning of every function
after inline processing. So tracing tools like uftrace 1 (or ftrace for
Linux kernel modules) have a chance to examine function calls.

It is similar to the -pg flag provided by gcc or clang, but without
generating a __gmon_start__ function for executables. If a program
runs without being traced, no gmon.out will be written to disk.

Under the hood, it simply adds "instrument-function-entry-inlined"="mcount"
attribute to every function. The post-inline-ee-instrument LLVM pass does
the actual job.

Add `-Z instrument-mcount`
This flag inserts `mcount` function call to the beginning of every function
after inline processing. So tracing tools like uftrace [1] (or ftrace for
Linux kernel modules) have a chance to examine function calls.

It is similar to the `-pg` flag provided by gcc or clang, but without
generating a `__gmon_start__` function for executables. If a program
runs without being traced, no `gmon.out` will be written to disk.

Under the hood, it simply adds `"instrument-function-entry-inlined"="mcount"`
attribute to every function. The `post-inline-ee-instrument` LLVM pass does
the actual job.

[1]: https://github.com/namhyung/uftrace
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 30, 2018

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Dec 31, 2018

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 31, 2018

📌 Commit 31a5066 has been approved by estebank

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 31, 2018

⌛️ Testing commit 31a5066 with merge 6efaef6...

bors added a commit that referenced this pull request Dec 31, 2018

Auto merge of #57220 - quark-zju:mcount, r=estebank
Add `-Z instrument-mcount`

This flag inserts `mcount` function call to the beginning of every function
after inline processing. So tracing tools like uftrace [1] (or ftrace for
Linux kernel modules) have a chance to examine function calls.

It is similar to the `-pg` flag provided by gcc or clang, but without
generating a `__gmon_start__` function for executables. If a program
runs without being traced, no `gmon.out` will be written to disk.

Under the hood, it simply adds `"instrument-function-entry-inlined"="mcount"`
attribute to every function. The `post-inline-ee-instrument` LLVM pass does
the actual job.

[1]: https://github.com/namhyung/uftrace
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 31, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: estebank
Pushing 6efaef6 to master...

@bors bors merged commit 31a5066 into rust-lang:master Dec 31, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Dec 31, 2018

Is it known that all the tools use specifically the mcount function name? A codegen test would’ve been nice as well.

@quark-zju

This comment has been minimized.

Copy link
Contributor

quark-zju commented Dec 31, 2018

Good question. clang -pg defaults to mcount but platforms can override it. The rule seems rather complicated. I think a complete solution would be platform-dependent. I'll add a comment, and try to add a test.

EDIT: uftrace also uses different names on different platforms.

alexreg added a commit to alexreg/rust that referenced this pull request Dec 31, 2018

Auto merge of rust-lang#57220 - quark-zju:mcount, r=estebank
Add `-Z instrument-mcount`

This flag inserts `mcount` function call to the beginning of every function
after inline processing. So tracing tools like uftrace [1] (or ftrace for
Linux kernel modules) have a chance to examine function calls.

It is similar to the `-pg` flag provided by gcc or clang, but without
generating a `__gmon_start__` function for executables. If a program
runs without being traced, no `gmon.out` will be written to disk.

Under the hood, it simply adds `"instrument-function-entry-inlined"="mcount"`
attribute to every function. The `post-inline-ee-instrument` LLVM pass does
the actual job.

[1]: https://github.com/namhyung/uftrace

quark-zju added a commit to quark-zju/rust that referenced this pull request Jan 1, 2019

Use platform-dependent mcount function
Follow up with @nagisa's comment on rust-lang#57220. Not all platforms use the
`mcount` name. Added a test.

@sanxiyn sanxiyn referenced this pull request Jan 13, 2019

Closed

mcount support?? #54500

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