Skip to content

Commit 536bdc9

Browse files
authored
[Coverage] Skip empty profile name section (llvm#108480)
llvm-cov reads __llvm_prf_names section in an object file to find the profile names, and it instead reads __llvm_covnames section in binary profile correlation mode when __llvm_prf_names section is omitted. This patch ensures that it still reads __llvm_covnames section when there is an empty __llvm_prf_names section.
1 parent ca49739 commit 536bdc9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,11 @@ lookupSections(ObjectFile &OF, InstrProfSectKind IPSK) {
10611061
if (!NameOrErr)
10621062
return NameOrErr.takeError();
10631063
if (stripSuffix(*NameOrErr) == Name) {
1064+
// Skip empty profile name section.
10641065
// COFF profile name section contains two null bytes indicating the
10651066
// start/end of the section. If its size is 2 bytes, it's empty.
1066-
if (IsCOFF && IPSK == IPSK_name && Section.getSize() == 2)
1067+
if (IPSK == IPSK_name &&
1068+
(Section.getSize() == 0 || (IsCOFF && Section.getSize() == 2)))
10671069
continue;
10681070
Sections.push_back(Section);
10691071
}

0 commit comments

Comments
 (0)