This revision was automatically updated to reflect the committed changes.
Closed by commit rL325182: [ThinLTO/CFI] Include TYPE_ID summaries into
GLOBALVAL_SUMMARY_BLOCK (authored by vitalybuka, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D42611?vs=134317&id=134321#toc
Repository:
rC Clang
https://reviews.llvm.org/D42611
Files:
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
cfe/trunk/test/CodeGen/thinlto-distributed.ll
llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Index: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
===
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
@@ -671,7 +671,6 @@
/// Mapping from type identifiers to summary information for that type
/// identifier.
- // FIXME: Add bitcode read/write support for this field.
std::map TypeIdMap;
/// Mapping from original ID to GUID. If original ID can map to multiple
Index: llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
===
--- llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
+++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
@@ -263,6 +263,11 @@
FS_PERMODULE_RELBF = 19,
// Index-wide flags
FS_FLAGS = 20,
+ // Maps type identifier to summary information for that type identifier.
+ // TYPE_ID: [typeid, kind, bitwidth, align, size, bitmask, inlinebits,
+ // n x (typeid, kind, name, numrba,
+ //numrba x (numarg, numarg x arg, kind, info, byte, bit))]
+ FS_TYPE_ID = 21,
};
enum MetadataCodes {
Index: llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
===
--- llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
+++ llvm/trunk/test/ThinLTO/X86/cfi-icall.ll
@@ -22,8 +22,9 @@
; COMBINED:
; COMBINED:
+; COMBINED:
; COMBINED:
; COMBINED: blob data = 'foobar'
+; COMBINED-NEXT:blob data = 'foobartypeid1'
; COMBINED-NEXT:
Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5071,6 +5071,56 @@
return Ret;
}
+static void
+parseWholeProgramDevirtResolutionByArg(ArrayRef Record, size_t &Slot,
+ WholeProgramDevirtResolution &Wpd) {
+ uint64_t ArgNum = Record[Slot++];
+ WholeProgramDevirtResolution::ByArg &B =
+ Wpd.ResByArg[{Record.begin() + Slot, Record.begin() + Slot + ArgNum}];
+ Slot += ArgNum;
+
+ B.TheKind =
+ static_cast(Record[Slot++]);
+ B.Info = Record[Slot++];
+ B.Byte = Record[Slot++];
+ B.Bit = Record[Slot++];
+}
+
+static void parseWholeProgramDevirtResolution(ArrayRef Record,
+ StringRef Strtab, size_t &Slot,
+ TypeIdSummary &TypeId) {
+ uint64_t Id = Record[Slot++];
+ WholeProgramDevirtResolution &Wpd = TypeId.WPDRes[Id];
+
+ Wpd.TheKind = static_cast(Record[Slot++]);
+ Wpd.SingleImplName = {Strtab.data() + Record[Slot],
+static_cast(Record[Slot + 1])};
+ Slot += 2;
+
+ uint64_t ResByArgNum = Record[Slot++];
+ for (uint64_t I = 0; I != ResByArgNum; ++I)
+parseWholeProgramDevirtResolutionByArg(Record, Slot, Wpd);
+}
+
+static void parseTypeIdSummaryRecord(ArrayRef Record,
+ StringRef Strtab,
+ ModuleSummaryIndex &TheIndex) {
+ size_t Slot = 0;
+ TypeIdSummary &TypeId = TheIndex.getOrInsertTypeIdSummary(
+ {Strtab.data() + Record[Slot], static_cast(Record[Slot + 1])});
+ Slot += 2;
+
+ TypeId.TTRes.TheKind = static_cast(Record[Slot++]);
+ TypeId.TTRes.SizeM1BitWidth = Record[Slot++];
+ TypeId.TTRes.AlignLog2 = Record[Slot++];
+ TypeId.TTRes.SizeM1 = Record[Slot++];
+ TypeId.TTRes.BitMask = Record[Slot++];
+ TypeId.TTRes.InlineBits = Record[Slot++];
+
+ while (Slot < Record.size())
+parseWholeProgramDevirtResolution(Record, Strtab, Slot, TypeId);
+}
+
// Eagerly parse the entire summary block. This populates the GlobalValueSummary
// objects in the index.
Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
@@ -5388,13 +5438,18 @@
{Strtab.data() + Record[I], static_cast(Record[I + 1])});
break;
}
+
case bitc::FS_CFI_FUNCTION_DECLS: {
std::set &CfiFunctionDecls = TheIndex.cfiFunctionDecls();
for (unsigned I = 0; I != Record.size(); I += 2)
CfiFuncti