aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/TestingSupport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-cov/TestingSupport.cpp')
-rw-r--r--llvm/tools/llvm-cov/TestingSupport.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/tools/llvm-cov/TestingSupport.cpp b/llvm/tools/llvm-cov/TestingSupport.cpp
index b99bd83157d0..9c6b25f2f585 100644
--- a/llvm/tools/llvm-cov/TestingSupport.cpp
+++ b/llvm/tools/llvm-cov/TestingSupport.cpp
@@ -10,6 +10,7 @@
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/raw_ostream.h"
#include <functional>
@@ -47,7 +48,7 @@ int convertForTestingMain(int argc, const char *argv[]) {
// Look for the sections that we are interested in.
int FoundSectionCount = 0;
- SectionRef ProfileNames, CoverageMapping;
+ SectionRef ProfileNames, CoverageMapping, CoverageRecords;
auto ObjFormat = OF->getTripleObjectFormat();
for (const auto &Section : OF->sections()) {
StringRef Name;
@@ -64,16 +65,20 @@ int convertForTestingMain(int argc, const char *argv[]) {
} else if (Name == llvm::getInstrProfSectionName(
IPSK_covmap, ObjFormat, /*AddSegmentInfo=*/false)) {
CoverageMapping = Section;
+ } else if (Name == llvm::getInstrProfSectionName(
+ IPSK_covfun, ObjFormat, /*AddSegmentInfo=*/false)) {
+ CoverageRecords = Section;
} else
continue;
++FoundSectionCount;
}
- if (FoundSectionCount != 2)
+ if (FoundSectionCount != 3)
return 1;
// Get the contents of the given sections.
uint64_t ProfileNamesAddress = ProfileNames.getAddress();
StringRef CoverageMappingData;
+ StringRef CoverageRecordsData;
StringRef ProfileNamesData;
if (Expected<StringRef> E = CoverageMapping.getContents())
CoverageMappingData = *E;
@@ -81,6 +86,12 @@ int convertForTestingMain(int argc, const char *argv[]) {
consumeError(E.takeError());
return 1;
}
+ if (Expected<StringRef> E = CoverageRecords.getContents())
+ CoverageRecordsData = *E;
+ else {
+ consumeError(E.takeError());
+ return 1;
+ }
if (Expected<StringRef> E = ProfileNames.getContents())
ProfileNamesData = *E;
else {
@@ -103,6 +114,10 @@ int convertForTestingMain(int argc, const char *argv[]) {
for (unsigned Pad = offsetToAlignment(OS.tell(), Align(8)); Pad; --Pad)
OS.write(uint8_t(0));
OS << CoverageMappingData;
+ // Coverage records data is expected to have an alignment of 8.
+ for (unsigned Pad = offsetToAlignment(OS.tell(), Align(8)); Pad; --Pad)
+ OS.write(uint8_t(0));
+ OS << CoverageRecordsData;
return 0;
}