[PATCH] D18831: [Coverage] Use the count value of the outer region for an expansion region.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 03:23:58 PDT 2016
ikudrin added a comment.
Another example which is also fixed by this patch:
$ cat > sample.cpp << EOF
#define DO_LOOP() \
for (int k = 0; k < 2; ++k) {}
#define DO_SOMETHING() \
{ \
DO_LOOP(); \
}
int main() {
DO_SOMETHING();
DO_SOMETHING();
return 0;
}
EOF
$ clang++ -fprofile-instr-generate -fcoverage-mapping sample.cpp
$ ./a.out
$ llvm-profdata merge -o default.profdata default.profraw
$ llvm-cov show a.out -instr-profile default.profdata
| 1|#define DO_LOOP() \
6| 2| for (int k = 0; k < 2; ++k) {}
| 3|
| 4|#define DO_SOMETHING() \
2| 5| { \
3| 6| DO_LOOP(); \
2| 7| }
| 8|
1| 9|int main() {
1| 10| DO_SOMETHING();
1| 11| DO_SOMETHING();
1| 12| return 0;
1| 13|}
Pay attention to line 6. The patched llvm-cov generates the following output:
$ llvm-cov show a.out -instr-profile default.profdata
| 1|#define DO_LOOP() \
6| 2| for (int k = 0; k < 2; ++k) {}
| 3|
| 4|#define DO_SOMETHING() \
2| 5| { \
2| 6| DO_LOOP(); \
2| 7| }
| 8|
1| 9|int main() {
1| 10| DO_SOMETHING();
1| 11| DO_SOMETHING();
1| 12| return 0;
1| 13|}
http://reviews.llvm.org/D18831
More information about the llvm-commits
mailing list