Skip to content

Commit df08094

Browse files
resolve feedback
1 parent 6fe9b48 commit df08094

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

llvm/include/llvm/ProfileData/DataAccessProf.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ struct DataAccessProfRecord {
5252

5353
// Represents a data symbol. The semantic comes in two forms: a symbol index
5454
// for symbol name if `IsStringLiteral` is false, or the hash of a string
55-
// content if `IsStringLiteral` is true. Required.
55+
// content if `IsStringLiteral` is true. For most of the symbolizable static
56+
// data, the mangled symbol names remain stable relative to the source code
57+
// and therefore used to identify symbols across binary releases. String
58+
// literals have unstable name patterns like `.str.N[.llvm.hash]`, so we use
59+
// the content hash instead. This is a required field.
5660
uint64_t SymbolID;
5761

5862
// The access count of symbol. Required.

llvm/lib/ProfileData/DataAccessProf.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@ const DataAccessProfRecord *
3535
DataAccessProfData::getProfileRecord(const SymbolHandle SymbolID) const {
3636
auto Key = SymbolID;
3737
if (std::holds_alternative<StringRef>(SymbolID)) {
38-
StringRef Name = std::get<StringRef>(SymbolID);
39-
assert(!Name.empty() && "Empty symbol name");
40-
Key = InstrProfSymtab::getCanonicalName(Name);
38+
auto NameOrErr = getCanonicalName(std::get<StringRef>(SymbolID));
39+
// If name canonicalization fails, suppress the error inside.
40+
if (!NameOrErr) {
41+
assert(
42+
std::get<StringRef>(SymbolID).empty() &&
43+
"Name canonicalization only fails when stringified string is empty.");
44+
return nullptr;
45+
}
46+
Key = *NameOrErr;
4147
}
4248

4349
auto It = Records.find(Key);

0 commit comments

Comments
 (0)