summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp15
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp8
2 files changed, 15 insertions, 8 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 33f1a7e454e..d45360f0049 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -6097,13 +6097,18 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseModule() {
return error("Invalid record");
break;
case bitc::GLOBALVAL_SUMMARY_BLOCK_ID:
- assert(VSTOffset > 0 && "Expected non-zero VST offset");
assert(!SeenValueSymbolTable &&
"Already read VST when parsing summary block?");
- if (std::error_code EC =
- parseValueSymbolTable(VSTOffset, ValueIdToLinkageMap))
- return EC;
- SeenValueSymbolTable = true;
+ // We might not have a VST if there were no values in the
+ // summary. An empty summary block generated when we are
+ // performing ThinLTO compiles so we don't later invoke
+ // the regular LTO process on them.
+ if (VSTOffset > 0) {
+ if (std::error_code EC =
+ parseValueSymbolTable(VSTOffset, ValueIdToLinkageMap))
+ return EC;
+ SeenValueSymbolTable = true;
+ }
SeenGlobalValSummary = true;
if (std::error_code EC = parseEntireSummary())
return EC;
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index df700a8aba1..a353edf7aec 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -3341,13 +3341,15 @@ static const uint64_t INDEX_VERSION = 1;
/// Emit the per-module summary section alongside the rest of
/// the module's bitcode.
void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
- if (Index->begin() == Index->end())
- return;
-
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 4);
Stream.EmitRecord(bitc::FS_VERSION, ArrayRef<uint64_t>{INDEX_VERSION});
+ if (Index->begin() == Index->end()) {
+ Stream.ExitBlock();
+ return;
+ }
+
// Abbrev for FS_PERMODULE.
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE));
OpenPOWER on IntegriCloud