aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorEugene Leviant <eleviant@accesssoftek.com>2019-07-05 15:25:05 +0000
committerEugene Leviant <eleviant@accesssoftek.com>2019-07-05 15:25:05 +0000
commit3aef35288b5387d3b1e8c1627df5c031b9c151c7 (patch)
treea234bcaa1bd15f5170446186728e3fdd89a69159 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent47afdaa4872e8617734e50bcc99bab149bfb08f8 (diff)
downloadllvm-3aef35288b5387d3b1e8c1627df5c031b9c151c7.zip
llvm-3aef35288b5387d3b1e8c1627df5c031b9c151c7.tar.gz
llvm-3aef35288b5387d3b1e8c1627df5c031b9c151c7.tar.bz2
[ThinLTO] Attempt to recommit r365188 after alignment fix
llvm-svn: 365215
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index affbe4c..a339f6e 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -984,7 +984,8 @@ static GlobalValueSummary::GVFlags getDecodedGVSummaryFlags(uint64_t RawFlags,
// Decode the flags for GlobalVariable in the summary
static GlobalVarSummary::GVarFlags getDecodedGVarFlags(uint64_t RawFlags) {
- return GlobalVarSummary::GVarFlags((RawFlags & 0x1) ? true : false);
+ return GlobalVarSummary::GVarFlags((RawFlags & 0x1) ? true : false,
+ (RawFlags & 0x2) ? true : false);
}
static GlobalValue::VisibilityTypes getDecodedVisibility(unsigned Val) {
@@ -5683,10 +5684,16 @@ void ModuleSummaryIndexBitcodeReader::parseTypeIdCompatibleVtableSummaryRecord(
parseTypeIdCompatibleVtableInfo(Record, Slot, TypeId);
}
-static void setImmutableRefs(std::vector<ValueInfo> &Refs, unsigned Count) {
- // Read-only refs are in the end of the refs list.
- for (unsigned RefNo = Refs.size() - Count; RefNo < Refs.size(); ++RefNo)
+static void setSpecialRefs(std::vector<ValueInfo> &Refs, unsigned ROCnt,
+ unsigned WOCnt) {
+ // Readonly and writeonly refs are in the end of the refs list.
+ assert(ROCnt + WOCnt <= Refs.size());
+ unsigned FirstWORef = Refs.size() - WOCnt;
+ unsigned RefNo = FirstWORef - ROCnt;
+ for (; RefNo < FirstWORef; ++RefNo)
Refs[RefNo].setReadOnly();
+ for (; RefNo < Refs.size(); ++RefNo)
+ Refs[RefNo].setWriteOnly();
}
// Eagerly parse the entire summary block. This populates the GlobalValueSummary
@@ -5713,9 +5720,9 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
}
const uint64_t Version = Record[0];
const bool IsOldProfileFormat = Version == 1;
- if (Version < 1 || Version > 6)
+ if (Version < 1 || Version > 7)
return error("Invalid summary version " + Twine(Version) +
- ". Version should be in the range [1-6].");
+ ". Version should be in the range [1-7].");
Record.clear();
// Keep around the last seen summary to be used when we see an optional
@@ -5814,15 +5821,19 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
unsigned InstCount = Record[2];
uint64_t RawFunFlags = 0;
unsigned NumRefs = Record[3];
- unsigned NumImmutableRefs = 0;
+ unsigned NumRORefs = 0, NumWORefs = 0;
int RefListStartIndex = 4;
if (Version >= 4) {
RawFunFlags = Record[3];
NumRefs = Record[4];
RefListStartIndex = 5;
if (Version >= 5) {
- NumImmutableRefs = Record[5];
+ NumRORefs = Record[5];
RefListStartIndex = 6;
+ if (Version >= 7) {
+ NumWORefs = Record[6];
+ RefListStartIndex = 7;
+ }
}
}
@@ -5842,7 +5853,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
std::vector<FunctionSummary::EdgeTy> Calls = makeCallList(
ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex),
IsOldProfileFormat, HasProfile, HasRelBF);
- setImmutableRefs(Refs, NumImmutableRefs);
+ setSpecialRefs(Refs, NumRORefs, NumWORefs);
auto FS = llvm::make_unique<FunctionSummary>(
Flags, InstCount, getDecodedFFlags(RawFunFlags), /*EntryCount=*/0,
std::move(Refs), std::move(Calls), std::move(PendingTypeTests),
@@ -5893,7 +5904,8 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
unsigned ValueID = Record[0];
uint64_t RawFlags = Record[1];
unsigned RefArrayStart = 2;
- GlobalVarSummary::GVarFlags GVF;
+ GlobalVarSummary::GVarFlags GVF(/* ReadOnly */ false,
+ /* WriteOnly */ false);
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
if (Version >= 5) {
GVF = getDecodedGVarFlags(Record[2]);
@@ -5950,7 +5962,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
uint64_t RawFunFlags = 0;
uint64_t EntryCount = 0;
unsigned NumRefs = Record[4];
- unsigned NumImmutableRefs = 0;
+ unsigned NumRORefs = 0, NumWORefs = 0;
int RefListStartIndex = 5;
if (Version >= 4) {
@@ -5958,13 +5970,19 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
RefListStartIndex = 6;
size_t NumRefsIndex = 5;
if (Version >= 5) {
+ unsigned NumRORefsOffset = 1;
RefListStartIndex = 7;
if (Version >= 6) {
NumRefsIndex = 6;
EntryCount = Record[5];
RefListStartIndex = 8;
+ if (Version >= 7) {
+ RefListStartIndex = 9;
+ NumWORefs = Record[8];
+ NumRORefsOffset = 2;
+ }
}
- NumImmutableRefs = Record[RefListStartIndex - 1];
+ NumRORefs = Record[RefListStartIndex - NumRORefsOffset];
}
NumRefs = Record[NumRefsIndex];
}
@@ -5980,7 +5998,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
ArrayRef<uint64_t>(Record).slice(CallGraphEdgeStartIndex),
IsOldProfileFormat, HasProfile, false);
ValueInfo VI = getValueInfoFromValueId(ValueID).first;
- setImmutableRefs(Refs, NumImmutableRefs);
+ setSpecialRefs(Refs, NumRORefs, NumWORefs);
auto FS = llvm::make_unique<FunctionSummary>(
Flags, InstCount, getDecodedFFlags(RawFunFlags), EntryCount,
std::move(Refs), std::move(Edges), std::move(PendingTypeTests),
@@ -6027,7 +6045,8 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
uint64_t ModuleId = Record[1];
uint64_t RawFlags = Record[2];
unsigned RefArrayStart = 3;
- GlobalVarSummary::GVarFlags GVF;
+ GlobalVarSummary::GVarFlags GVF(/* ReadOnly */ false,
+ /* WriteOnly */ false);
auto Flags = getDecodedGVSummaryFlags(RawFlags, Version);
if (Version >= 5) {
GVF = getDecodedGVarFlags(Record[3]);