-
Notifications
You must be signed in to change notification settings - Fork 13k
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
LLVM IR coverage encoding aligns closer to Clang's #75416
Conversation
8d80dd3
to
cbb073c
Compare
@tmandry @wesleywiser - Since this PR modifies LLVM IR without changing the final result (coverage counts), I just added a new test for LLVM IR expected patterns, using LLVM's "FileCheck" tool (and following a similar approach used to test Rust PGO). See: src/test/run-make-fulldeps/instrument-coverage/filecheck-patterns.txt |
This comment has been minimized.
This comment has been minimized.
Actually, after discussing with Tyler offline, I'm moving this discussion about using a Statement instead of BasicBlock to Zulip. |
cbb073c
to
799ef9c
Compare
I removed the FIXME comment, now replaced by the live Zulip thread discussing imlementing a new StatementKind. |
src/test/run-make-fulldeps/instrument-coverage/filecheck-patterns.txt
Outdated
Show resolved
Hide resolved
799ef9c
to
a670540
Compare
// @alloc4 = private unnamed_addr constant <{ [43 x i8] }> \ | ||
// <{ [43 x i8] c"C:\\msys64\\home\\richkadel\\rust\\rust_basic.rs" }>, align 1 | ||
// | ||
// Can I flag the alloc as something not to be added to codegen? Or somehow remove it before |
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.
Hmm... I'm not aware of any facility currently to do this but this might be something we should look into since MIR optimizations could also cause some allocations to no longer be needed.
@bors r+ rollup=never (due to the LLVM IR tests) |
📌 Commit a670540017a7e61532684ef333a60c0722229190 has been approved by |
⌛ Testing commit a670540017a7e61532684ef333a60c0722229190 with merge b3afc68b9ff9e258b98c98a3915160f280f0e0eb... |
@bors retry yielding to rollup |
✌️ @richkadel can now approve this pull request |
⌛ Trying commit a670540017a7e61532684ef333a60c0722229190 with merge 0c5491bd41285af2f061dc1f496b4920fdd119c2... |
☀️ Try build successful - checks-actions, checks-azure |
@bors r+ |
📌 Commit a670540017a7e61532684ef333a60c0722229190 has been approved by |
⌛ Testing commit a670540017a7e61532684ef333a60c0722229190 with merge 9da5d2aa6077b7b41f068a537e1968c1c3f9e946... |
@bors retry yielding |
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry yielding |
⌛ Testing commit a670540017a7e61532684ef333a60c0722229190 with merge 8a6c2ef7f1239c35370200c23e2d435a5bf2b54d... |
💔 Test failed - checks-azure |
I forgot MacOS section names are a little different. I'll compile on my Mac and fix this. |
a670540
to
49e5445
Compare
I found some areas for improvement while attempting to debug the SegFault issue when running rust programs compiled using MSVC, with coverage instrumentation. I discovered that LLVM's coverage writer was generating incomplete function name variable names (that's not a typo: the name of the variable that holds a function name). The existing implementation used one-up numbers to distinguish variables, and correcting the names did not fix the MSVC coverage bug, but the fix in this PR makes the names and resulting LLVM IR easier to follow and more consistent with Clang's implementation. I also changed the way the `-Zinstrument-coverage` option is supported in symbol_export.rs. The original implementation was incorrect, and the corrected version matches the handling for `-Zprofile-generate`, as it turns out. (An argument could be made that maybe `-Zinstrument-coverage` should automatically enable `-Cprofile-generate`. In fact, if `-Cprofile-generate` is analagous to Clang's `-fprofile-generate`, as some documentation implies, Clang always requires this flag for its implementation of source-based code coverage. This would require a little more validation, and if implemented, would probably require updating some of the user-facing messages related to `-Cprofile-generate` to not be so specific to the PGO use case.) None of these changes fixed the MSVC coverage problems, but they should still be welcome improvements. Lastly, I added some additional FIXME comments in instrument_coverage.rs describing issues I found with the generated LLVM IR that would be resolved if the coverage instrumentation is injected with a `Statement` instead of as a new `BasicBlock`. I describe seven advantages of this change, but it requires some discussion before making a change like this.
49e5445
to
ba18978
Compare
@bors retry yielding |
@bors r+ rollup=never (due to the LLVM IR tests) |
📌 Commit ba18978 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
I found some areas for improvement while attempting to debug the
SegFault issue when running rust programs compiled using MSVC, with
coverage instrumentation.
I discovered that LLVM's coverage writer was generating incomplete
function name variable names (that's not a typo: the name of the
variable that holds a function name).
The existing implementation used one-up numbers to distinguish
variables, and correcting the names did not fix the MSVC coverage bug,
but the fix in this PR makes the names and resulting LLVM IR easier to
follow and more consistent with Clang's implementation.
I also changed the way the
-Zinstrument-coverage
option is supported insymbol_export.rs. The original implementation was incorrect, and the
corrected version matches the handling for
-Zprofile-generate
, as itturns out.
(An argument could be made that maybe
-Zinstrument-coverage
shouldautomatically enable
-Cprofile-generate
. In fact, if-Cprofile-generate
is analagous to Clang's-fprofile-generate
, assome documentation implies, Clang always requires this flag for its
implementation of source-based code coverage. This would require a
little more validation, and if implemented, would probably require
updating some of the user-facing messages related to
-Cprofile-generate
to not be so specific to the PGO use case.)None of these changes fixed the MSVC coverage problems, but they should
still be welcome improvements.
Lastly, I added some additional FIXME comments in instrument_coverage.rs
describing issues I found with the generated LLVM IR that would be
resolved if the coverage instrumentation is injected with a
Statement
instead of as a new
BasicBlock
. I describe seven advantages of thischange, but it requires some discussion before making a change like
this.
r? @tmandry