Skip to content

Commit 7e74608

Browse files
author
Andres Wearden
committed
saving updates
1 parent b88e0bc commit 7e74608

File tree

3 files changed

+98
-7
lines changed

3 files changed

+98
-7
lines changed

code_changes.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
2+
index a786aadce6de..eeea25e25fe8 100644
3+
--- a/llvm/include/llvm/ProfileData/InstrProf.h
4+
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
5+
@@ -40,6 +40,7 @@
6+
#include <cassert>
7+
#include <cstddef>
8+
#include <cstdint>
9+
+#include <cstdio>
10+
#include <cstring>
11+
#include <list>
12+
#include <memory>
13+
@@ -643,7 +644,10 @@ public:
14+
15+
// Insert into NameTab so that MD5NameMap (a vector that will be sorted)
16+
// won't have duplicated entries in the first place.
17+
- auto Ins = NameTab.insert(SymbolName);
18+
+ uint64_t HashValue = IndexedInstrProf::ComputeHash(SymbolName);
19+
+ printf("Hash Value for %.*s: %" PRIu64 "\n", static_cast<int>(SymbolName.size()), SymbolName.data(), HashValue);
20+
+ auto Ins = NameTab.insert(FuncName);
21+
+ printf("mapped value for %" PRIu64 " hash: %.*s\n", HashValue, static_cast<int>(Ins.first->getKey().size()), Ins.first->getKey().data());
22+
if (Ins.second) {
23+
MD5NameMap.push_back(std::make_pair(
24+
IndexedInstrProf::ComputeHash(SymbolName), Ins.first->getKey()));
25+
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
26+
index b92253a81502..7bd1bed6b74f 100644
27+
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
28+
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
29+
@@ -356,7 +356,8 @@ private:
30+
uint64_t CountersDelta;
31+
uint64_t BitmapDelta;
32+
uint64_t NamesDelta;
33+
- const RawInstrProf::ProfileData<IntPtrT> *Data;
34+
+ const RawInstrProf::ProfileData<IntPtrT> *cccccbveifehbfkeciugkvlcugkcgbdhkkkvdtrfbgkn
35+
+ Data;
36+
const RawInstrProf::ProfileData<IntPtrT> *DataEnd;
37+
const RawInstrProf::VTableProfileData<IntPtrT> *VTableBegin = nullptr;
38+
const RawInstrProf::VTableProfileData<IntPtrT> *VTableEnd = nullptr;
39+
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
40+
index 16d4877f3ccc..ea9e0ea2e129 100644
41+
--- a/llvm/lib/ProfileData/InstrProf.cpp
42+
+++ b/llvm/lib/ProfileData/InstrProf.cpp
43+
@@ -555,7 +555,6 @@ Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
44+
auto NameToGUIDMap = [&](StringRef Name) -> Error {
45+
if (Error E = addSymbolName(Name))
46+
return E;
47+
-
48+
bool Inserted = true;
49+
std::tie(std::ignore, Inserted) = MD5VTableMap.try_emplace(
50+
GlobalValue::getGUIDAssumingExternalLinkage(Name), &VTable);
51+
@@ -607,10 +606,18 @@ Error readAndDecodeStrings(StringRef NameStrings,
52+
SmallVector<StringRef, 0> Names;
53+
StringRef ArchRef(Architecture);
54+
NameStrings.split(Names, getInstrProfNameSeparator());
55+
- for (StringRef &Name : Names)
56+
- if (Error E = NameCallback(Name.str()+ ":" + ArchRef.str()))
57+
- return E;
58+
-
59+
+ printf("=====================READER DATA====================");
60+
+ for (StringRef &Name : Names){
61+
+ std::string ConcHashString = Name.str() + ":" + ArchRef.str();
62+
+ printf("The string %s will get hashed and mapped to %s\n", ConcHashString.c_str(), Name.str().c_str());
63+
+ if(ArchRef.empty()){
64+
+ if (Error E = NameCallback(Name))
65+
+ return E;
66+
+ }else{
67+
+ if (Error E = NameCallback(Name.str() + ":" + ArchRef.str()))
68+
+ return E;
69+
+ }
70+
+ }
71+
while (P < EndP && *P == 0)
72+
P++;
73+
}
74+
@@ -653,7 +660,6 @@ Error readAndDecodeStrings(StringRef NameStrings,
75+
for (StringRef &Name : Names)
76+
if (Error E = NameCallback(Name))
77+
return E;
78+
-
79+
while (P < EndP && *P == 0)
80+
P++;
81+
}

llvm/include/llvm/ProfileData/InstrProf.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <cassert>
4141
#include <cstddef>
4242
#include <cstdint>
43+
#include <cstdio>
4344
#include <cstring>
4445
#include <list>
4546
#include <memory>
@@ -643,7 +644,10 @@ class InstrProfSymtab {
643644

644645
// Insert into NameTab so that MD5NameMap (a vector that will be sorted)
645646
// won't have duplicated entries in the first place.
646-
auto Ins = NameTab.insert(SymbolName);
647+
uint64_t HashValue = IndexedInstrProf::ComputeHash(SymbolName);
648+
printf("Hash Value for %.*s: %" PRIu64 "\n", static_cast<int>(SymbolName.size()), SymbolName.data(), HashValue);
649+
auto Ins = NameTab.insert(FuncName);
650+
printf("mapped value for %" PRIu64 " hash: %.*s\n", HashValue, static_cast<int>(Ins.first->getKey().size()), Ins.first->getKey().data());
647651
if (Ins.second) {
648652
MD5NameMap.push_back(std::make_pair(
649653
IndexedInstrProf::ComputeHash(SymbolName), Ins.first->getKey()));

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
555555
auto NameToGUIDMap = [&](StringRef Name) -> Error {
556556
if (Error E = addSymbolName(Name))
557557
return E;
558-
559558
bool Inserted = true;
560559
std::tie(std::ignore, Inserted) = MD5VTableMap.try_emplace(
561560
GlobalValue::getGUIDAssumingExternalLinkage(Name), &VTable);
@@ -607,10 +606,18 @@ Error readAndDecodeStrings(StringRef NameStrings,
607606
SmallVector<StringRef, 0> Names;
608607
StringRef ArchRef(Architecture);
609608
NameStrings.split(Names, getInstrProfNameSeparator());
610-
for (StringRef &Name : Names)
611-
if (Error E = NameCallback(Name.str()+ ":" + ArchRef.str()))
612-
return E;
613-
609+
printf("=====================READER DATA====================");
610+
for (StringRef &Name : Names){
611+
std::string ConcHashString = Name.str() + ":" + ArchRef.str();
612+
printf("The string %s will get hashed and mapped to %s\n", ConcHashString.c_str(), Name.str().c_str());
613+
if(ArchRef.empty()){
614+
if (Error E = NameCallback(Name))
615+
return E;
616+
}else{
617+
if (Error E = NameCallback(Name.str() + ":" + ArchRef.str()))
618+
return E;
619+
}
620+
}
614621
while (P < EndP && *P == 0)
615622
P++;
616623
}
@@ -653,7 +660,6 @@ Error readAndDecodeStrings(StringRef NameStrings,
653660
for (StringRef &Name : Names)
654661
if (Error E = NameCallback(Name))
655662
return E;
656-
657663
while (P < EndP && *P == 0)
658664
P++;
659665
}

0 commit comments

Comments
 (0)