-
Notifications
You must be signed in to change notification settings - Fork 13.4k
LLVM IR coverage encoding aligns closer to Clang's #75416
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,6 +295,21 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> { | |
|
||
let (file_name, start_line, start_col, end_line, end_col) = self.code_region(&span); | ||
|
||
// FIXME(richkadel): Note that `const_str()` results in the creation of an `Allocation` to | ||
// hold one copy of each unique filename. It looks like that `Allocation` may translate into | ||
// the creation of an `@alloc` in LLVM IR that is never actually used by runtime code. | ||
// | ||
// Example LLVM IR: | ||
// | ||
// @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 commentThe 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. |
||
// it gets added to the LLVM IR? Do we need some kind of reference counting to know it's | ||
// not used by any runtime code? | ||
// | ||
// This question is moot if I convert the Call Terminators to Statements, I believe: | ||
// https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implement.20LLVM-compatible.20source-based.20cod.20compiler-team.23278/near/206731748 | ||
args.push(self.const_str(&file_name, inject_at)); | ||
args.push(self.const_u32(start_line, inject_at)); | ||
args.push(self.const_u32(start_col, inject_at)); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/run-make-fulldeps/instrument-coverage/filecheck-patterns.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Check for metadata, variables, declarations, and function definitions injected | ||
# into LLVM IR when compiling with -Zinstrument-coverage. | ||
richkadel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
WIN32: $__llvm_profile_runtime_user = comdat any | ||
|
||
CHECK: @__llvm_coverage_mapping = internal constant | ||
CHECK-SAME: section "[[INSTR_PROF_COVMAP]]", align 8 | ||
|
||
WIN32: @__llvm_profile_runtime = external global i32 | ||
|
||
CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = [[PRIVATE_GLOBAL]] | ||
CHECK-SAME: section "[[INSTR_PROF_CNTS]]", align 8 | ||
|
||
CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = [[PRIVATE_GLOBAL]] | ||
CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, | ||
CHECK-SAME: ()* @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called to i8*), | ||
CHECK-SAME: section "[[INSTR_PROF_DATA]]", align 8 | ||
|
||
CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main = [[PRIVATE_GLOBAL]] | ||
CHECK-SAME: section "[[INSTR_PROF_CNTS]]", align 8 | ||
|
||
CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog4main = [[PRIVATE_GLOBAL]] | ||
CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main, | ||
CHECK-SAME: ()* @_R{{[a-zA-Z0-9_]+}}testprog4main to i8*), | ||
CHECK-SAME: section "[[INSTR_PROF_DATA]]", align 8 | ||
|
||
CHECK: @__llvm_prf_nm = private constant | ||
CHECK-SAME: section "[[INSTR_PROF_NAME]]", align 1 | ||
|
||
CHECK: @llvm.used = appending global | ||
CHECK-SAME: i8* bitcast ({ {{.*}} }* @__llvm_coverage_mapping to i8*) | ||
WIN32-SAME: i8* bitcast (i32 ()* @__llvm_profile_runtime_user to i8*) | ||
CHECK-SAME: i8* bitcast ({ {{.*}} }* @__profd__R{{[a-zA-Z0-9_]*}}testprog4main to i8*) | ||
CHECK-SAME: i8* getelementptr inbounds ({{.*}}* @__llvm_prf_nm, i32 0, i32 0) | ||
CHECK-SAME: section "llvm.metadata" | ||
|
||
CHECK: define hidden { {{.*}} } @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called() unnamed_addr #{{[0-9]+}} { | ||
CHECK-NEXT: start: | ||
CHECK-NOT: bb{{[0-9]+}}: | ||
CHECK: %pgocount = load i64, i64* getelementptr inbounds | ||
CHECK-SAME: * @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, | ||
|
||
CHECK: declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]] | ||
|
||
WIN32: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() #[[LLVM_PROFILE_RUNTIME_USER_ATTR:[0-9]+]] comdat { | ||
WIN32-NEXT: %1 = load i32, i32* @__llvm_profile_runtime | ||
WIN32-NEXT: ret i32 %1 | ||
WIN32-NEXT: } | ||
|
||
CHECK: attributes #[[LLVM_INSTRPROF_INCREMENT_ATTR]] = { nounwind } | ||
WIN32: attributes #[[LLVM_PROFILE_RUNTIME_USER_ATTR]] = { noinline } |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.