@@ -636,14 +636,15 @@ class InstrProfSymtab {
636
636
// Map the MD5 of the symbol name to the name.
637
637
Error addSymbolName (StringRef SymbolName) {
638
638
StringRef FuncName;
639
- StringRef ArchName = " " ;
640
- std::tie (FuncName, ArchName) = SymbolName.split (" : " );
639
+ StringRef ArchName = Architecture ;
640
+ std::tie (FuncName, ArchName) = SymbolName.split (" # " );
641
641
if (SymbolName.empty ())
642
642
return make_error<InstrProfError>(instrprof_error::malformed,
643
643
" symbol name is empty" );
644
644
645
645
// Insert into NameTab so that MD5NameMap (a vector that will be sorted)
646
646
// won't have duplicated entries in the first place.
647
+
647
648
uint64_t HashValue = IndexedInstrProf::ComputeHash (FuncName);
648
649
llvm::StringRef HashRef (FuncName);
649
650
if (!ArchName.empty ()){
@@ -652,14 +653,18 @@ class InstrProfSymtab {
652
653
HashRef = CombinedStr;
653
654
HashValue = IndexedInstrProf::ComputeHash (HashRef);
654
655
}
656
+ llvm::errs () << " FuncName is " << FuncName << " is written in " << ArchName << " \n " ;
655
657
printf (" Hash Value for %.*s %" PRIu64 " \n " , static_cast <int >(SymbolName.size ()), SymbolName.data (), HashValue);
656
658
auto Ins = NameTab.insert (FuncName);
657
659
printf (" mapped value for %" PRIu64 " hash: %.*s\n " , HashValue, static_cast <int >(Ins.first ->getKey ().size ()), Ins.first ->getKey ().data ());
658
660
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 ()));
661
662
Sorted = false ;
662
663
}
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
+ }
663
668
return Error::success ();
664
669
}
665
670
@@ -787,13 +792,19 @@ StringRef InstrProfSymtab::getFuncOrVarNameIfDefined(uint64_t MD5Hash) {
787
792
StringRef InstrProfSymtab::getFuncOrVarName (uint64_t MD5Hash) {
788
793
finalizeSymtab ();
789
794
std::string TempMD5HashStr = std::to_string (MD5Hash);
795
+ llvm::errs () << " Before: " << MD5Hash << " \n " ;
790
796
if (!Architecture.empty ()){
791
797
std::string CombinedHashStr = TempMD5HashStr + " :" + Architecture;
792
798
llvm::StringRef CombinedHashRef (CombinedHashStr);
793
799
MD5Hash = IndexedInstrProf::ComputeHash (CombinedHashRef);
794
800
}
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
+ }
795
806
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 " ;
797
808
if (Result != MD5NameMap.end () && Result->first == MD5Hash)
798
809
return Result->second ;
799
810
return StringRef ();
0 commit comments