Skip to content

Coverage on Multiple Architectures Fails #148673

@awearden

Description

@awearden
1|       |#include <stdio.h>
2|      2|int main(){
3|       |#if defined(__hexagon__)
4|       |    puts("hexagon path");
5|       |#else
6|      2|    puts("generic path");
7|      2|#endif
8|      2|    return 0;
9|      2|}

The code coverage report above is a result of generating two .profraw files, one on hexagon and another on x86, then using llvm-profdata to merge the two results together then displaying the results using llvm-cov. Below is the workflow used to generate this report.

hexagon-clang -fprofile-instr-generate -fcoverage-mapping -o hexagon_exec arch_ifdef.c -g

clang -o x86_exec arch_ifdef.c -stdlib=libc++ -fprofile-instr-generate -fcoverage-mapping

llvm-profdata merge -o all.profdata =x86.profraw hexagon.profraw

llvm-cov show --object=x86_exec --arch=x86_64 --object=hexagon_exec --arch=hexagon --dump --instr-profile=all.profdata > coverage.txt

The coverage report should report the following:

1|       |#include <stdio.h>
2|      2|int main(){
3|      1|#if defined(__hexagon__)
4|      1|    puts("hexagon path");
5|      1|#else
6|      1|    puts("generic path");
7|      2|#endif
8|      2|    return 0;
9|      2|}

From what I understand, this issue is happening because each of the binaries are only creating one counter region so the “#else puts(“generic path”)” section will not get mapped to a counter that differentiates it from the counter of the main function. Additionally, the hexagon counters are not showing up at all because when llvm-cov processes the binaries for each of these files, it will first process the x86 binary, but when it processes the hexagon binary, it will detect that the main function has already been accounted for and skip it. are there any viable ways of fixing this merging across multiple architectures?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions