llvm.org GIT mirror llvm / 3f53abc
Add a version field in the bitcode for the summary Differential Revision: http://reviews.llvm.org/D19456 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267318 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
11 changed file(s) with 46 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
218218 FS_COMBINED_ALIAS = 8,
219219 // COMBINED_ORIGINAL_NAME: [original_name_hash]
220220 FS_COMBINED_ORIGINAL_NAME = 9,
221 // VERSION of the summary, bumped when adding flags for instance.
222 FS_VERSION = 10,
221223 };
222224
223225 enum MetadataCodes {
59945994 std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
59955995 if (Stream.EnterSubBlock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID))
59965996 return error("Invalid record");
5997
59985997 SmallVector Record;
5998
5999 // Parse version
6000 {
6001 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
6002 if (Entry.Kind != BitstreamEntry::Record)
6003 return error("Invalid Summary Block: record for version expected");
6004 if (Stream.readRecord(Entry.ID, Record) != bitc::FS_VERSION)
6005 return error("Invalid Summary Block: version expected");
6006 }
6007 const uint64_t Version = Record[0];
6008 if (Version != 1)
6009 return error("Invalid summary version " + Twine(Version) + ", 1 expected");
6010 Record.clear();
6011
59996012 // Keep around the last seen summary to be used when we see an optional
60006013 // "OriginalName" attachement.
60016014 GlobalValueSummary *LastSeenSummary = nullptr;
30663066 NameVals.clear();
30673067 }
30683068
3069 // Current version for the summary.
3070 // This is bumped whenever we introduce changes in the way some record are
3071 // interpreted, like flags for instance.
3072 static const uint64_t INDEX_VERSION = 1;
3073
30693074 /// Emit the per-module summary section alongside the rest of
30703075 /// the module's bitcode.
30713076 void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
30763081 return;
30773082
30783083 Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
3084
3085 Stream.EmitRecord(bitc::FS_VERSION, ArrayRef{INDEX_VERSION});
30793086
30803087 // Abbrev for FS_PERMODULE.
30813088 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
31613168 /// Emit the combined summary section into the combined index file.
31623169 void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
31633170 Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
3171 Stream.EmitRecord(bitc::FS_VERSION, ArrayRef{INDEX_VERSION});
31643172
31653173 // Abbrev for FS_COMBINED.
31663174 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
0 ; Check summary versioning
1 ; RUN: opt -module-summary %s -o - | llvm-bcanalyzer -dump | FileCheck %s
2
3 ; CHECK:
4 ; CHECK:
5
6
7
8 ; Need a function for the summary to be populated.
9 define void @foo() {
10 ret void
11 }
55 ; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
66
77 ; CHECK:
8 ; CHECK-NEXT:
89 ; See if the call to func is registered, using the expected callsite count
910 ; and value id matching the subsequent value symbol table.
1011 ; CHECK-NEXT:
1617 ; CHECK-NEXT:
1718
1819 ; COMBINED:
20 ; COMBINED-NEXT:
1921 ; See if the call to analias is registered, using the expected callsite count
2022 ; and value id matching the subsequent value symbol table.
2123 ; COMBINED-NEXT:
55 ; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
66
77 ; CHECK:
8 ; CHECK-NEXT:
89 ; See if the call to func is registered, using the expected callsite count
910 ; and profile count, with value id matching the subsequent value symbol table.
1011 ; CHECK-NEXT:
1617 ; CHECK-NEXT:
1718
1819 ; COMBINED:
20 ; COMBINED-NEXT:
1921 ; COMBINED-NEXT:
2022 ; See if the call to func is registered, using the expected callsite count
2123 ; and profile count, with value id matching the subsequent value symbol table.
55 ; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
66
77 ; CHECK:
8 ; CHECK-NEXT:
89 ; See if the call to func is registered, using the expected callsite count
910 ; and value id matching the subsequent value symbol table.
1011 ; CHECK-NEXT:
1617 ; CHECK-NEXT:
1718
1819 ; COMBINED:
20 ; COMBINED-NEXT:
1921 ; COMBINED-NEXT:
2022 ; See if the call to func is registered, using the expected callsite count
2123 ; and value id matching the subsequent value symbol table.
33 ; RUN: llvm-bcanalyzer -dump %t.index.bc | FileCheck %s --check-prefix=COMBINED
44
55 ; COMBINED:
6 ; COMBINED-NEXT:
67 ; COMBINED-DAG:
78 ; COMBINED-DAG:
89 ; COMBINED-DAG:
44 ; same in the ValueSumbolTable, to ensure the ordering is stable.
55 ; Also check the linkage field on the summary entries.
66 ; BC:
7 ; BC-NEXT:
78 ; BC-NEXT:
89 ; BC-NEXT:
910 ; BC-NEXT:
99 ; COMBINED-NEXT:
1010 ; COMBINED-NEXT:
1111 ; COMBINED-NEXT:
12 ; COMBINED-NEXT:
1213 ; COMBINED-NEXT:
1314 ; COMBINED-NEXT:
1415 ; COMBINED-NEXT:
308308 STRINGIFY_CODE(FS, ALIAS)
309309 STRINGIFY_CODE(FS, COMBINED_ALIAS)
310310 STRINGIFY_CODE(FS, COMBINED_ORIGINAL_NAME)
311 STRINGIFY_CODE(FS, VERSION)
311312 }
312313 case bitc::METADATA_ATTACHMENT_ID:
313314 switch(CodeID) {