@@ -1037,9 +1037,8 @@ static Error getProfileNamesFromDebugInfo(StringRef FileName,
1037
1037
}
1038
1038
1039
1039
static Expected<std::unique_ptr<BinaryCoverageReader>>
1040
- loadBinaryFormat (std::unique_ptr<Binary> Bin,
1041
- IndexedInstrProfReader &ProfileReader, StringRef Arch,
1042
- StringRef CompilationDir = " " ,
1040
+ loadBinaryFormat (std::unique_ptr<Binary> Bin, StringRef Arch,
1041
+ InstrProfSymtab ProfSymTab, StringRef CompilationDir = " " ,
1043
1042
object::BuildIDRef *BinaryID = nullptr ) {
1044
1043
std::unique_ptr<ObjectFile> OF;
1045
1044
if (auto *Universal = dyn_cast<MachOUniversalBinary>(Bin.get ())) {
@@ -1068,7 +1067,12 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin,
1068
1067
1069
1068
// Look for the sections that we are interested in.
1070
1069
auto ObjFormat = OF->getTripleObjectFormat ();
1071
- InstrProfSymtab ProfileNames = ProfileReader.getSymtab ();
1070
+ // Without debug info correlation, all function names are stored in the
1071
+ // binary's profile name section.
1072
+ // When debug info correlation is enabled, instrumented function names are
1073
+ // stored in the indexed profile file, and unused function names are stored in
1074
+ // the binary's debug info.
1075
+ InstrProfSymtab ProfileNames = ProfSymTab;
1072
1076
auto NamesSection =
1073
1077
lookupSections (*OF, getInstrProfSectionName (IPSK_name, ObjFormat,
1074
1078
/* AddSegmentInfo=*/ false ));
@@ -1086,6 +1090,7 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin,
1086
1090
if (Error E = ProfileNames.create (NamesSectionRefs.back ()))
1087
1091
return std::move (E);
1088
1092
}
1093
+
1089
1094
auto CoverageSection =
1090
1095
lookupSections (*OF, getInstrProfSectionName (IPSK_covmap, ObjFormat,
1091
1096
/* AddSegmentInfo=*/ false ));
@@ -1169,10 +1174,10 @@ static bool isArchSpecifierInvalidOrMissing(Binary *Bin, StringRef Arch) {
1169
1174
1170
1175
Expected<std::vector<std::unique_ptr<BinaryCoverageReader>>>
1171
1176
BinaryCoverageReader::create (
1172
- MemoryBufferRef ObjectBuffer, IndexedInstrProfReader &ProfileReader,
1173
- StringRef Arch,
1177
+ MemoryBufferRef ObjectBuffer, StringRef Arch,
1174
1178
SmallVectorImpl<std::unique_ptr<MemoryBuffer>> &ObjectFileBuffers,
1175
- StringRef CompilationDir, SmallVectorImpl<object::BuildIDRef> *BinaryIDs) {
1179
+ InstrProfSymtab ProfSymTab, StringRef CompilationDir,
1180
+ SmallVectorImpl<object::BuildIDRef> *BinaryIDs) {
1176
1181
std::vector<std::unique_ptr<BinaryCoverageReader>> Readers;
1177
1182
1178
1183
if (ObjectBuffer.getBuffer ().size () > sizeof (TestingFormatMagic)) {
@@ -1216,8 +1221,8 @@ BinaryCoverageReader::create(
1216
1221
}
1217
1222
1218
1223
return BinaryCoverageReader::create (
1219
- ArchiveOrErr.get ()->getMemoryBufferRef (), ProfileReader, Arch,
1220
- ObjectFileBuffers, CompilationDir, BinaryIDs);
1224
+ ArchiveOrErr.get ()->getMemoryBufferRef (), Arch,
1225
+ ObjectFileBuffers, ProfSymTab, CompilationDir, BinaryIDs);
1221
1226
}
1222
1227
}
1223
1228
@@ -1230,7 +1235,7 @@ BinaryCoverageReader::create(
1230
1235
return ChildBufOrErr.takeError ();
1231
1236
1232
1237
auto ChildReadersOrErr = BinaryCoverageReader::create (
1233
- ChildBufOrErr.get (), ProfileReader, Arch, ObjectFileBuffers,
1238
+ ChildBufOrErr.get (), Arch, ObjectFileBuffers, ProfSymTab ,
1234
1239
CompilationDir, BinaryIDs);
1235
1240
if (!ChildReadersOrErr)
1236
1241
return ChildReadersOrErr.takeError ();
@@ -1252,7 +1257,7 @@ BinaryCoverageReader::create(
1252
1257
1253
1258
object::BuildIDRef BinaryID;
1254
1259
auto ReaderOrErr =
1255
- loadBinaryFormat (std::move (Bin), ProfileReader, Arch , CompilationDir,
1260
+ loadBinaryFormat (std::move (Bin), Arch, ProfSymTab , CompilationDir,
1256
1261
BinaryIDs ? &BinaryID : nullptr );
1257
1262
if (!ReaderOrErr)
1258
1263
return ReaderOrErr.takeError ();
0 commit comments