From f23650c3c633a514bd70652670c659c60d8765b5 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Thu, 25 Jun 2020 23:49:07 +0000 Subject: [PATCH] Remove references to the 4.0 release as a major breaking (NFC) This is cleaning up comments (mostly in the bitcode handling) about removing some backward compatibility aspect in the 4.0 release. Historically, "4.0" was used during the development of the 3.x versions as "this future major breaking change version". At the time the major number was used to indicate the compatibility. When we reached 3.9 we decided to change the numbering, instead of going to 3.10 we went to 4.0 but after changing the meaning of the major number to not mean anything anymore with respect to bitcode backward compatibility. The current policy (https://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility) indicates only now: The current LLVM version supports loading any bitcode since version 3.0. Differential Revision: https://reviews.llvm.org/D82514 --- docs/HowToUseAttributes.rst | 4 ++-- include/llvm/Bitcode/LLVMBitCodes.h | 4 ++-- lib/Bitcode/Reader/BitcodeAnalyzer.cpp | 2 +- lib/Bitcode/Reader/BitcodeReader.cpp | 25 +++++++++++++------------ lib/Bitcode/Reader/MetadataLoader.cpp | 4 ++-- lib/IR/DataLayout.cpp | 4 ++-- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/docs/HowToUseAttributes.rst b/docs/HowToUseAttributes.rst index 1d05e238587..cc8a00ec545 100644 --- a/docs/HowToUseAttributes.rst +++ b/docs/HowToUseAttributes.rst @@ -57,7 +57,7 @@ An ``AttributeList`` object is designed to be passed around by value. Note: It is advised that you do *not* use the ``AttributeList`` "introspection" methods (e.g. ``Raw``, ``getRawPointer``, etc.). These methods break -encapsulation, and may be removed in a future release (i.e. LLVM 4.0). +encapsulation, and may be removed in a future release. ``AttrBuilder`` =============== @@ -73,7 +73,7 @@ should be passed by reference. Note: It is advised that you do *not* use the ``AttrBuilder::addRawValue()`` method or the ``AttrBuilder(uint64_t Val)`` constructor. These are for -backwards compatibility and may be removed in a future release (i.e. LLVM 4.0). +backwards compatibility and may be removed in a future release. And that's basically it! A lot of functionality is hidden behind these classes, but the interfaces are pretty straight forward. diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index b370fa48718..092730242d0 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -85,7 +85,7 @@ enum ModuleCodes { MODULE_CODE_ASM = 4, // ASM: [strchr x N] MODULE_CODE_SECTIONNAME = 5, // SECTIONNAME: [strchr x N] - // FIXME: Remove DEPLIB in 4.0. + // Deprecated, but still needed to read old bitcode files. MODULE_CODE_DEPLIB = 6, // DEPLIB: [strchr x N] // GLOBALVAR: [pointer type, isconst, initid, @@ -121,7 +121,7 @@ enum ModuleCodes { /// PARAMATTR blocks have code for defining a parameter attribute set. enum AttributeCodes { - // FIXME: Remove `PARAMATTR_CODE_ENTRY_OLD' in 4.0 + // Deprecated, but still needed to read old bitcode files. PARAMATTR_CODE_ENTRY_OLD = 1, // ENTRY: [paramidx0, attr0, // paramidx1, attr1...] PARAMATTR_CODE_ENTRY = 2, // ENTRY: [attrgrp0, attrgrp1, ...] diff --git a/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/lib/Bitcode/Reader/BitcodeAnalyzer.cpp index 64530f35316..2ce064c7685 100644 --- a/lib/Bitcode/Reader/BitcodeAnalyzer.cpp +++ b/lib/Bitcode/Reader/BitcodeAnalyzer.cpp @@ -130,7 +130,7 @@ static Optional GetCodeName(unsigned CodeID, unsigned BlockID, STRINGIFY_CODE(MODULE_CODE, DATALAYOUT) STRINGIFY_CODE(MODULE_CODE, ASM) STRINGIFY_CODE(MODULE_CODE, SECTIONNAME) - STRINGIFY_CODE(MODULE_CODE, DEPLIB) // FIXME: Remove in 4.0 + STRINGIFY_CODE(MODULE_CODE, DEPLIB) // Deprecated, present in old bitcode STRINGIFY_CODE(MODULE_CODE, GLOBALVAR) STRINGIFY_CODE(MODULE_CODE, FUNCTION) STRINGIFY_CODE(MODULE_CODE, ALIAS) diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index a428416244f..813c1b3a03b 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1317,8 +1317,6 @@ static void addRawAttributeValue(AttrBuilder &B, uint64_t Val) { /// 'encodeLLVMAttributesForBitcode'. static void decodeLLVMAttributesForBitcode(AttrBuilder &B, uint64_t EncodedAttrs) { - // FIXME: Remove in 4.0. - // The alignment is stored as a 16-bit raw value from bits 31--16. We shift // the bits above 31 down by 11 bits. unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16; @@ -1369,7 +1367,7 @@ Error BitcodeReader::parseAttributeBlock() { default: // Default behavior: ignore. break; case bitc::PARAMATTR_CODE_ENTRY_OLD: // ENTRY: [paramidx0, attr0, ...] - // FIXME: Remove in 4.0. + // Deprecated, but still needed to read old bitcode files. if (Record.size() & 1) return error("Invalid record"); @@ -1777,7 +1775,7 @@ Error BitcodeReader::parseTypeTableBody() { break; } case bitc::TYPE_CODE_FUNCTION_OLD: { - // FIXME: attrid is dead, remove it in LLVM 4.0 + // Deprecated, but still needed to read old bitcode files. // FUNCTION: [vararg, attrid, retty, paramty x N] if (Record.size() < 3) return error("Invalid record"); @@ -2700,8 +2698,10 @@ Error BitcodeReader::parseConstants() { if (!IdxTy) return error("Invalid record"); Op1 = ValueList.getConstantFwdRef(Record[3], IdxTy); - } else // TODO: Remove with llvm 4.0 + } else { + // Deprecated, but still needed to read old bitcode files. Op1 = ValueList.getConstantFwdRef(Record[2], Type::getInt32Ty(Context)); + } if (!Op1) return error("Invalid record"); V = ConstantExpr::getExtractElement(Op0, Op1); @@ -2721,8 +2721,10 @@ Error BitcodeReader::parseConstants() { if (!IdxTy) return error("Invalid record"); Op2 = ValueList.getConstantFwdRef(Record[3], IdxTy); - } else // TODO: Remove with llvm 4.0 + } else { + // Deprecated, but still needed to read old bitcode files. Op2 = ValueList.getConstantFwdRef(Record[2], Type::getInt32Ty(Context)); + } if (!Op2) return error("Invalid record"); V = ConstantExpr::getInsertElement(Op0, Op1, Op2); @@ -2762,7 +2764,7 @@ Error BitcodeReader::parseConstants() { break; } // This maintains backward compatibility, pre-asm dialect keywords. - // FIXME: Remove with the 4.0 release. + // Deprecated, but still needed to read old bitcode files. case bitc::CST_CODE_INLINEASM_OLD: { if (Record.size() < 2) return error("Invalid record"); @@ -3163,8 +3165,8 @@ Error BitcodeReader::parseGlobalVarRecord(ArrayRef Record) { } GlobalValue::VisibilityTypes Visibility = GlobalValue::DefaultVisibility; // Local linkage must have default visibility. + // auto-upgrade `hidden` and `protected` for old bitcode. if (Record.size() > 6 && !GlobalValue::isLocalLinkage(Linkage)) - // FIXME: Change to an error if non-default in 4.0. Visibility = getDecodedVisibility(Record[6]); GlobalVariable::ThreadLocalMode TLM = GlobalVariable::NotThreadLocal; @@ -3293,8 +3295,8 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef Record) { Func->setSection(SectionTable[Record[6] - 1]); } // Local linkage must have default visibility. + // auto-upgrade `hidden` and `protected` for old bitcode. if (!Func->hasLocalLinkage()) - // FIXME: Change to an error if non-default in 4.0. Func->setVisibility(getDecodedVisibility(Record[7])); if (Record.size() > 8 && Record[8]) { if (Record[8] - 1 >= GCTable.size()) @@ -3401,12 +3403,11 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord( assert(NewGA->getValueType() == flattenPointerTypes(FullTy) && "Incorrect fully structured type provided for GlobalIndirectSymbol"); - // Old bitcode files didn't have visibility field. // Local linkage must have default visibility. + // auto-upgrade `hidden` and `protected` for old bitcode. if (OpNum != Record.size()) { auto VisInd = OpNum++; if (!NewGA->hasLocalLinkage()) - // FIXME: Change to an error if non-default in 4.0. NewGA->setVisibility(getDecodedVisibility(Record[VisInd])); } if (BitCode == bitc::MODULE_CODE_ALIAS || @@ -3659,7 +3660,7 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit, break; } case bitc::MODULE_CODE_DEPLIB: { // DEPLIB: [strchr x N] - // FIXME: Remove in 4.0. + // Deprecated, but still needed to read old bitcode files. std::string S; if (convertToString(Record, 0, S)) return error("Invalid record"); diff --git a/lib/Bitcode/Reader/MetadataLoader.cpp b/lib/Bitcode/Reader/MetadataLoader.cpp index 34c93beebb0..a8bf579bd18 100644 --- a/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1132,7 +1132,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( break; } case bitc::METADATA_OLD_FN_NODE: { - // FIXME: Remove in 4.0. + // Deprecated, but still needed to read old bitcode files. // This is a LocalAsMetadata record, the only type of function-local // metadata. if (Record.size() % 2 == 1) @@ -1162,7 +1162,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( break; } case bitc::METADATA_OLD_NODE: { - // FIXME: Remove in 4.0. + // Deprecated, but still needed to read old bitcode files. if (Record.size() % 2 == 1) return error("Invalid record"); diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index a4c39a5ca99..ca8f66d5f6c 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -260,8 +260,8 @@ void DataLayout::parseSpecifier(StringRef Desc) { switch (Specifier) { case 's': - // Ignored for backward compatibility. - // FIXME: remove this on LLVM 4.0. + // Deprecated, but ignoring here to preserve loading older textual llvm + // ASM file break; case 'E': BigEndian = true;