@@ -369,9 +369,9 @@ LLVM_ABI bool needsComdatForCounter(const GlobalObject &GV, const Module &M);
369
369
// / InstrProf.h:getInstrProfNameSeparator). This method decodes the string and
370
370
// / calls `NameCallback` for each substring.
371
371
LLVM_ABI Error readAndDecodeStrings (
372
- StringRef NameStrings, std::function<Error(StringRef)> NameCallback);
372
+ StringRef NameStrings, std::function<Error(StringRef)> NameCallback, StringRef Architecture = "");
373
+
373
374
374
- LLVM_ABI Error readAndDecodeStrings (StringRef NameStrings, std::function<Error(StringRef)> NameCallback, const std::string &Architecture);
375
375
// / An enum describing the attributes of an instrumented profile.
376
376
enum class InstrProfKind {
377
377
Unknown = 0x0 ,
@@ -515,11 +515,11 @@ class InstrProfSymtab {
515
515
LLVM_ABI static StringRef getCanonicalName (StringRef PGOName);
516
516
517
517
// ANDRES Function
518
- const std::string & getArchitecture () {return Architecture;}
519
- void setArchitecture (const std::string & Arch) {Architecture = Arch;}
518
+ StringRef getArchitecture () {return Architecture;}
519
+ void setArchitecture (StringRef Arch) {Architecture = Arch;}
520
520
// ANDRES Function
521
521
private:
522
- std::string Architecture;
522
+ StringRef Architecture;
523
523
using AddrIntervalMap =
524
524
IntervalMap<uint64_t , uint64_t , 4 , IntervalMapHalfOpenInfo<uint64_t >>;
525
525
StringRef Data;
@@ -635,35 +635,30 @@ class InstrProfSymtab {
635
635
636
636
// Map the MD5 of the symbol name to the name.
637
637
Error addSymbolName (StringRef SymbolName) {
638
- StringRef FuncName;
639
- StringRef ArchName = Architecture;
640
- std::tie (FuncName, ArchName) = SymbolName.split (" #" );
638
+ // StringRef FuncName;
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 );
649
- llvm::StringRef HashRef (FuncName );
650
- if (!ArchName .empty ()){
648
+ uint64_t HashValue = IndexedInstrProf::ComputeHash (SymbolName );
649
+ llvm::StringRef HashRef (SymbolName );
650
+ if (!Architecture .empty ()){
651
651
std::string HashStr = std::to_string (HashValue);
652
- std::string CombinedStr = HashStr + " :" + ArchName .str ();
652
+ std::string CombinedStr = HashStr + " :" + Architecture .str ();
653
653
HashRef = CombinedStr;
654
654
HashValue = IndexedInstrProf::ComputeHash (HashRef);
655
655
}
656
- llvm::errs () << " FuncName is " << FuncName << " is written in " << ArchName << " \n " ;
657
- printf (" Hash Value for %.*s %" PRIu64 " \n " , static_cast <int >(SymbolName.size ()), SymbolName.data (), HashValue);
658
- auto Ins = NameTab.insert (FuncName);
659
- printf (" mapped value for %" PRIu64 " hash: %.*s\n " , HashValue, static_cast <int >(Ins.first ->getKey ().size ()), Ins.first ->getKey ().data ());
656
+ auto Ins = NameTab.insert (SymbolName);
660
657
if (Ins.second ) {
661
658
MD5NameMap.push_back (std::make_pair (HashValue /* IndexedInstrProf::ComputeHash(HashRef)*/ , Ins.first ->getKey ()));
662
659
Sorted = false ;
663
660
}
664
- llvm::errs () << " Hash values when inside of addSymbolName" << " \n " ;
665
661
for (int I = 0 ; I < int (MD5NameMap.size ()); ++I){
666
- llvm::errs () << " Hash: " << MD5NameMap[I].first << " Function Name: " << MD5NameMap[I].second << " \n " ;
667
662
}
668
663
return Error::success ();
669
664
}
@@ -792,19 +787,17 @@ StringRef InstrProfSymtab::getFuncOrVarNameIfDefined(uint64_t MD5Hash) {
792
787
StringRef InstrProfSymtab::getFuncOrVarName (uint64_t MD5Hash) {
793
788
finalizeSymtab ();
794
789
std::string TempMD5HashStr = std::to_string (MD5Hash);
795
- llvm::errs () << " Before: " << MD5Hash << " \n " ;
796
790
if (!Architecture.empty ()){
797
- std::string CombinedHashStr = TempMD5HashStr + " :" + Architecture;
791
+ std::string CombinedHashStr = TempMD5HashStr + " :" + Architecture. str () ;
798
792
llvm::StringRef CombinedHashRef (CombinedHashStr);
799
793
MD5Hash = IndexedInstrProf::ComputeHash (CombinedHashRef);
800
794
}
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
- }
806
795
auto Result = llvm::lower_bound (MD5NameMap, MD5Hash, [](const std::pair<uint64_t , StringRef> &LHS, uint64_t RHS) { return LHS.first < RHS; });
807
- llvm::errs () << " Architecture: " << (!Architecture.empty () ? Architecture : " No Specified Architecture" ) << " : " << Result->second << " : " << " Result->first: " << Result->first << " vs. MD5hash: " << MD5Hash << " \n " ;
796
+
797
+ // for(auto name : MD5NameMap){
798
+ // llvm::errs() << "Function Name " << name.second << " Result->first: " << name.first << "\n";
799
+ // }
800
+ // llvm::errs() << "Function Name " << Result->second << " Result->first: " << Result->first << " vs. " << MD5Hash << "\n";
808
801
if (Result != MD5NameMap.end () && Result->first == MD5Hash)
809
802
return Result->second ;
810
803
return StringRef ();
0 commit comments