From: Chris Lattner Date: Fri, 17 Jun 2011 17:48:53 +0000 (+0000) Subject: remove bitcode reader support for LLVM 2.7 metadata encoding. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=020a5a449f297ced1f0fed08fb81c5da87fb7c9a;p=oota-llvm.git 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 --- diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 7692bd28720..6ff2cc45666 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -112,16 +112,12 @@ namespace bitc { enum MetadataCodes { METADATA_STRING = 1, // MDSTRING: [values] - // FIXME: Remove NODE in favor of NODE2 in LLVM 3.0 - METADATA_NODE = 2, // NODE with potentially invalid metadata - // FIXME: Remove FN_NODE in favor of FN_NODE2 in LLVM 3.0 - METADATA_FN_NODE = 3, // FN_NODE with potentially invalid metadata + // 2 is unused. + // 3 is unused. METADATA_NAME = 4, // STRING: [values] - // FIXME: Remove NAMED_NODE in favor of NAMED_NODE2 in LLVM 3.0 - METADATA_NAMED_NODE = 5, // NAMED_NODE with potentially invalid metadata + // 5 is unused. METADATA_KIND = 6, // [n x [id, name]] - // FIXME: Remove ATTACHMENT in favor of ATTACHMENT2 in LLVM 3.0 - METADATA_ATTACHMENT = 7, // ATTACHMENT with potentially invalid metadata + // 7 is unused. METADATA_NODE2 = 8, // NODE2: [n x (type num, value num)] METADATA_FN_NODE2 = 9, // FN_NODE2: [n x (type num, value num)] METADATA_NAMED_NODE2 = 10, // NAMED_NODE2: [n x mdnodes] diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index bc995aec83e..cbb0ac7b375 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -791,12 +791,8 @@ bool BitcodeReader::ParseMetadata() { Code = Stream.ReadCode(); // METADATA_NAME is always followed by METADATA_NAMED_NODE2. - // Or METADATA_NAMED_NODE in LLVM 2.7. FIXME: Remove this in LLVM 3.0. unsigned NextBitCode = Stream.ReadRecord(Code, Record); - if (NextBitCode == bitc::METADATA_NAMED_NODE) { - LLVM2_7MetadataDetected = true; - } else if (NextBitCode != bitc::METADATA_NAMED_NODE2) - assert ( 0 && "Invalid Named Metadata record"); + assert(NextBitCode == bitc::METADATA_NAMED_NODE2); (void)NextBitCode; // Read named metadata elements. unsigned Size = Record.size(); @@ -807,27 +803,12 @@ bool BitcodeReader::ParseMetadata() { return Error("Malformed metadata record"); NMD->addOperand(MD); } - // Backwards compatibility hack: NamedMDValues used to be Values, - // and they got their own slots in the value numbering. They are no - // longer Values, however we still need to account for them in the - // numbering in order to be able to read old bitcode files. - // FIXME: Remove this in LLVM 3.0. - if (LLVM2_7MetadataDetected) - MDValueList.AssignValue(0, NextMDValueNo++); break; } - case bitc::METADATA_FN_NODE: // FIXME: Remove in LLVM 3.0. case bitc::METADATA_FN_NODE2: IsFunctionLocal = true; // fall-through - case bitc::METADATA_NODE: // FIXME: Remove in LLVM 3.0. case bitc::METADATA_NODE2: { - - // Detect 2.7-era metadata. - // FIXME: Remove in LLVM 3.0. - if (Code == bitc::METADATA_FN_NODE || Code == bitc::METADATA_NODE) - LLVM2_7MetadataDetected = true; - if (Record.size() % 2 == 1) return Error("Invalid METADATA_NODE2 record"); @@ -1755,9 +1736,6 @@ bool BitcodeReader::ParseMetadataAttachment() { switch (Stream.ReadRecord(Code, Record)) { default: // Default behavior: ignore. break; - // FIXME: Remove in LLVM 3.0. - case bitc::METADATA_ATTACHMENT: - LLVM2_7MetadataDetected = true; case bitc::METADATA_ATTACHMENT2: { unsigned RecordLength = Record.size(); if (Record.empty() || (RecordLength - 1) % 2 == 1) @@ -1870,9 +1848,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { I = 0; continue; - // FIXME: Remove this in LLVM 3.0. - case bitc::FUNC_CODE_DEBUG_LOC: - LLVM2_7MetadataDetected = true; case bitc::FUNC_CODE_DEBUG_LOC2: { // DEBUG_LOC: [line, col, scope, ia] I = 0; // Get the last instruction emitted. if (CurBB && !CurBB->empty()) @@ -2393,7 +2368,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { } // FIXME: Remove this in LLVM 3.0. case bitc::FUNC_CODE_INST_CALL: - LLVM2_7MetadataDetected = true; case bitc::FUNC_CODE_INST_CALL2: { // CALL: [paramattrs, cc, fnty, fnid, arg0, arg1...] if (Record.size() < 3) @@ -2513,23 +2487,10 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { BlockAddrFwdRefs.erase(BAFRI); } - // FIXME: Remove this in LLVM 3.0. - unsigned NewMDValueListSize = MDValueList.size(); - // Trim the value list down to the size it was before we parsed this function. ValueList.shrinkTo(ModuleValueListSize); MDValueList.shrinkTo(ModuleMDValueListSize); - - // Backwards compatibility hack: Function-local metadata numbers - // were previously not reset between functions. This is now fixed, - // however we still need to understand the old numbering in order - // to be able to read old bitcode files. - // FIXME: Remove this in LLVM 3.0. - if (LLVM2_7MetadataDetected) - MDValueList.resize(NewMDValueListSize); - std::vector().swap(FunctionBBs); - return false; } diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h index f8fc079c73d..9bab00e4527 100644 --- a/lib/Bitcode/Reader/BitcodeReader.h +++ b/lib/Bitcode/Reader/BitcodeReader.h @@ -174,17 +174,10 @@ class BitcodeReader : public GVMaterializer { typedef std::pair BlockAddrRefTy; DenseMap > BlockAddrFwdRefs; - /// LLVM2_7MetadataDetected - True if metadata produced by LLVM 2.7 or - /// earlier was detected, in which case we behave slightly differently, - /// for compatibility. - /// FIXME: Remove in LLVM 3.0. - bool LLVM2_7MetadataDetected; - public: explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C) : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false), - ErrorString(0), ValueList(C), MDValueList(C), - LLVM2_7MetadataDetected(false) { + ErrorString(0), ValueList(C), MDValueList(C) { HasReversedFunctionsWithBodies = false; } ~BitcodeReader() { diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 9a92671b137..5ac42127297 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -262,19 +262,14 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, case bitc::METADATA_ATTACHMENT_ID: switch(CodeID) { default:return 0; - case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT"; case bitc::METADATA_ATTACHMENT2: return "METADATA_ATTACHMENT2"; } case bitc::METADATA_BLOCK_ID: switch(CodeID) { default:return 0; case bitc::METADATA_STRING: return "METADATA_STRING"; - case bitc::METADATA_NODE: return "METADATA_NODE"; - case bitc::METADATA_FN_NODE: return "METADATA_FN_NODE"; case bitc::METADATA_NAME: return "METADATA_NAME"; - case bitc::METADATA_NAMED_NODE: return "METADATA_NAMED_NODE"; case bitc::METADATA_KIND: return "METADATA_KIND"; - case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT"; case bitc::METADATA_NODE2: return "METADATA_NODE2"; case bitc::METADATA_FN_NODE2: return "METADATA_FN_NODE2"; case bitc::METADATA_NAMED_NODE2: return "METADATA_NAMED_NODE2";