llvm.org GIT mirror llvm / 020a5a4
remove bitcode reader support for LLVM 2.7 metadata encoding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133268 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
4 changed file(s) with 8 addition(s) and 63 deletion(s). Raw diff Collapse all Expand all
111111
112112 enum MetadataCodes {
113113 METADATA_STRING = 1, // MDSTRING: [values]
114 // FIXME: Remove NODE in favor of NODE2 in LLVM 3.0
115 METADATA_NODE = 2, // NODE with potentially invalid metadata
116 // FIXME: Remove FN_NODE in favor of FN_NODE2 in LLVM 3.0
117 METADATA_FN_NODE = 3, // FN_NODE with potentially invalid metadata
114 // 2 is unused.
115 // 3 is unused.
118116 METADATA_NAME = 4, // STRING: [values]
119 // FIXME: Remove NAMED_NODE in favor of NAMED_NODE2 in LLVM 3.0
120 METADATA_NAMED_NODE = 5, // NAMED_NODE with potentially invalid metadata
117 // 5 is unused.
121118 METADATA_KIND = 6, // [n x [id, name]]
122 // FIXME: Remove ATTACHMENT in favor of ATTACHMENT2 in LLVM 3.0
123 METADATA_ATTACHMENT = 7, // ATTACHMENT with potentially invalid metadata
119 // 7 is unused.
124120 METADATA_NODE2 = 8, // NODE2: [n x (type num, value num)]
125121 METADATA_FN_NODE2 = 9, // FN_NODE2: [n x (type num, value num)]
126122 METADATA_NAMED_NODE2 = 10, // NAMED_NODE2: [n x mdnodes]
790790 Code = Stream.ReadCode();
791791
792792 // METADATA_NAME is always followed by METADATA_NAMED_NODE2.
793 // Or METADATA_NAMED_NODE in LLVM 2.7. FIXME: Remove this in LLVM 3.0.
794793 unsigned NextBitCode = Stream.ReadRecord(Code, Record);
795 if (NextBitCode == bitc::METADATA_NAMED_NODE) {
796 LLVM2_7MetadataDetected = true;
797 } else if (NextBitCode != bitc::METADATA_NAMED_NODE2)
798 assert ( 0 && "Invalid Named Metadata record");
794 assert(NextBitCode == bitc::METADATA_NAMED_NODE2); (void)NextBitCode;
799795
800796 // Read named metadata elements.
801797 unsigned Size = Record.size();
806802 return Error("Malformed metadata record");
807803 NMD->addOperand(MD);
808804 }
809 // Backwards compatibility hack: NamedMDValues used to be Values,
810 // and they got their own slots in the value numbering. They are no
811 // longer Values, however we still need to account for them in the
812 // numbering in order to be able to read old bitcode files.
813 // FIXME: Remove this in LLVM 3.0.
814 if (LLVM2_7MetadataDetected)
815 MDValueList.AssignValue(0, NextMDValueNo++);
816 break;
817 }
818 case bitc::METADATA_FN_NODE: // FIXME: Remove in LLVM 3.0.
805 break;
806 }
819807 case bitc::METADATA_FN_NODE2:
820808 IsFunctionLocal = true;
821809 // fall-through
822 case bitc::METADATA_NODE: // FIXME: Remove in LLVM 3.0.
823810 case bitc::METADATA_NODE2: {
824
825 // Detect 2.7-era metadata.
826 // FIXME: Remove in LLVM 3.0.
827 if (Code == bitc::METADATA_FN_NODE || Code == bitc::METADATA_NODE)
828 LLVM2_7MetadataDetected = true;
829
830811 if (Record.size() % 2 == 1)
831812 return Error("Invalid METADATA_NODE2 record");
832813
17541735 switch (Stream.ReadRecord(Code, Record)) {
17551736 default: // Default behavior: ignore.
17561737 break;
1757 // FIXME: Remove in LLVM 3.0.
1758 case bitc::METADATA_ATTACHMENT:
1759 LLVM2_7MetadataDetected = true;
17601738 case bitc::METADATA_ATTACHMENT2: {
17611739 unsigned RecordLength = Record.size();
17621740 if (Record.empty() || (RecordLength - 1) % 2 == 1)
18691847 I = 0;
18701848 continue;
18711849
1872 // FIXME: Remove this in LLVM 3.0.
1873 case bitc::FUNC_CODE_DEBUG_LOC:
1874 LLVM2_7MetadataDetected = true;
18751850 case bitc::FUNC_CODE_DEBUG_LOC2: { // DEBUG_LOC: [line, col, scope, ia]
18761851 I = 0; // Get the last instruction emitted.
18771852 if (CurBB && !CurBB->empty())
23922367 }
23932368 // FIXME: Remove this in LLVM 3.0.
23942369 case bitc::FUNC_CODE_INST_CALL:
2395 LLVM2_7MetadataDetected = true;
23962370 case bitc::FUNC_CODE_INST_CALL2: {
23972371 // CALL: [paramattrs, cc, fnty, fnid, arg0, arg1...]
23982372 if (Record.size() < 3)
25122486 BlockAddrFwdRefs.erase(BAFRI);
25132487 }
25142488
2515 // FIXME: Remove this in LLVM 3.0.
2516 unsigned NewMDValueListSize = MDValueList.size();
2517
25182489 // Trim the value list down to the size it was before we parsed this function.
25192490 ValueList.shrinkTo(ModuleValueListSize);
25202491 MDValueList.shrinkTo(ModuleMDValueListSize);
2521
2522 // Backwards compatibility hack: Function-local metadata numbers
2523 // were previously not reset between functions. This is now fixed,
2524 // however we still need to understand the old numbering in order
2525 // to be able to read old bitcode files.
2526 // FIXME: Remove this in LLVM 3.0.
2527 if (LLVM2_7MetadataDetected)
2528 MDValueList.resize(NewMDValueListSize);
2529
25302492 std::vector().swap(FunctionBBs);
2531
25322493 return false;
25332494 }
25342495
173173 typedef std::pair BlockAddrRefTy;
174174 DenseMap > BlockAddrFwdRefs;
175175
176 /// LLVM2_7MetadataDetected - True if metadata produced by LLVM 2.7 or
177 /// earlier was detected, in which case we behave slightly differently,
178 /// for compatibility.
179 /// FIXME: Remove in LLVM 3.0.
180 bool LLVM2_7MetadataDetected;
181
182176 public:
183177 explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C)
184178 : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false),
185 ErrorString(0), ValueList(C), MDValueList(C),
186 LLVM2_7MetadataDetected(false) {
179 ErrorString(0), ValueList(C), MDValueList(C) {
187180 HasReversedFunctionsWithBodies = false;
188181 }
189182 ~BitcodeReader() {
261261 case bitc::METADATA_ATTACHMENT_ID:
262262 switch(CodeID) {
263263 default:return 0;
264 case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT";
265264 case bitc::METADATA_ATTACHMENT2: return "METADATA_ATTACHMENT2";
266265 }
267266 case bitc::METADATA_BLOCK_ID:
268267 switch(CodeID) {
269268 default:return 0;
270269 case bitc::METADATA_STRING: return "METADATA_STRING";
271 case bitc::METADATA_NODE: return "METADATA_NODE";
272 case bitc::METADATA_FN_NODE: return "METADATA_FN_NODE";
273270 case bitc::METADATA_NAME: return "METADATA_NAME";
274 case bitc::METADATA_NAMED_NODE: return "METADATA_NAMED_NODE";
275271 case bitc::METADATA_KIND: return "METADATA_KIND";
276 case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT";
277272 case bitc::METADATA_NODE2: return "METADATA_NODE2";
278273 case bitc::METADATA_FN_NODE2: return "METADATA_FN_NODE2";
279274 case bitc::METADATA_NAMED_NODE2: return "METADATA_NAMED_NODE2";