Skip to content
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

[LLVM-COV] source code inside a label after a loop is wrongly labeled as not executed in llvm-cov #34742

Closed
llvmbot opened this issue Nov 23, 2017 · 3 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category duplicate Resolved as duplicate

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 23, 2017

Bugzilla Link 35394
Resolution DUPLICATE
Resolved on Dec 07, 2017 02:47
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @def-,@vedantk

Extended Description

$ clang -v
clang version 6.0.0-svn318792-1~exp1 (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ cat small.c
int main()
{
int i=0, k=0;
if (1) {
if (1) {
goto lbl;
}
} else {
lbl:
for (; k < 2; k++)
;

    i = i+1;
}

printf("%d\n", i);
return 0;

}

$ clang -w -O0 -g -fcoverae-mapping -fprofile-instr-generate=small.profraw small.c; ./a.out; llvm-profdata merge small.profraw -o small.profdata; llvm-cov show a.out -instr-profile=small.profdata small.c > small.gcov
1

$ cat small.gcov
1| |int main()
2| 1|{
3| 1| int i=0, k=0;
4| 1| if (1) {
5| 1| if (1) {
6| 1| goto lbl;
7| 1| }
8| 0| } else {
9| 1|lbl:
10| 3| for (; k < 2; k++)
11| 2| ;
12| 0|
13| 0| i = i+1;
14| 0| }
15| 1|
16| 1| printf("%d\n", i);
17| 1| return 0;
18| 1|}

Line #​13 is executed but the output showed that this line is not executed in llvm-cov.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 24, 2017

$ clang -v
clang version 6.0.0-svn318792-1~exp1 (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ cat small.c
int main()
{
int i=0, k=0;
if (1) {
if (1) {
goto lbl;
}
} else {
lbl:
for (; k < 2; k++)
;

    i = i+1;
}

printf("%d\n", i);
return 0;

}

$ clang -w -O0 -g -fcoverae-mapping -fprofile-instr-generate=small.profraw
small.c; ./a.out; llvm-profdata merge small.profraw -o small.profdata;
llvm-cov show a.out -instr-profile=small.profdata small.c > small.gcov
1

sorry. The "-fcoverae-mapping" should be "-fcoverage-mapping". Thus the correct command should be as follows:
$ clang -w -O0 -g -fcoverage-mapping -fprofile-instr-generate=small.profraw small.c; ./a.out; llvm-profdata merge small.profraw -o small.profdata; llvm-cov show a.out -instr-profile=small.profdata small.c > small.gcov

$ cat small.gcov
1| |int main()
2| 1|{
3| 1| int i=0, k=0;
4| 1| if (1) {
5| 1| if (1) {
6| 1| goto lbl;
7| 1| }
8| 0| } else {
9| 1|lbl:
10| 3| for (; k < 2; k++)
11| 2| ;
12| 0|
13| 0| i = i+1;
14| 0| }
15| 1|
16| 1| printf("%d\n", i);
17| 1| return 0;
18| 1|}

Line #​13 is executed but the output showed that this line is not executed in
llvm-cov.

@vedantk
Copy link
Collaborator

vedantk commented Nov 30, 2017

*** This bug has been marked as a duplicate of bug llvm/llvm-bugzilla-archive#35426 ***

@vedantk
Copy link
Collaborator

vedantk commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#35426

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

2 participants