taiki-e / cargo-llvm-cov

Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Apache License 2.0
858 stars 57 forks source link

Code compiled with different #[cfg] flags shows up as different instantiations #344

Closed Ekleog-NEAR closed 3 months ago

Ekleog-NEAR commented 5 months ago

Initially reported by @Dushistov here:

Oh, that's why not generic functions some times have several instantiation according to html generated by cargo-llvm-cov:

237814209-98e1616c-04a5-4da8-b509-b079f137ff40

The solution might end up being the same as #43

michaelvlach commented 5 months ago

As taiki-e said in the other thread this is a problem of LLVM and not much can be done in cargo-llvm-cov about it. The coverage profiles should be merged but llvm-cov/llvm-profdata would need to do that.

taiki-e commented 5 months ago

(I'm wondering if this may be another instance of https://github.com/taiki-e/cargo-llvm-cov/issues/325.)

michaelvlach commented 5 months ago

(I'm wondering if this may be another instance of #325.)

It almost certainly is. I am also pleasantly surprised that I was wrong and that the issue can be solved with a demangler even with current LLVM implementation! That is great news and could improve teh quality of the coverage reporting.

taiki-e commented 3 months ago

This probably has been fixed in v0.6.7 (https://github.com/taiki-e/cargo-llvm-cov/pull/354). Could you recheck this with v0.6.7?

michaelvlach commented 3 months ago

This probably has been fixed in v0.6.7 (#354). Could you recheck this with v0.6.7?

Thanks for this, I have tried it and I see no missing lines with multiple instantiations anymore as long as the coverage overlaps.

The only remaining issue is await not always mark as executed even though call cahing before/after was executed. But that is a different issue I think not related to demangler or instantiations.

taiki-e commented 3 months ago

Thanks for confirming!

The only remaining issue is await not always mark as executed even though call cahing before/after was executed. But that is a different issue I think not related to demangler or instantiations.

Yeah, it's different rustc bug: https://github.com/rust-lang/rust/issues/98712