[PATCH] D20286: [Coverage] Fix an issue where improper coverage mapping data could be loaded for an inline function.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 08:54:55 PDT 2016
ikudrin added a comment.
The motivation sample for this patch is the following:
$ cat > sample.h << EOF
inline int sample_func(int A) {
if (A > 0)
return A;
return 0;
}
EOF
$ cat > dummy.cpp << EOF
#include "sample.h"
EOF
$ cat > sample.cpp << EOF
#include "sample.h"
int main() {
return sample_func(5);
}
EOF
$ clang++ -fprofile-instr-generate -fcoverage-mapping dummy.cpp sample.cpp
$ ./a.out
$ llvm-profdata merge -o default.profdata default.profraw
$ llvm-cov show a.out -instr-profile default.profdata
warning: 1 functions have mismatched data.
sample.cpp:
| 1|#include "sample.h"
| 2|
1| 3|int main() {
1| 4| return sample_func(5);
1| 5|}
After applying the patch, the output is the following:
$ llvm-cov show a.out -instr-profile default.profdata
sample.h:
1| 1|inline int sample_func(int A) {
1| 2| if (A > 0)
1| 3| return A;
0| 4| return 0;
1| 5|}
sample.cpp:
| 1|#include "sample.h"
| 2|
1| 3|int main() {
1| 4| return sample_func(5);
1| 5|}
http://reviews.llvm.org/D20286
More information about the llvm-commits
mailing list