D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5848 - Coverage always report 0000000 for inlined function
Summary: Coverage always report 0000000 for inlined function
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-16 11:39 UTC by kennytm
Modified: 2024-12-13 17:55 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kennytm 2011-04-16 11:39:31 UTC
When a function is inlined, the coverage result will not consider it was called, and always report the coverage count as 0000000.

For example, the program:

int inlined(int p, int q) {
    return p+q;
}
void main() {
    inlined(1, 3);
}

without -inline, the coverage result is

       |int inlined(int p, int q) {
      1|    return p+q;
       |}
       |void main() {
      1|    inlined(1, 3);
       |}
x.d is 100% covered

with -inline, the 'inlined' function becomes uncovered

       |int inlined(int p, int q) {
0000000|    return p+q;
       |}
       |void main() {
      1|    inlined(1, 3);
       |}
x.d is 50% covered
Comment 1 bearophile_hugs 2011-04-16 11:50:22 UTC
What kind of textual output do you desire in this situation?
Comment 2 kennytm 2011-04-16 12:06:15 UTC
(In reply to comment #1)
> What kind of textual output do you desire in this situation?

What do you mean?
Comment 3 bearophile_hugs 2011-04-16 12:54:22 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > What kind of textual output do you desire in this situation?
> 
> What do you mean?

What coverage results textual file do you want DMD to save on disk about that inlined() function when you compile the program with the -inline switch too?
Comment 4 kennytm 2011-04-17 00:50:20 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > What kind of textual output do you desire in this situation?
> > 
> > What do you mean?
> 
> What coverage results textual file do you want DMD to save on disk about that
> inlined() function when you compile the program with the -inline switch too?

Ideally that line should display "1", like the 2nd piece of code I've shown in the first post. The coverage percent should be 100%, not 50%. Why would one expect to get 0000000 when a line of code is used?

If it's not possible to get an exact count, at least it should show something other than 0000000, and count that line as covered.

In gcov the equivalent program shows '1' in the corresponding line even with maximum optimization (-O3). So avoiding 0000000 in most of the cases should be possible.
Comment 5 SomeDude 2012-04-23 09:09:59 UTC
With dmd 2.059:

PS E:\DigitalMars\dmd2\samples> rdmd -cov bug
PS E:\DigitalMars\dmd2\samples> cat bug.lst
       |//import std.stdio, std.range, std.algorithm, std.string;
       |
       |import std.stdio;
       |
       |int inlined(int p, int q) {
      1|    return p+q;
       |}
       |void main() {
      1|    inlined(1, 3);
       |}
bug.d is 100% covered
PS E:\DigitalMars\dmd2\samples>
Comment 6 kennytm 2012-04-23 09:44:00 UTC
(In reply to comment #5)
> With dmd 2.059:
> 
> PS E:\DigitalMars\dmd2\samples> rdmd -cov bug
> PS E:\DigitalMars\dmd2\samples> cat bug.lst
>        |//import std.stdio, std.range, std.algorithm, std.string;
>        |
>        |import std.stdio;
>        |
>        |int inlined(int p, int q) {
>       1|    return p+q;
>        |}
>        |void main() {
>       1|    inlined(1, 3);
>        |}
> bug.d is 100% covered
> PS E:\DigitalMars\dmd2\samples>

Please make sure you have the '-inline' flag. Test with 'dmd', not 'rdmd'.
Comment 7 SomeDude 2012-04-23 12:29:55 UTC
(In reply to comment #6)
> (In reply to comment #5)
> Please make sure you have the '-inline' flag. Test with 'dmd', not 'rdmd'.

OK, with -inline I get the same result you got.
Comment 8 dlangBugzillaToGithub 2024-12-13 17:55:08 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18337

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB