Dmitry Volyntsev
2015-Feb-10 15:15 UTC
[LLVMdev] Coverage mapping issue: Malformed profile data
Hi all!
It seems I came across on issue with coverage mapping
(http://www.llvm.org/docs/CoverageMappingFormat.html)
check on:
llvm revision: r228136
clang Last Changed Rev: 228121
build: Debug+Asserts
OS: ubuntu 14.04
Here is simple snippets
test1.c: NOT OK
=================#include <stdio.h>
static int foo() { return 42; }
int main() {
return 0;
}
=================cp src/test1.c src/test.c; rm -fr default.profraw test.profdata
;
clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate
-fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0
-fprofile-instr-generate -fcoverage-mapping; ./bin/test ;
llvm-profdata merge -o test.profdata default.profraw; llvm-cov show
./bin/test -instr-profile=test.profdata
error: Failed to load coverage: Malformed profile data
test2.c: OK
=================#include <stdio.h>
static int foo() { return 42; }
int main() {
return foo();
}
=================cp src/test2.c src/test.c; rm -fr default.profraw test.profdata
;
clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate
-fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0
-fprofile-instr-generate -fcoverage-mapping; ./bin/test ;
llvm-profdata merge -o test.profdata default.profraw; llvm-cov show
./bin/test -instr-profile=test.profdata
/home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c:
| 1|#include <stdio.h>
| 2|
1| 3|static int foo() { return 42; }
1| 4|int main() {
1| 5| return foo();
1| 6|}
test3.c: OK
=================#include <stdio.h>
int foo() { return 42; }
int main() {
return 0;
}
=================cp src/test3.c src/test.c; rm -fr default.profraw test.profdata
;
clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate
-fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0
-fprofile-instr-generate -fcoverage-mapping; ./bin/test ;
llvm-profdata merge -o test.profdata default.profraw; llvm-cov show
./bin/test -instr-profile=test.profdata
/home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c:
| 1|#include <stdio.h>
| 2|
0| 3|int foo() { return 42; }
1| 4|int main() {
1| 5| return 0;
1| 6|}
As far I can understand issue somehow related to unused static functions.
Also, as I can track down the problem raised because of
lib/ProfileData/CoverageMappingReader.cpp (SectionData::get) expects
that function's names located inside __llvm_prf_names section but it
not true in case of test1.c, instead some function names located
inside .rodata section.
Is it known issue?
any hints, how to avoid or workaround it?
--
Be happy,
Best regards,
Dmitry Volyntsev
Justin Bogner
2015-Feb-10 16:47 UTC
[LLVMdev] Coverage mapping issue: Malformed profile data
Dmitry Volyntsev <xeioexception at gmail.com> writes:> It seems I came across on issue with coverage mapping > (http://www.llvm.org/docs/CoverageMappingFormat.html) > > check on: > llvm revision: r228136 > clang Last Changed Rev: 228121 > build: Debug+Asserts > OS: ubuntu 14.04 > > > Here is simple snippets > > test1.c: NOT OK > =================> #include <stdio.h> > > static int foo() { return 42; } > int main() { > return 0; > } > =================> cp src/test1.c src/test.c; rm -fr default.profraw test.profdata ; > clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate > -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 > -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; > llvm-profdata merge -o test.profdata default.profraw; llvm-cov show > ./bin/test -instr-profile=test.profdata > > error: Failed to load coverage: Malformed profile data > > > > test2.c: OK > =================> #include <stdio.h> > > static int foo() { return 42; } > int main() { > return foo(); > } > =================> cp src/test2.c src/test.c; rm -fr default.profraw test.profdata ; > clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate > -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 > -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; > llvm-profdata merge -o test.profdata default.profraw; llvm-cov show > ./bin/test -instr-profile=test.profdata > > /home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c: > | 1|#include <stdio.h> > | 2| > 1| 3|static int foo() { return 42; } > 1| 4|int main() { > 1| 5| return foo(); > 1| 6|} > > test3.c: OK > =================> #include <stdio.h> > > int foo() { return 42; } > int main() { > return 0; > } > =================> cp src/test3.c src/test.c; rm -fr default.profraw test.profdata ; > clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate > -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 > -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; > llvm-profdata merge -o test.profdata default.profraw; llvm-cov show > ./bin/test -instr-profile=test.profdata > > /home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c: > | 1|#include <stdio.h> > | 2| > 0| 3|int foo() { return 42; } > 1| 4|int main() { > 1| 5| return 0; > 1| 6|} > > > As far I can understand issue somehow related to unused static functions.It looks like this hits when a function isn't emitted by the frontend but we emit an "empty" coverage map for it.> Also, as I can track down the problem raised because of > lib/ProfileData/CoverageMappingReader.cpp (SectionData::get) expects > that function's names located inside __llvm_prf_names section but it > not true in case of test1.c, instead some function names located > inside .rodata section.The problem is that these don't go through the InstrProfiling machinery, so the names aren't lowered properly. I'd noticed a related issue not long ago, but fixed a bug by inspection that happened to hide it (r226764). Feel free to file a bug (http://llvm.org/bugs/) and I'll to get this fixed in the next day or two.
Dmitry Volyntsev
2015-Feb-10 18:55 UTC
[LLVMdev] Coverage mapping issue: Malformed profile data
Here is the bug: http://llvm.org/bugs/show_bug.cgi?id=22531 On Tue, Feb 10, 2015 at 7:47 PM, Justin Bogner <mail at justinbogner.com> wrote:> Dmitry Volyntsev <xeioexception at gmail.com> writes: >> It seems I came across on issue with coverage mapping >> (http://www.llvm.org/docs/CoverageMappingFormat.html) >> >> check on: >> llvm revision: r228136 >> clang Last Changed Rev: 228121 >> build: Debug+Asserts >> OS: ubuntu 14.04 >> >> >> Here is simple snippets >> >> test1.c: NOT OK >> =================>> #include <stdio.h> >> >> static int foo() { return 42; } >> int main() { >> return 0; >> } >> =================>> cp src/test1.c src/test.c; rm -fr default.profraw test.profdata ; >> clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate >> -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 >> -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; >> llvm-profdata merge -o test.profdata default.profraw; llvm-cov show >> ./bin/test -instr-profile=test.profdata >> >> error: Failed to load coverage: Malformed profile data >> >> >> >> test2.c: OK >> =================>> #include <stdio.h> >> >> static int foo() { return 42; } >> int main() { >> return foo(); >> } >> =================>> cp src/test2.c src/test.c; rm -fr default.profraw test.profdata ; >> clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate >> -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 >> -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; >> llvm-profdata merge -o test.profdata default.profraw; llvm-cov show >> ./bin/test -instr-profile=test.profdata >> >> /home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c: >> | 1|#include <stdio.h> >> | 2| >> 1| 3|static int foo() { return 42; } >> 1| 4|int main() { >> 1| 5| return foo(); >> 1| 6|} >> >> test3.c: OK >> =================>> #include <stdio.h> >> >> int foo() { return 42; } >> int main() { >> return 0; >> } >> =================>> cp src/test3.c src/test.c; rm -fr default.profraw test.profdata ; >> clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate >> -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 >> -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; >> llvm-profdata merge -o test.profdata default.profraw; llvm-cov show >> ./bin/test -instr-profile=test.profdata >> >> /home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c: >> | 1|#include <stdio.h> >> | 2| >> 0| 3|int foo() { return 42; } >> 1| 4|int main() { >> 1| 5| return 0; >> 1| 6|} >> >> >> As far I can understand issue somehow related to unused static functions. > > It looks like this hits when a function isn't emitted by the frontend > but we emit an "empty" coverage map for it. > >> Also, as I can track down the problem raised because of >> lib/ProfileData/CoverageMappingReader.cpp (SectionData::get) expects >> that function's names located inside __llvm_prf_names section but it >> not true in case of test1.c, instead some function names located >> inside .rodata section. > > The problem is that these don't go through the InstrProfiling machinery, > so the names aren't lowered properly. I'd noticed a related issue not > long ago, but fixed a bug by inspection that happened to hide it > (r226764). > > Feel free to file a bug (http://llvm.org/bugs/) and I'll to get this > fixed in the next day or two.-- Be happy, Best regards, Dmitry Volyntsev
Dmitry Volyntsev
2015-Feb-13 15:06 UTC
[LLVMdev] Coverage mapping issue: Malformed profile data
Here is probably a related bug: http://llvm.org/bugs/show_bug.cgi?id=22575 On Tue, Feb 10, 2015 at 7:47 PM, Justin Bogner <mail at justinbogner.com> wrote:> Dmitry Volyntsev <xeioexception at gmail.com> writes: >> It seems I came across on issue with coverage mapping >> (http://www.llvm.org/docs/CoverageMappingFormat.html) >> >> check on: >> llvm revision: r228136 >> clang Last Changed Rev: 228121 >> build: Debug+Asserts >> OS: ubuntu 14.04 >> >> >> Here is simple snippets >> >> test1.c: NOT OK >> =================>> #include <stdio.h> >> >> static int foo() { return 42; } >> int main() { >> return 0; >> } >> =================>> cp src/test1.c src/test.c; rm -fr default.profraw test.profdata ; >> clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate >> -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 >> -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; >> llvm-profdata merge -o test.profdata default.profraw; llvm-cov show >> ./bin/test -instr-profile=test.profdata >> >> error: Failed to load coverage: Malformed profile data >> >> >> >> test2.c: OK >> =================>> #include <stdio.h> >> >> static int foo() { return 42; } >> int main() { >> return foo(); >> } >> =================>> cp src/test2.c src/test.c; rm -fr default.profraw test.profdata ; >> clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate >> -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 >> -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; >> llvm-profdata merge -o test.profdata default.profraw; llvm-cov show >> ./bin/test -instr-profile=test.profdata >> >> /home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c: >> | 1|#include <stdio.h> >> | 2| >> 1| 3|static int foo() { return 42; } >> 1| 4|int main() { >> 1| 5| return foo(); >> 1| 6|} >> >> test3.c: OK >> =================>> #include <stdio.h> >> >> int foo() { return 42; } >> int main() { >> return 0; >> } >> =================>> cp src/test3.c src/test.c; rm -fr default.profraw test.profdata ; >> clang -c -o obj/test.o src/test.c -I -g -O0 -fprofile-instr-generate >> -fcoverage-mapping; clang -o bin/test obj/test.o -I -g -O0 >> -fprofile-instr-generate -fcoverage-mapping; ./bin/test ; >> llvm-profdata merge -o test.profdata default.profraw; llvm-cov show >> ./bin/test -instr-profile=test.profdata >> >> /home/xeioex/workspace/clang/experiments/llvm-cov/test/src/test.c: >> | 1|#include <stdio.h> >> | 2| >> 0| 3|int foo() { return 42; } >> 1| 4|int main() { >> 1| 5| return 0; >> 1| 6|} >> >> >> As far I can understand issue somehow related to unused static functions. > > It looks like this hits when a function isn't emitted by the frontend > but we emit an "empty" coverage map for it. > >> Also, as I can track down the problem raised because of >> lib/ProfileData/CoverageMappingReader.cpp (SectionData::get) expects >> that function's names located inside __llvm_prf_names section but it >> not true in case of test1.c, instead some function names located >> inside .rodata section. > > The problem is that these don't go through the InstrProfiling machinery, > so the names aren't lowered properly. I'd noticed a related issue not > long ago, but fixed a bug by inspection that happened to hide it > (r226764). > > Feel free to file a bug (http://llvm.org/bugs/) and I'll to get this > fixed in the next day or two.-- Be happy, Best regards, Dmitry Volyntsev
Maybe Matching Threads
- llvm-cov: Combined report for multiple executables
- llvm-cov: Combined report for multiple executables
- Code coverage for member functions that are defined inside the class
- The state of IRPGO (3 remaining work items)
- The state of IRPGO (3 remaining work items)