File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,11 @@ struct DataAccessProfRecord {
52
52
53
53
// Represents a data symbol. The semantic comes in two forms: a symbol index
54
54
// 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.
56
60
uint64_t SymbolID;
57
61
58
62
// The access count of symbol. Required.
Original file line number Diff line number Diff line change @@ -35,9 +35,15 @@ const DataAccessProfRecord *
35
35
DataAccessProfData::getProfileRecord (const SymbolHandle SymbolID) const {
36
36
auto Key = SymbolID;
37
37
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;
41
47
}
42
48
43
49
auto It = Records.find (Key);
You can’t perform that action at this time.
0 commit comments