-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Coverage] getMaxBitmapSize: Scan max(BitmapIdx)
instead of the last Decision
#78963
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
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#define RANGE(a,b,c) ((a) <= (b) && (b) <= (c)) | ||
|
||
int sub(int c) { | ||
if (RANGE('0', c, '9')) return 1; | ||
return (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')); | ||
} | ||
|
||
extern void __llvm_profile_write_file(void); | ||
|
||
int main(int c, char **v) | ||
{ | ||
return (c > 1 ? sub(c) : 0); | ||
} |
Binary file not shown.
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,9 @@ | ||
main | ||
# Func Hash: | ||
99164 | ||
# Num Counters: | ||
2 | ||
# Counter Values: | ||
1 | ||
0 | ||
|
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,46 @@ | ||
# Test not to trigger the assertion failure in llvm-cov with empty bitmap. | ||
# REQUIRES: asserts | ||
|
||
# mcdc-maxbs.o contains the record: | ||
# | ||
# sub: | ||
# Decision,File 0, 5:11 -> 5:59 = M:1, C:4 | ||
# Branch,File 0, 5:12 -> 5:20 = #5, ((#0 - #1) - #5) [1,3,2] | ||
# Branch,File 0, 5:24 -> 5:32 = #6, (#5 - #6) [3,0,2] | ||
# Branch,File 0, 5:38 -> 5:46 = #7, (#4 - #7) [2,4,0] | ||
# Branch,File 0, 5:50 -> 5:58 = #8, (#7 - #8) [4,0,0] | ||
# Decision,File 1, 1:23 -> 1:47 = M:0, C:2 | ||
# Branch,File 1, 1:23 -> 1:33 = #2, (#0 - #2) [1,2,0] | ||
# Branch,File 1, 1:37 -> 1:47 = #3, (#2 - #3) [2,0,0] | ||
# | ||
# With the previous implementation, `Decision M:0 C:2` was picked up as | ||
# the last `Decision`. | ||
# The size of the bitmap was reported as `1` in this case. | ||
# Actually, the largest `Decision` is `M:1 C:4` and the size should be `3` | ||
# (Idx=1, len=16 bits). | ||
# | ||
# When a corresponding bitmap was not emitted, the dummy zero-ed bitmap is | ||
# allocated as `BitmapBytes` with `getMaxBitmapSize(Record) + 1` | ||
# (in this case, `1 + 1`, less than `3`). | ||
# It may overrun and would trigger `unexpected test vector` | ||
# by trailing uninitialized garbage. | ||
|
||
# RUN: llvm-profdata merge %S/Inputs/mcdc-maxbs.proftext -o %t.profdata | ||
# RUN: llvm-cov report --show-mcdc-summary %S/Inputs/mcdc-maxbs.o -instr-profile %t.profdata | ||
|
||
# Instructions for regenerating the test object: | ||
|
||
cd %S/Inputs # or copy %S/Inputs/mcdc-maxbs.c into the working directory | ||
clang -O3 -fcoverage-mcdc -fprofile-instr-generate \ | ||
-fcoverage-mapping -fcoverage-compilation-dir=. \ | ||
mcdc-maxbs.c -c -o mcdc-maxbs.o | ||
chapuni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Instructions for regenerating the test vector: | ||
|
||
clang -fprofile-instr-generate mcdc-maxbs.o | ||
|
||
# Doesn't crash if argc > 1 | ||
./a.out | ||
|
||
llvm-profdata merge --sparse -o default.profdata default.profraw | ||
llvm-profdata merge --text -o mcdc-maxbs.proftext default.profdata |
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.