[llvm] [Coverage] Skip empty profile name section (PR #108480)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 19:22:54 PDT 2024


https://github.com/gulfemsavrun created https://github.com/llvm/llvm-project/pull/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.

>From 4fae6a4dbf750d7531b43e2e855a6bcc588c1b17 Mon Sep 17 00:00:00 2001
From: Gulfem Savrun Yeniceri <gulfem at google.com>
Date: Thu, 12 Sep 2024 19:06:54 -0700
Subject: [PATCH] [Coverage] Skip empty profile name section

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.
---
 llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
index 445b48067a9755..70967125001761 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -1065,6 +1065,9 @@ lookupSections(ObjectFile &OF, InstrProfSectKind IPSK) {
       // start/end of the section. If its size is 2 bytes, it's empty.
       if (IsCOFF && IPSK == IPSK_name && Section.getSize() == 2)
         continue;
+      // Skip empty profile name section.
+      if (IPSK == IPSK_name && Section.getSize() == 0)
+        continue;
       Sections.push_back(Section);
     }
   }



More information about the llvm-commits mailing list