Skip to content

Commit 451e0fd

Browse files
author
Andres Wearden
committed
fixed bug messing up coremark build, it was getting rehashed when hash was inserted into MD5NameMap
1 parent 1d6ae59 commit 451e0fd

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

llvm/include/llvm/ProfileData/InstrProf.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,15 @@ class InstrProfSymtab {
636636
// Map the MD5 of the symbol name to the name.
637637
Error addSymbolName(StringRef SymbolName) {
638638
StringRef FuncName;
639-
StringRef ArchName = "";
640-
std::tie(FuncName, ArchName) = SymbolName.split(":");
639+
StringRef ArchName = Architecture;
640+
std::tie(FuncName, ArchName) = SymbolName.split("#");
641641
if (SymbolName.empty())
642642
return make_error<InstrProfError>(instrprof_error::malformed,
643643
"symbol name is empty");
644644

645645
// Insert into NameTab so that MD5NameMap (a vector that will be sorted)
646646
// won't have duplicated entries in the first place.
647+
647648
uint64_t HashValue = IndexedInstrProf::ComputeHash(FuncName);
648649
llvm::StringRef HashRef(FuncName);
649650
if(!ArchName.empty()){
@@ -652,14 +653,18 @@ class InstrProfSymtab {
652653
HashRef = CombinedStr;
653654
HashValue = IndexedInstrProf::ComputeHash(HashRef);
654655
}
656+
llvm::errs() << "FuncName is " << FuncName << " is written in " << ArchName << "\n";
655657
printf("Hash Value for %.*s %" PRIu64 "\n", static_cast<int>(SymbolName.size()), SymbolName.data(), HashValue);
656658
auto Ins = NameTab.insert(FuncName);
657659
printf("mapped value for %" PRIu64 " hash: %.*s\n", HashValue, static_cast<int>(Ins.first->getKey().size()), Ins.first->getKey().data());
658660
if (Ins.second) {
659-
MD5NameMap.push_back(std::make_pair(
660-
IndexedInstrProf::ComputeHash(HashRef), Ins.first->getKey()));
661+
MD5NameMap.push_back(std::make_pair(HashValue /*IndexedInstrProf::ComputeHash(HashRef)*/, Ins.first->getKey()));
661662
Sorted = false;
662663
}
664+
llvm::errs() << "Hash values when inside of addSymbolName" << "\n";
665+
for(int I = 0; I < int(MD5NameMap.size()); ++I){
666+
llvm::errs() << "Hash: " << MD5NameMap[I].first << " Function Name: " << MD5NameMap[I].second << "\n";
667+
}
663668
return Error::success();
664669
}
665670

@@ -787,13 +792,19 @@ StringRef InstrProfSymtab::getFuncOrVarNameIfDefined(uint64_t MD5Hash) {
787792
StringRef InstrProfSymtab::getFuncOrVarName(uint64_t MD5Hash) {
788793
finalizeSymtab();
789794
std::string TempMD5HashStr = std::to_string(MD5Hash);
795+
llvm::errs() << "Before: " << MD5Hash << "\n";
790796
if(!Architecture.empty()){
791797
std::string CombinedHashStr = TempMD5HashStr + ":" + Architecture;
792798
llvm::StringRef CombinedHashRef(CombinedHashStr);
793799
MD5Hash = IndexedInstrProf::ComputeHash(CombinedHashRef);
794800
}
801+
llvm::errs() << "After: " << MD5Hash << "\n";
802+
llvm::errs() << "Hash values when inside of getFuncOrVarName" << "\n";
803+
for(int I = 0; I < int(MD5NameMap.size()); ++I){
804+
llvm::errs() << "Hash: " << MD5NameMap[I].first << " Function Name: " << MD5NameMap[I].second << "\n";
805+
}
795806
auto Result = llvm::lower_bound(MD5NameMap, MD5Hash, [](const std::pair<uint64_t, StringRef> &LHS, uint64_t RHS) { return LHS.first < RHS; });
796-
llvm::errs() << "Architecture: " << (!Architecture.empty() ? Architecture : "No Specified Architecture") << ": " << Result->second<< ": " << "Result->first: " << Result->first << " vs. MD5hash: " << MD5Hash << "\n";
807+
llvm::errs() << "Architecture: " << (!Architecture.empty() ? Architecture : "No Specified Architecture") << ": " << Result->second << ": " << "Result->first: " << Result->first << " vs. MD5hash: " << MD5Hash << "\n";
797808
if (Result != MD5NameMap.end() && Result->first == MD5Hash)
798809
return Result->second;
799810
return StringRef();

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Error readAndDecodeStrings(StringRef NameStrings,
615615
if (Error E = NameCallback(Name))
616616
return E;
617617
}else{
618-
if (Error E = NameCallback(Name.str() + ":" + ArchRef.str()))
618+
if (Error E = NameCallback(Name.str() + "#" + ArchRef.str()))
619619
return E;
620620
}
621621
}

0 commit comments

Comments
 (0)