This is an archive of the discontinued LLVM Phabricator instance.

llvm-cov produces inconsistent result when file appears multiple times in gcno
ClosedPublic

Authored by tenta4 on Jun 8 2023, 8:56 AM.

Details

Summary

My gcno/gcda files contain some of sources multiple times and sometimes they have different paths formats.
For example

llvm-cov gcov test_unit_MXR_Settings_SettingsEngine_CSettingsHandler.dir/__/__/__/src/CSettingsHandler.cpp.gcno -b -x -i  | grep CSettingsHandler.cpp 
File '../../../src/Settings/SettingsEngine/test/unit_test/CSettingsHandler/../../../src/CSettingsHandler.cpp'
Lines executed:75.00% of 8
Branches executed:100.00% of 12
Taken at least once:41.67% of 12
No calls

--
File '../../../src/Settings/SettingsEngine/src/CSettingsHandler.cpp'
Lines executed:98.37% of 184
Branches executed:97.34% of 601
Taken at least once:56.91% of 601
No calls

llvm-cov randomly takes one of records and adds it to cov-file.
That is why my coverage results usually wrong and furthermore they differ every now and than

My patch unifies filenames, so coverage results are merged.

llvm-cov gcov /home/tenta4/work/arcreator/mxr2/build/build_products_cov/build_host_release/src/Settings/SettingsEngine/test/unit_test/CSettingsHandler/CMakeFiles/test_unit_MXR_Settings_SettingsEngine_CSettingsHandler.dir/__/__/__/src/CSettingsHandler.cpp.gcno -b -x -i  | grep CSettingsHandler.cpp -A5
File '../../../src/Settings/SettingsEngine/src/CSettingsHandler.cpp'
Lines executed:97.37% of 190
Branches executed:97.39% of 613
Taken at least once:56.61% of 613
No calls

Diff Detail

Event Timeline

tenta4 created this revision.Jun 8 2023, 8:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 8:56 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
tenta4 requested review of this revision.Jun 8 2023, 8:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 8:56 AM
tenta4 edited the summary of this revision. (Show Details)Jun 8 2023, 9:00 AM
tenta4 edited the summary of this revision. (Show Details)
tenta4 edited the summary of this revision. (Show Details)Jun 8 2023, 9:05 AM
bogner added inline comments.Jun 8 2023, 9:13 PM
llvm/lib/ProfileData/GCOV.cpp
146

Why not SmallString<256> P(filename)?

Regardless, it might help readability to add a function named something like "addNormalizedPathToMap" that does this and calls emplace as below rather than doing this all inline here.

tenta4 updated this revision to Diff 529870.Jun 9 2023, 2:32 AM
tenta4 updated this revision to Diff 529912.Jun 9 2023, 4:46 AM
tenta4 marked an inline comment as done.

Please review 🙏

bogner accepted this revision.Jun 14 2023, 4:06 PM

Looks good. Do you need me to commit this for you?

This revision is now accepted and ready to land.Jun 14 2023, 4:06 PM

Yes, do it please, since I do not have access.
Many thinks.
Regards, Oleksii Odynochenko <oleksii.odynochenko@gmail.com>

This revision was automatically updated to reflect the committed changes.