[llvm] r267274 - Address comments.
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 23 14:37:57 PDT 2016
> On 2016-Apr-22, at 21:31, Teresa Johnson via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> Author: tejohnson
> Date: Fri Apr 22 23:31:20 2016
> New Revision: 267274
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267274&view=rev
> Log:
> Address comments.
This doesn't describe the commit in a useful way. In the future,
please describe the changes you're making, even when you're responding
to reviews!
>
> Modified:
> llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
>
> Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=267274&r1=267273&r2=267274&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Fri Apr 22 23:31:20 2016
> @@ -63,12 +63,13 @@ enum {
> FUNCTION_INST_GEP_ABBREV,
> };
>
> -/// Class to manage the bitcode writing for all bitcode file types.
> -/// Owns the BitstreamWriter, and includes the main entry point for
> +/// Abstract class to manage the bitcode writing, subclassed for each bitcode
> +/// file type. Owns the BitstreamWriter, and includes the main entry point for
> /// writing.
> class BitcodeWriter {
> +protected:
> /// Pointer to the buffer allocated by caller for bitcode writing.
> - SmallVectorImpl<char> *Buffer;
> + const SmallVectorImpl<char> &Buffer;
>
> /// The stream created and owned by the BitodeWriter.
> BitstreamWriter Stream;
> @@ -80,8 +81,8 @@ class BitcodeWriter {
> public:
> /// Constructs a BitcodeWriter object, and initializes a BitstreamRecord,
> /// writing to the provided \p Buffer.
> - BitcodeWriter(SmallVectorImpl<char> *Buffer)
> - : Buffer(Buffer), Stream(*Buffer) {}
> + BitcodeWriter(SmallVectorImpl<char> &Buffer)
> + : Buffer(Buffer), Stream(Buffer) {}
>
> virtual ~BitcodeWriter() = default;
>
> @@ -96,9 +97,6 @@ private:
>
> protected:
> bool hasVSTOffsetPlaceholder() { return VSTOffsetPlaceholder != 0; }
> - uint64_t getVSTOffsetPlaceholder() { return VSTOffsetPlaceholder; }
> - SmallVectorImpl<char> &buffer() { return *Buffer; }
> - BitstreamWriter &stream() { return Stream; }
> void writeValueSymbolTableForwardDecl();
> void writeBitcodeHeader();
> };
> @@ -106,7 +104,7 @@ protected:
> /// Class to manage the bitcode writing for a module.
> class ModuleBitcodeWriter : public BitcodeWriter {
> /// The Module to write to bitcode.
> - const Module *M;
> + const Module &M;
>
> /// Enumerates ids for all values in the module.
> ValueEnumerator VE;
> @@ -123,16 +121,16 @@ class ModuleBitcodeWriter : public Bitco
> public:
> /// Constructs a ModuleBitcodeWriter object for the given Module,
> /// writing to the provided \p Buffer.
> - ModuleBitcodeWriter(const Module *M, SmallVectorImpl<char> *Buffer,
> + ModuleBitcodeWriter(const Module *M, SmallVectorImpl<char> &Buffer,
> bool ShouldPreserveUseListOrder,
> const ModuleSummaryIndex *Index, bool GenerateHash)
> - : BitcodeWriter(Buffer), M(M), VE(*M, ShouldPreserveUseListOrder),
> + : BitcodeWriter(Buffer), M(*M), VE(*M, ShouldPreserveUseListOrder),
> Index(Index), GenerateHash(GenerateHash) {
> // Save the start bit of the actual bitcode, in case there is space
> // saved at the start for the darwin header above. The reader stream
> // will start at the bitcode, and we need the offset of the VST
> // to line up.
> - BitcodeStartBit = stream().GetCurrentBitNo();
> + BitcodeStartBit = Stream.GetCurrentBitNo();
> }
>
> private:
> @@ -263,7 +261,7 @@ private:
> /// Class to manage the bitcode writing for a combined index.
> class IndexBitcodeWriter : public BitcodeWriter {
> /// The combined index to write to bitcode.
> - const ModuleSummaryIndex *Index;
> + const ModuleSummaryIndex &Index;
>
> /// Map that holds the correspondence between the GUID used in the combined
> /// index and a value id generated by this class to use in references.
> @@ -275,14 +273,14 @@ class IndexBitcodeWriter : public Bitcod
> public:
> /// Constructs a IndexBitcodeWriter object for the given combined index,
> /// writing to the provided \p Buffer.
> - IndexBitcodeWriter(SmallVectorImpl<char> *Buffer,
> - const ModuleSummaryIndex *Index)
> + IndexBitcodeWriter(SmallVectorImpl<char> &Buffer,
> + const ModuleSummaryIndex &Index)
> : BitcodeWriter(Buffer), Index(Index) {
> // Assign unique value ids to all functions in the index for use
> // in writing out the call graph edges. Save the mapping from GUID
> // to the new global value id to use when writing those edges, which
> // are currently saved in the index in terms of GUID.
> - for (auto &II : *Index)
> + for (auto &II : Index)
> GUIDToValueIdMap[II.first] = ++GlobalValueId;
> }
>
> @@ -413,7 +411,7 @@ void ModuleBitcodeWriter::writeStringRec
> }
>
> // Emit the finished record.
> - stream().EmitRecord(Code, Vals, AbbrevToUse);
> + Stream.EmitRecord(Code, Vals, AbbrevToUse);
> }
>
> static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
> @@ -533,7 +531,7 @@ void ModuleBitcodeWriter::writeAttribute
> const std::vector<AttributeSet> &AttrGrps = VE.getAttributeGroups();
> if (AttrGrps.empty()) return;
>
> - stream().EnterSubblock(bitc::PARAMATTR_GROUP_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::PARAMATTR_GROUP_BLOCK_ID, 3);
>
> SmallVector<uint64_t, 64> Record;
> for (unsigned i = 0, e = AttrGrps.size(); i != e; ++i) {
> @@ -568,19 +566,19 @@ void ModuleBitcodeWriter::writeAttribute
> }
> }
>
> - stream().EmitRecord(bitc::PARAMATTR_GRP_CODE_ENTRY, Record);
> + Stream.EmitRecord(bitc::PARAMATTR_GRP_CODE_ENTRY, Record);
> Record.clear();
> }
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeAttributeTable() {
> const std::vector<AttributeSet> &Attrs = VE.getAttributes();
> if (Attrs.empty()) return;
>
> - stream().EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3);
>
> SmallVector<uint64_t, 64> Record;
> for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
> @@ -588,18 +586,18 @@ void ModuleBitcodeWriter::writeAttribute
> for (unsigned i = 0, e = A.getNumSlots(); i != e; ++i)
> Record.push_back(VE.getAttributeGroupID(A.getSlotAttributes(i)));
>
> - stream().EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
> + Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
> Record.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> /// WriteTypeTable - Write out the type table for a module.
> void ModuleBitcodeWriter::writeTypeTable() {
> const ValueEnumerator::TypeList &TypeList = VE.getTypes();
>
> - stream().EnterSubblock(bitc::TYPE_BLOCK_ID_NEW, 4 /*count from # abbrevs */);
> + Stream.EnterSubblock(bitc::TYPE_BLOCK_ID_NEW, 4 /*count from # abbrevs */);
> SmallVector<uint64_t, 64> TypeVals;
>
> uint64_t NumBits = VE.computeBitsRequiredForTypeIndicies();
> @@ -609,7 +607,7 @@ void ModuleBitcodeWriter::writeTypeTable
> Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_POINTER));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
> Abbv->Add(BitCodeAbbrevOp(0)); // Addrspace = 0
> - unsigned PtrAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for TYPE_CODE_FUNCTION.
> Abbv = new BitCodeAbbrev();
> @@ -618,7 +616,7 @@ void ModuleBitcodeWriter::writeTypeTable
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
>
> - unsigned FunctionAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FunctionAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for TYPE_CODE_STRUCT_ANON.
> Abbv = new BitCodeAbbrev();
> @@ -627,14 +625,14 @@ void ModuleBitcodeWriter::writeTypeTable
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
>
> - unsigned StructAnonAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned StructAnonAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for TYPE_CODE_STRUCT_NAME.
> Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_STRUCT_NAME));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
> - unsigned StructNameAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned StructNameAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for TYPE_CODE_STRUCT_NAMED.
> Abbv = new BitCodeAbbrev();
> @@ -643,7 +641,7 @@ void ModuleBitcodeWriter::writeTypeTable
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
>
> - unsigned StructNamedAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned StructNamedAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for TYPE_CODE_ARRAY.
> Abbv = new BitCodeAbbrev();
> @@ -651,11 +649,11 @@ void ModuleBitcodeWriter::writeTypeTable
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // size
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
>
> - unsigned ArrayAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned ArrayAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Emit an entry count so the reader can reserve space.
> TypeVals.push_back(TypeList.size());
> - stream().EmitRecord(bitc::TYPE_CODE_NUMENTRY, TypeVals);
> + Stream.EmitRecord(bitc::TYPE_CODE_NUMENTRY, TypeVals);
> TypeVals.clear();
>
> // Loop over all of the types, emitting each in turn.
> @@ -749,11 +747,11 @@ void ModuleBitcodeWriter::writeTypeTable
> }
>
> // Emit the finished record.
> - stream().EmitRecord(Code, TypeVals, AbbrevToUse);
> + Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
> TypeVals.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage) {
> @@ -843,7 +841,7 @@ void ModuleBitcodeWriter::writeComdats()
> Vals.push_back(Size);
> for (char Chr : C->getName())
> Vals.push_back((unsigned char)Chr);
> - stream().EmitRecord(bitc::MODULE_CODE_COMDAT, Vals, /*AbbrevToUse=*/0);
> + Stream.EmitRecord(bitc::MODULE_CODE_COMDAT, Vals, /*AbbrevToUse=*/0);
> Vals.clear();
> }
> }
> @@ -862,16 +860,16 @@ void BitcodeWriter::writeValueSymbolTabl
> // hold the real VST offset. Must use fixed instead of VBR as we don't
> // know how many VBR chunks to reserve ahead of time.
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
> - unsigned VSTOffsetAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned VSTOffsetAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Emit the placeholder
> uint64_t Vals[] = {bitc::MODULE_CODE_VSTOFFSET, 0};
> - stream().EmitRecordWithAbbrev(VSTOffsetAbbrev, Vals);
> + Stream.EmitRecordWithAbbrev(VSTOffsetAbbrev, Vals);
>
> // Compute and save the bit offset to the placeholder, which will be
> // patched when the real VST is written. We can simply subtract the 32-bit
> // fixed size from the current bit number to get the location to backpatch.
> - VSTOffsetPlaceholder = stream().GetCurrentBitNo() - 32;
> + VSTOffsetPlaceholder = Stream.GetCurrentBitNo() - 32;
> }
>
> enum StringEncoding { SE_Char6, SE_Fixed7, SE_Fixed8 };
> @@ -897,14 +895,14 @@ static StringEncoding getStringEncoding(
> /// Returns the bit offset to backpatch with the location of the real VST.
> void ModuleBitcodeWriter::writeModuleInfo() {
> // Emit various pieces of data attached to a module.
> - if (!M->getTargetTriple().empty())
> - writeStringRecord(bitc::MODULE_CODE_TRIPLE, M->getTargetTriple(),
> + if (!M.getTargetTriple().empty())
> + writeStringRecord(bitc::MODULE_CODE_TRIPLE, M.getTargetTriple(),
> 0 /*TODO*/);
> - const std::string &DL = M->getDataLayoutStr();
> + const std::string &DL = M.getDataLayoutStr();
> if (!DL.empty())
> writeStringRecord(bitc::MODULE_CODE_DATALAYOUT, DL, 0 /*TODO*/);
> - if (!M->getModuleInlineAsm().empty())
> - writeStringRecord(bitc::MODULE_CODE_ASM, M->getModuleInlineAsm(),
> + if (!M.getModuleInlineAsm().empty())
> + writeStringRecord(bitc::MODULE_CODE_ASM, M.getModuleInlineAsm(),
> 0 /*TODO*/);
>
> // Emit information about sections and GC, computing how many there are. Also
> @@ -913,7 +911,7 @@ void ModuleBitcodeWriter::writeModuleInf
> std::map<std::string, unsigned> GCMap;
> unsigned MaxAlignment = 0;
> unsigned MaxGlobalType = 0;
> - for (const GlobalValue &GV : M->globals()) {
> + for (const GlobalValue &GV : M.globals()) {
> MaxAlignment = std::max(MaxAlignment, GV.getAlignment());
> MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
> if (GV.hasSection()) {
> @@ -926,7 +924,7 @@ void ModuleBitcodeWriter::writeModuleInf
> }
> }
> }
> - for (const Function &F : *M) {
> + for (const Function &F : M) {
> MaxAlignment = std::max(MaxAlignment, F.getAlignment());
> if (F.hasSection()) {
> // Give section names unique ID's.
> @@ -949,7 +947,7 @@ void ModuleBitcodeWriter::writeModuleInf
>
> // Emit abbrev for globals, now that we know # sections and max alignment.
> unsigned SimpleGVarAbbrev = 0;
> - if (!M->global_empty()) {
> + if (!M.global_empty()) {
> // Add an abbrev for common globals with no visibility or thread localness.
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::MODULE_CODE_GLOBALVAR));
> @@ -973,12 +971,12 @@ void ModuleBitcodeWriter::writeModuleInf
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
> Log2_32_Ceil(SectionMap.size()+1)));
> // Don't bother emitting vis + thread local.
> - SimpleGVarAbbrev = stream().EmitAbbrev(Abbv);
> + SimpleGVarAbbrev = Stream.EmitAbbrev(Abbv);
> }
>
> // Emit the global variable information.
> SmallVector<unsigned, 64> Vals;
> - for (const GlobalVariable &GV : M->globals()) {
> + for (const GlobalVariable &GV : M.globals()) {
> unsigned AbbrevToUse = 0;
>
> // GLOBALVAR: [type, isconst, initid,
> @@ -1007,12 +1005,12 @@ void ModuleBitcodeWriter::writeModuleInf
> AbbrevToUse = SimpleGVarAbbrev;
> }
>
> - stream().EmitRecord(bitc::MODULE_CODE_GLOBALVAR, Vals, AbbrevToUse);
> + Stream.EmitRecord(bitc::MODULE_CODE_GLOBALVAR, Vals, AbbrevToUse);
> Vals.clear();
> }
>
> // Emit the function proto information.
> - for (const Function &F : *M) {
> + for (const Function &F : M) {
> // FUNCTION: [type, callingconv, isproto, linkage, paramattrs, alignment,
> // section, visibility, gc, unnamed_addr, prologuedata,
> // dllstorageclass, comdat, prefixdata, personalityfn]
> @@ -1036,12 +1034,12 @@ void ModuleBitcodeWriter::writeModuleInf
> F.hasPersonalityFn() ? (VE.getValueID(F.getPersonalityFn()) + 1) : 0);
>
> unsigned AbbrevToUse = 0;
> - stream().EmitRecord(bitc::MODULE_CODE_FUNCTION, Vals, AbbrevToUse);
> + Stream.EmitRecord(bitc::MODULE_CODE_FUNCTION, Vals, AbbrevToUse);
> Vals.clear();
> }
>
> // Emit the alias information.
> - for (const GlobalAlias &A : M->aliases()) {
> + for (const GlobalAlias &A : M.aliases()) {
> // ALIAS: [alias type, aliasee val#, linkage, visibility]
> Vals.push_back(VE.getTypeID(A.getValueType()));
> Vals.push_back(A.getType()->getAddressSpace());
> @@ -1052,26 +1050,26 @@ void ModuleBitcodeWriter::writeModuleInf
> Vals.push_back(getEncodedThreadLocalMode(A));
> Vals.push_back(A.hasUnnamedAddr());
> unsigned AbbrevToUse = 0;
> - stream().EmitRecord(bitc::MODULE_CODE_ALIAS, Vals, AbbrevToUse);
> + Stream.EmitRecord(bitc::MODULE_CODE_ALIAS, Vals, AbbrevToUse);
> Vals.clear();
> }
>
> // Emit the ifunc information.
> - for (const GlobalIFunc &I : M->ifuncs()) {
> + for (const GlobalIFunc &I : M.ifuncs()) {
> // IFUNC: [ifunc type, address space, resolver val#, linkage, visibility]
> Vals.push_back(VE.getTypeID(I.getValueType()));
> Vals.push_back(I.getType()->getAddressSpace());
> Vals.push_back(VE.getValueID(I.getResolver()));
> Vals.push_back(getEncodedLinkage(I));
> Vals.push_back(getEncodedVisibility(I));
> - stream().EmitRecord(bitc::MODULE_CODE_IFUNC, Vals);
> + Stream.EmitRecord(bitc::MODULE_CODE_IFUNC, Vals);
> Vals.clear();
> }
>
> // Emit the module's source file name.
> {
> - StringEncoding Bits = getStringEncoding(M->getSourceFileName().data(),
> - M->getSourceFileName().size());
> + StringEncoding Bits = getStringEncoding(M.getSourceFileName().data(),
> + M.getSourceFileName().size());
> BitCodeAbbrevOp AbbrevOpToUse = BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8);
> if (Bits == SE_Char6)
> AbbrevOpToUse = BitCodeAbbrevOp(BitCodeAbbrevOp::Char6);
> @@ -1083,19 +1081,18 @@ void ModuleBitcodeWriter::writeModuleInf
> Abbv->Add(BitCodeAbbrevOp(bitc::MODULE_CODE_SOURCE_FILENAME));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(AbbrevOpToUse);
> - unsigned FilenameAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FilenameAbbrev = Stream.EmitAbbrev(Abbv);
>
> - for (const auto P : M->getSourceFileName())
> + for (const auto P : M.getSourceFileName())
> Vals.push_back((unsigned char)P);
>
> // Emit the finished record.
> - stream().EmitRecord(bitc::MODULE_CODE_SOURCE_FILENAME, Vals,
> - FilenameAbbrev);
> + Stream.EmitRecord(bitc::MODULE_CODE_SOURCE_FILENAME, Vals, FilenameAbbrev);
> Vals.clear();
> }
>
> // If we have a VST, write the VSTOFFSET record placeholder.
> - if (M->getValueSymbolTable().empty())
> + if (M.getValueSymbolTable().empty())
> return;
> writeValueSymbolTableForwardDecl();
> }
> @@ -1133,7 +1130,7 @@ void ModuleBitcodeWriter::writeValueAsMe
> Value *V = MD->getValue();
> Record.push_back(VE.getTypeID(V->getType()));
> Record.push_back(VE.getValueID(V));
> - stream().EmitRecord(bitc::METADATA_VALUE, Record, 0);
> + Stream.EmitRecord(bitc::METADATA_VALUE, Record, 0);
> Record.clear();
> }
>
> @@ -1146,9 +1143,9 @@ void ModuleBitcodeWriter::writeMDTuple(c
> "Unexpected function-local metadata");
> Record.push_back(VE.getMetadataOrNullID(MD));
> }
> - stream().EmitRecord(N->isDistinct() ? bitc::METADATA_DISTINCT_NODE
> - : bitc::METADATA_NODE,
> - Record, Abbrev);
> + Stream.EmitRecord(N->isDistinct() ? bitc::METADATA_DISTINCT_NODE
> + : bitc::METADATA_NODE,
> + Record, Abbrev);
> Record.clear();
> }
>
> @@ -1162,7 +1159,7 @@ unsigned ModuleBitcodeWriter::createDILo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
> - return stream().EmitAbbrev(Abbv);
> + return Stream.EmitAbbrev(Abbv);
> }
>
> void ModuleBitcodeWriter::writeDILocation(const DILocation *N,
> @@ -1177,7 +1174,7 @@ void ModuleBitcodeWriter::writeDILocatio
> Record.push_back(VE.getMetadataID(N->getScope()));
> Record.push_back(VE.getMetadataOrNullID(N->getInlinedAt()));
>
> - stream().EmitRecord(bitc::METADATA_LOCATION, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_LOCATION, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1192,7 +1189,7 @@ unsigned ModuleBitcodeWriter::createGene
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
> - return stream().EmitAbbrev(Abbv);
> + return Stream.EmitAbbrev(Abbv);
> }
>
> void ModuleBitcodeWriter::writeGenericDINode(const GenericDINode *N,
> @@ -1208,7 +1205,7 @@ void ModuleBitcodeWriter::writeGenericDI
> for (auto &I : N->operands())
> Record.push_back(VE.getMetadataOrNullID(I));
>
> - stream().EmitRecord(bitc::METADATA_GENERIC_DEBUG, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_GENERIC_DEBUG, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1224,7 +1221,7 @@ void ModuleBitcodeWriter::writeDISubrang
> Record.push_back(N->getCount());
> Record.push_back(rotateSign(N->getLowerBound()));
>
> - stream().EmitRecord(bitc::METADATA_SUBRANGE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_SUBRANGE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1235,7 +1232,7 @@ void ModuleBitcodeWriter::writeDIEnumera
> Record.push_back(rotateSign(N->getValue()));
> Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
>
> - stream().EmitRecord(bitc::METADATA_ENUMERATOR, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_ENUMERATOR, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1249,7 +1246,7 @@ void ModuleBitcodeWriter::writeDIBasicTy
> Record.push_back(N->getAlignInBits());
> Record.push_back(N->getEncoding());
>
> - stream().EmitRecord(bitc::METADATA_BASIC_TYPE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_BASIC_TYPE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1269,7 +1266,7 @@ void ModuleBitcodeWriter::writeDIDerived
> Record.push_back(N->getFlags());
> Record.push_back(VE.getMetadataOrNullID(N->getExtraData()));
>
> - stream().EmitRecord(bitc::METADATA_DERIVED_TYPE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_DERIVED_TYPE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1293,7 +1290,7 @@ void ModuleBitcodeWriter::writeDIComposi
> Record.push_back(VE.getMetadataOrNullID(N->getTemplateParams().get()));
> Record.push_back(VE.getMetadataOrNullID(N->getRawIdentifier()));
>
> - stream().EmitRecord(bitc::METADATA_COMPOSITE_TYPE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_COMPOSITE_TYPE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1304,7 +1301,7 @@ void ModuleBitcodeWriter::writeDISubrout
> Record.push_back(N->getFlags());
> Record.push_back(VE.getMetadataOrNullID(N->getTypeArray().get()));
>
> - stream().EmitRecord(bitc::METADATA_SUBROUTINE_TYPE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_SUBROUTINE_TYPE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1315,7 +1312,7 @@ void ModuleBitcodeWriter::writeDIFile(co
> Record.push_back(VE.getMetadataOrNullID(N->getRawFilename()));
> Record.push_back(VE.getMetadataOrNullID(N->getRawDirectory()));
>
> - stream().EmitRecord(bitc::METADATA_FILE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_FILE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1340,7 +1337,7 @@ void ModuleBitcodeWriter::writeDICompile
> Record.push_back(N->getDWOId());
> Record.push_back(VE.getMetadataOrNullID(N->getMacros().get()));
>
> - stream().EmitRecord(bitc::METADATA_COMPILE_UNIT, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_COMPILE_UNIT, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1367,7 +1364,7 @@ void ModuleBitcodeWriter::writeDISubprog
> Record.push_back(VE.getMetadataOrNullID(N->getDeclaration()));
> Record.push_back(VE.getMetadataOrNullID(N->getVariables().get()));
>
> - stream().EmitRecord(bitc::METADATA_SUBPROGRAM, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_SUBPROGRAM, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1380,7 +1377,7 @@ void ModuleBitcodeWriter::writeDILexical
> Record.push_back(N->getLine());
> Record.push_back(N->getColumn());
>
> - stream().EmitRecord(bitc::METADATA_LEXICAL_BLOCK, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_LEXICAL_BLOCK, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1392,7 +1389,7 @@ void ModuleBitcodeWriter::writeDILexical
> Record.push_back(VE.getMetadataOrNullID(N->getFile()));
> Record.push_back(N->getDiscriminator());
>
> - stream().EmitRecord(bitc::METADATA_LEXICAL_BLOCK_FILE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_LEXICAL_BLOCK_FILE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1405,7 +1402,7 @@ void ModuleBitcodeWriter::writeDINamespa
> Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
> Record.push_back(N->getLine());
>
> - stream().EmitRecord(bitc::METADATA_NAMESPACE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_NAMESPACE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1418,7 +1415,7 @@ void ModuleBitcodeWriter::writeDIMacro(c
> Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
> Record.push_back(VE.getMetadataOrNullID(N->getRawValue()));
>
> - stream().EmitRecord(bitc::METADATA_MACRO, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_MACRO, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1431,7 +1428,7 @@ void ModuleBitcodeWriter::writeDIMacroFi
> Record.push_back(VE.getMetadataOrNullID(N->getFile()));
> Record.push_back(VE.getMetadataOrNullID(N->getElements().get()));
>
> - stream().EmitRecord(bitc::METADATA_MACRO_FILE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_MACRO_FILE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1442,7 +1439,7 @@ void ModuleBitcodeWriter::writeDIModule(
> for (auto &I : N->operands())
> Record.push_back(VE.getMetadataOrNullID(I));
>
> - stream().EmitRecord(bitc::METADATA_MODULE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_MODULE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1453,7 +1450,7 @@ void ModuleBitcodeWriter::writeDITemplat
> Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
> Record.push_back(VE.getMetadataOrNullID(N->getType()));
>
> - stream().EmitRecord(bitc::METADATA_TEMPLATE_TYPE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_TEMPLATE_TYPE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1466,7 +1463,7 @@ void ModuleBitcodeWriter::writeDITemplat
> Record.push_back(VE.getMetadataOrNullID(N->getType()));
> Record.push_back(VE.getMetadataOrNullID(N->getValue()));
>
> - stream().EmitRecord(bitc::METADATA_TEMPLATE_VALUE, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_TEMPLATE_VALUE, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1485,7 +1482,7 @@ void ModuleBitcodeWriter::writeDIGlobalV
> Record.push_back(VE.getMetadataOrNullID(N->getRawVariable()));
> Record.push_back(VE.getMetadataOrNullID(N->getStaticDataMemberDeclaration()));
>
> - stream().EmitRecord(bitc::METADATA_GLOBAL_VAR, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_GLOBAL_VAR, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1501,7 +1498,7 @@ void ModuleBitcodeWriter::writeDILocalVa
> Record.push_back(N->getArg());
> Record.push_back(N->getFlags());
>
> - stream().EmitRecord(bitc::METADATA_LOCAL_VAR, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_LOCAL_VAR, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1513,7 +1510,7 @@ void ModuleBitcodeWriter::writeDIExpress
> Record.push_back(N->isDistinct());
> Record.append(N->elements_begin(), N->elements_end());
>
> - stream().EmitRecord(bitc::METADATA_EXPRESSION, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_EXPRESSION, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1529,7 +1526,7 @@ void ModuleBitcodeWriter::writeDIObjCPro
> Record.push_back(N->getAttributes());
> Record.push_back(VE.getMetadataOrNullID(N->getType()));
>
> - stream().EmitRecord(bitc::METADATA_OBJC_PROPERTY, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_OBJC_PROPERTY, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1543,7 +1540,7 @@ void ModuleBitcodeWriter::writeDIImporte
> Record.push_back(N->getLine());
> Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
>
> - stream().EmitRecord(bitc::METADATA_IMPORTED_ENTITY, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_IMPORTED_ENTITY, Record, Abbrev);
> Record.clear();
> }
>
> @@ -1552,26 +1549,26 @@ unsigned ModuleBitcodeWriter::createName
> Abbv->Add(BitCodeAbbrevOp(bitc::METADATA_NAME));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
> - return stream().EmitAbbrev(Abbv);
> + return Stream.EmitAbbrev(Abbv);
> }
>
> void ModuleBitcodeWriter::writeNamedMetadata(
> SmallVectorImpl<uint64_t> &Record) {
> - if (M->named_metadata_empty())
> + if (M.named_metadata_empty())
> return;
>
> unsigned Abbrev = createNamedMetadataAbbrev();
> - for (const NamedMDNode &NMD : M->named_metadata()) {
> + for (const NamedMDNode &NMD : M.named_metadata()) {
> // Write name.
> StringRef Str = NMD.getName();
> Record.append(Str.bytes_begin(), Str.bytes_end());
> - stream().EmitRecord(bitc::METADATA_NAME, Record, Abbrev);
> + Stream.EmitRecord(bitc::METADATA_NAME, Record, Abbrev);
> Record.clear();
>
> // Write named metadata operands.
> for (const MDNode *N : NMD.operands())
> Record.push_back(VE.getMetadataID(N));
> - stream().EmitRecord(bitc::METADATA_NAMED_NODE, Record, 0);
> + Stream.EmitRecord(bitc::METADATA_NAMED_NODE, Record, 0);
> Record.clear();
> }
> }
> @@ -1582,7 +1579,7 @@ unsigned ModuleBitcodeWriter::createMeta
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // # of strings
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // offset to chars
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
> - return stream().EmitAbbrev(Abbv);
> + return Stream.EmitAbbrev(Abbv);
> }
>
> /// Write out a record for MDString.
> @@ -1615,7 +1612,7 @@ void ModuleBitcodeWriter::writeMetadataS
> Blob.append(cast<MDString>(MD)->getString());
>
> // Emit the final record.
> - stream().EmitRecordWithBlob(createMetadataStringsAbbrev(), Record, Blob);
> + Stream.EmitRecordWithBlob(createMetadataStringsAbbrev(), Record, Blob);
> Record.clear();
> }
>
> @@ -1647,30 +1644,30 @@ void ModuleBitcodeWriter::writeMetadataR
> }
>
> void ModuleBitcodeWriter::writeModuleMetadata() {
> - if (!VE.hasMDs() && M->named_metadata_empty())
> + if (!VE.hasMDs() && M.named_metadata_empty())
> return;
>
> - stream().EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
> SmallVector<uint64_t, 64> Record;
> writeMetadataStrings(VE.getMDStrings(), Record);
> writeMetadataRecords(VE.getNonMDStrings(), Record);
> writeNamedMetadata(Record);
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeFunctionMetadata(const Function &F) {
> if (!VE.hasMDs())
> return;
>
> - stream().EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
> SmallVector<uint64_t, 64> Record;
> writeMetadataStrings(VE.getMDStrings(), Record);
> writeMetadataRecords(VE.getNonMDStrings(), Record);
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeMetadataAttachment(const Function &F) {
> - stream().EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3);
> + Stream.EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3);
>
> SmallVector<uint64_t, 64> Record;
>
> @@ -1683,7 +1680,7 @@ void ModuleBitcodeWriter::writeMetadataA
> Record.push_back(I.first);
> Record.push_back(VE.getMetadataID(I.second));
> }
> - stream().EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0);
> + Stream.EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0);
> Record.clear();
> }
>
> @@ -1701,11 +1698,11 @@ void ModuleBitcodeWriter::writeMetadataA
> Record.push_back(MDs[i].first);
> Record.push_back(VE.getMetadataID(MDs[i].second));
> }
> - stream().EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0);
> + Stream.EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0);
> Record.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeModuleMetadataStore() {
> @@ -1714,22 +1711,22 @@ void ModuleBitcodeWriter::writeModuleMet
> // Write metadata kinds
> // METADATA_KIND - [n x [id, name]]
> SmallVector<StringRef, 8> Names;
> - M->getMDKindNames(Names);
> + M.getMDKindNames(Names);
>
> if (Names.empty()) return;
>
> - stream().EnterSubblock(bitc::METADATA_KIND_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::METADATA_KIND_BLOCK_ID, 3);
>
> for (unsigned MDKindID = 0, e = Names.size(); MDKindID != e; ++MDKindID) {
> Record.push_back(MDKindID);
> StringRef KName = Names[MDKindID];
> Record.append(KName.begin(), KName.end());
>
> - stream().EmitRecord(bitc::METADATA_KIND, Record, 0);
> + Stream.EmitRecord(bitc::METADATA_KIND, Record, 0);
> Record.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeOperandBundleTags() {
> @@ -1740,23 +1737,23 @@ void ModuleBitcodeWriter::writeOperandBu
> // OPERAND_BUNDLE_TAG - [strchr x N]
>
> SmallVector<StringRef, 8> Tags;
> - M->getOperandBundleTags(Tags);
> + M.getOperandBundleTags(Tags);
>
> if (Tags.empty())
> return;
>
> - stream().EnterSubblock(bitc::OPERAND_BUNDLE_TAGS_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::OPERAND_BUNDLE_TAGS_BLOCK_ID, 3);
>
> SmallVector<uint64_t, 64> Record;
>
> for (auto Tag : Tags) {
> Record.append(Tag.begin(), Tag.end());
>
> - stream().EmitRecord(bitc::OPERAND_BUNDLE_TAG, Record, 0);
> + Stream.EmitRecord(bitc::OPERAND_BUNDLE_TAG, Record, 0);
> Record.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> static void emitSignedInt64(SmallVectorImpl<uint64_t> &Vals, uint64_t V) {
> @@ -1770,7 +1767,7 @@ void ModuleBitcodeWriter::writeConstants
> bool isGlobal) {
> if (FirstVal == LastVal) return;
>
> - stream().EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4);
> + Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4);
>
> unsigned AggregateAbbrev = 0;
> unsigned String8Abbrev = 0;
> @@ -1783,26 +1780,26 @@ void ModuleBitcodeWriter::writeConstants
> Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_AGGREGATE));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1)));
> - AggregateAbbrev = stream().EmitAbbrev(Abbv);
> + AggregateAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for CST_CODE_STRING.
> Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
> - String8Abbrev = stream().EmitAbbrev(Abbv);
> + String8Abbrev = Stream.EmitAbbrev(Abbv);
> // Abbrev for CST_CODE_CSTRING.
> Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
> - CString7Abbrev = stream().EmitAbbrev(Abbv);
> + CString7Abbrev = Stream.EmitAbbrev(Abbv);
> // Abbrev for CST_CODE_CSTRING.
> Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
> - CString6Abbrev = stream().EmitAbbrev(Abbv);
> + CString6Abbrev = Stream.EmitAbbrev(Abbv);
> }
>
> SmallVector<uint64_t, 64> Record;
> @@ -1815,8 +1812,8 @@ void ModuleBitcodeWriter::writeConstants
> if (V->getType() != LastTy) {
> LastTy = V->getType();
> Record.push_back(VE.getTypeID(LastTy));
> - stream().EmitRecord(bitc::CST_CODE_SETTYPE, Record,
> - CONSTANTS_SETTYPE_ABBREV);
> + Stream.EmitRecord(bitc::CST_CODE_SETTYPE, Record,
> + CONSTANTS_SETTYPE_ABBREV);
> Record.clear();
> }
>
> @@ -1834,7 +1831,7 @@ void ModuleBitcodeWriter::writeConstants
> const std::string &ConstraintStr = IA->getConstraintString();
> Record.push_back(ConstraintStr.size());
> Record.append(ConstraintStr.begin(), ConstraintStr.end());
> - stream().EmitRecord(bitc::CST_CODE_INLINEASM, Record);
> + Stream.EmitRecord(bitc::CST_CODE_INLINEASM, Record);
> Record.clear();
> continue;
> }
> @@ -2014,11 +2011,11 @@ void ModuleBitcodeWriter::writeConstants
> #endif
> llvm_unreachable("Unknown constant!");
> }
> - stream().EmitRecord(Code, Record, AbbrevToUse);
> + Stream.EmitRecord(Code, Record, AbbrevToUse);
> Record.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeModuleConstants() {
> @@ -2066,7 +2063,7 @@ void ModuleBitcodeWriter::writeOperandBu
> for (auto &Input : Bundle.Inputs)
> pushValueAndType(Input, InstID, Record);
>
> - stream().EmitRecord(bitc::FUNC_CODE_OPERAND_BUNDLE, Record);
> + Stream.EmitRecord(bitc::FUNC_CODE_OPERAND_BUNDLE, Record);
> Record.clear();
> }
> }
> @@ -2320,7 +2317,7 @@ void ModuleBitcodeWriter::writeInstructi
> Vals64.push_back(VE.getValueID(PN.getIncomingBlock(i)));
> }
> // Emit a Vals64 vector and exit.
> - stream().EmitRecord(Code, Vals64, AbbrevToUse);
> + Stream.EmitRecord(Code, Vals64, AbbrevToUse);
> Vals64.clear();
> return;
> }
> @@ -2468,7 +2465,7 @@ void ModuleBitcodeWriter::writeInstructi
> break;
> }
>
> - stream().EmitRecord(Code, Vals, AbbrevToUse);
> + Stream.EmitRecord(Code, Vals, AbbrevToUse);
> Vals.clear();
> }
>
> @@ -2489,15 +2486,15 @@ void ModuleBitcodeWriter::writeValueSymb
> if (IsModuleLevel && hasVSTOffsetPlaceholder()) {
> // Get the offset of the VST we are writing, and backpatch it into
> // the VST forward declaration record.
> - uint64_t VSTOffset = stream().GetCurrentBitNo();
> + uint64_t VSTOffset = Stream.GetCurrentBitNo();
> // The BitcodeStartBit was the stream offset of the actual bitcode
> // (e.g. excluding any initial darwin header).
> VSTOffset -= bitcodeStartBit();
> assert((VSTOffset & 31) == 0 && "VST block not 32-bit aligned");
> - stream().BackpatchWord(getVSTOffsetPlaceholder(), VSTOffset / 32);
> + Stream.BackpatchWord(VSTOffsetPlaceholder, VSTOffset / 32);
> }
>
> - stream().EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 4);
> + Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 4);
>
> // For the module-level VST, add abbrev Ids for the VST_CODE_FNENTRY
> // records, which are not used in the per-function VSTs.
> @@ -2512,7 +2509,7 @@ void ModuleBitcodeWriter::writeValueSymb
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
> - FnEntry8BitAbbrev = stream().EmitAbbrev(Abbv);
> + FnEntry8BitAbbrev = Stream.EmitAbbrev(Abbv);
>
> // 7-bit fixed width VST_CODE_FNENTRY function strings.
> Abbv = new BitCodeAbbrev();
> @@ -2521,7 +2518,7 @@ void ModuleBitcodeWriter::writeValueSymb
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
> - FnEntry7BitAbbrev = stream().EmitAbbrev(Abbv);
> + FnEntry7BitAbbrev = Stream.EmitAbbrev(Abbv);
>
> // 6-bit char6 VST_CODE_FNENTRY function strings.
> Abbv = new BitCodeAbbrev();
> @@ -2530,7 +2527,7 @@ void ModuleBitcodeWriter::writeValueSymb
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
> - FnEntry6BitAbbrev = stream().EmitAbbrev(Abbv);
> + FnEntry6BitAbbrev = Stream.EmitAbbrev(Abbv);
> }
>
> // FIXME: Set up the abbrev, we know how many values there are!
> @@ -2593,10 +2590,10 @@ void ModuleBitcodeWriter::writeValueSymb
> NameVals.push_back((unsigned char)P);
>
> // Emit the finished record.
> - stream().EmitRecord(Code, NameVals, AbbrevToUse);
> + Stream.EmitRecord(Code, NameVals, AbbrevToUse);
> NameVals.clear();
> }
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> /// Emit function names and summary offsets for the combined index
> @@ -2605,28 +2602,28 @@ void IndexBitcodeWriter::writeCombinedVa
> assert(hasVSTOffsetPlaceholder() && "Expected non-zero VSTOffsetPlaceholder");
> // Get the offset of the VST we are writing, and backpatch it into
> // the VST forward declaration record.
> - uint64_t VSTOffset = stream().GetCurrentBitNo();
> + uint64_t VSTOffset = Stream.GetCurrentBitNo();
> assert((VSTOffset & 31) == 0 && "VST block not 32-bit aligned");
> - stream().BackpatchWord(getVSTOffsetPlaceholder(), VSTOffset / 32);
> + Stream.BackpatchWord(VSTOffsetPlaceholder, VSTOffset / 32);
>
> - stream().EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 4);
> + Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 4);
>
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_COMBINED_GVDEFENTRY));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // sumoffset
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // guid
> - unsigned DefEntryAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned DefEntryAbbrev = Stream.EmitAbbrev(Abbv);
>
> Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_COMBINED_ENTRY));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // refguid
> - unsigned EntryAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned EntryAbbrev = Stream.EmitAbbrev(Abbv);
>
> SmallVector<uint64_t, 64> NameVals;
>
> - for (const auto &FII : *Index) {
> + for (const auto &FII : Index) {
> GlobalValue::GUID FuncGUID = FII.first;
> unsigned ValueId = popValueId(FuncGUID);
>
> @@ -2637,8 +2634,8 @@ void IndexBitcodeWriter::writeCombinedVa
> NameVals.push_back(FuncGUID);
>
> // Emit the finished record.
> - stream().EmitRecord(bitc::VST_CODE_COMBINED_GVDEFENTRY, NameVals,
> - DefEntryAbbrev);
> + Stream.EmitRecord(bitc::VST_CODE_COMBINED_GVDEFENTRY, NameVals,
> + DefEntryAbbrev);
> NameVals.clear();
> }
> }
> @@ -2648,10 +2645,10 @@ void IndexBitcodeWriter::writeCombinedVa
> NameVals.push_back(GVI.first);
>
> // Emit the finished record.
> - stream().EmitRecord(bitc::VST_CODE_COMBINED_ENTRY, NameVals, EntryAbbrev);
> + Stream.EmitRecord(bitc::VST_CODE_COMBINED_ENTRY, NameVals, EntryAbbrev);
> NameVals.clear();
> }
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeUseList(UseListOrder &&Order) {
> @@ -2664,7 +2661,7 @@ void ModuleBitcodeWriter::writeUseList(U
>
> SmallVector<uint64_t, 64> Record(Order.Shuffle.begin(), Order.Shuffle.end());
> Record.push_back(VE.getValueID(Order.V));
> - stream().EmitRecord(Code, Record);
> + Stream.EmitRecord(Code, Record);
> }
>
> void ModuleBitcodeWriter::writeUseListBlock(const Function *F) {
> @@ -2678,12 +2675,12 @@ void ModuleBitcodeWriter::writeUseListBl
> // Nothing to do.
> return;
>
> - stream().EnterSubblock(bitc::USELIST_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::USELIST_BLOCK_ID, 3);
> while (hasMore()) {
> writeUseList(std::move(VE.UseListOrders.back()));
> VE.UseListOrders.pop_back();
> }
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> /// Emit a function body to the module stream.
> @@ -2692,9 +2689,9 @@ void ModuleBitcodeWriter::writeFunction(
> DenseMap<const Function *, uint64_t> &FunctionToBitcodeIndex) {
> // Save the bitcode index of the start of this function block for recording
> // in the VST.
> - FunctionToBitcodeIndex[&F] = stream().GetCurrentBitNo();
> + FunctionToBitcodeIndex[&F] = Stream.GetCurrentBitNo();
>
> - stream().EnterSubblock(bitc::FUNCTION_BLOCK_ID, 4);
> + Stream.EnterSubblock(bitc::FUNCTION_BLOCK_ID, 4);
> VE.incorporateFunction(F);
>
> SmallVector<unsigned, 64> Vals;
> @@ -2702,7 +2699,7 @@ void ModuleBitcodeWriter::writeFunction(
> // Emit the number of basic blocks, so the reader can create them ahead of
> // time.
> Vals.push_back(VE.getBasicBlocks().size());
> - stream().EmitRecord(bitc::FUNC_CODE_DECLAREBLOCKS, Vals);
> + Stream.EmitRecord(bitc::FUNC_CODE_DECLAREBLOCKS, Vals);
> Vals.clear();
>
> // If there are function-local constants, emit them now.
> @@ -2738,7 +2735,7 @@ void ModuleBitcodeWriter::writeFunction(
>
> if (DL == LastDL) {
> // Just repeat the same debug loc as last time.
> - stream().EmitRecord(bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals);
> + Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals);
> continue;
> }
>
> @@ -2746,7 +2743,7 @@ void ModuleBitcodeWriter::writeFunction(
> Vals.push_back(DL->getColumn());
> Vals.push_back(VE.getMetadataOrNullID(DL->getScope()));
> Vals.push_back(VE.getMetadataOrNullID(DL->getInlinedAt()));
> - stream().EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals);
> + Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals);
> Vals.clear();
>
> LastDL = DL;
> @@ -2760,7 +2757,7 @@ void ModuleBitcodeWriter::writeFunction(
> if (VE.shouldPreserveUseListOrder())
> writeUseListBlock(&F);
> VE.purgeFunction();
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> // Emit blockinfo, which defines the standard abbreviations etc.
> @@ -2768,7 +2765,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> // We only want to emit block info records for blocks that have multiple
> // instances: CONSTANTS_BLOCK, FUNCTION_BLOCK and VALUE_SYMTAB_BLOCK.
> // Other blocks can define their abbrevs inline.
> - stream().EnterBlockInfoBlock(2);
> + Stream.EnterBlockInfoBlock(2);
>
> { // 8-bit fixed-width VST_CODE_ENTRY/VST_CODE_BBENTRY strings.
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> @@ -2776,7 +2773,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
> - if (stream().EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> VST_ENTRY_8_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2787,7 +2784,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
> - if (stream().EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> VST_ENTRY_7_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2797,7 +2794,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
> - if (stream().EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> VST_ENTRY_6_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2807,7 +2804,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
> - if (stream().EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, Abbv) !=
> VST_BBENTRY_6_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2819,7 +2816,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_SETTYPE));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
> VE.computeBitsRequiredForTypeIndicies()));
> - if (stream().EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> CONSTANTS_SETTYPE_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2828,7 +2825,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_INTEGER));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> - if (stream().EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> CONSTANTS_INTEGER_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2841,14 +2838,14 @@ void ModuleBitcodeWriter::writeBlockInfo
> VE.computeBitsRequiredForTypeIndicies()));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
>
> - if (stream().EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> CONSTANTS_CE_CAST_Abbrev)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> { // NULL abbrev for CONSTANTS_BLOCK.
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_NULL));
> - if (stream().EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::CONSTANTS_BLOCK_ID, Abbv) !=
> CONSTANTS_NULL_Abbrev)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2863,7 +2860,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> VE.computeBitsRequiredForTypeIndicies()));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Align
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // volatile
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_LOAD_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2873,7 +2870,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_BINOP_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2884,7 +2881,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); // flags
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_BINOP_FLAGS_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2895,7 +2892,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty
> VE.computeBitsRequiredForTypeIndicies()));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_CAST_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2903,7 +2900,7 @@ void ModuleBitcodeWriter::writeBlockInfo
> { // INST_RET abbrev for FUNCTION_BLOCK.
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_RET));
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_RET_VOID_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2911,14 +2908,14 @@ void ModuleBitcodeWriter::writeBlockInfo
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_RET));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ValID
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_RET_VAL_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> { // INST_UNREACHABLE abbrev for FUNCTION_BLOCK.
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_UNREACHABLE));
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_UNREACHABLE_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
> @@ -2930,18 +2927,18 @@ void ModuleBitcodeWriter::writeBlockInfo
> Log2_32_Ceil(VE.getTypes().size() + 1)));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
> - if (stream().EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
> FUNCTION_INST_GEP_ABBREV)
> llvm_unreachable("Unexpected abbrev ordering!");
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> /// Write the module path strings, currently only used when generating
> /// a combined index file.
> void IndexBitcodeWriter::writeModStrings() {
> - stream().EnterSubblock(bitc::MODULE_STRTAB_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::MODULE_STRTAB_BLOCK_ID, 3);
>
> // TODO: See which abbrev sizes we actually need to emit
>
> @@ -2951,7 +2948,7 @@ void IndexBitcodeWriter::writeModStrings
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
> - unsigned Abbrev8Bit = stream().EmitAbbrev(Abbv);
> + unsigned Abbrev8Bit = Stream.EmitAbbrev(Abbv);
>
> // 7-bit fixed width MST_ENTRY strings.
> Abbv = new BitCodeAbbrev();
> @@ -2959,7 +2956,7 @@ void IndexBitcodeWriter::writeModStrings
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
> - unsigned Abbrev7Bit = stream().EmitAbbrev(Abbv);
> + unsigned Abbrev7Bit = Stream.EmitAbbrev(Abbv);
>
> // 6-bit char6 MST_ENTRY strings.
> Abbv = new BitCodeAbbrev();
> @@ -2967,7 +2964,7 @@ void IndexBitcodeWriter::writeModStrings
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
> - unsigned Abbrev6Bit = stream().EmitAbbrev(Abbv);
> + unsigned Abbrev6Bit = Stream.EmitAbbrev(Abbv);
>
> // Module Hash, 160 bits SHA1. Optionally, emitted after each MST_CODE_ENTRY.
> Abbv = new BitCodeAbbrev();
> @@ -2977,10 +2974,10 @@ void IndexBitcodeWriter::writeModStrings
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
> - unsigned AbbrevHash = stream().EmitAbbrev(Abbv);
> + unsigned AbbrevHash = Stream.EmitAbbrev(Abbv);
>
> SmallVector<unsigned, 64> Vals;
> - for (const auto &MPSE : Index->modulePaths()) {
> + for (const auto &MPSE : Index.modulePaths()) {
> StringEncoding Bits =
> getStringEncoding(MPSE.getKey().data(), MPSE.getKey().size());
> unsigned AbbrevToUse = Abbrev8Bit;
> @@ -2995,7 +2992,7 @@ void IndexBitcodeWriter::writeModStrings
> Vals.push_back((unsigned char)P);
>
> // Emit the finished record.
> - stream().EmitRecord(bitc::MST_CODE_ENTRY, Vals, AbbrevToUse);
> + Stream.EmitRecord(bitc::MST_CODE_ENTRY, Vals, AbbrevToUse);
>
> Vals.clear();
> // Emit an optional hash for the module now
> @@ -3008,12 +3005,12 @@ void IndexBitcodeWriter::writeModStrings
> }
> if (!AllZero) {
> // Emit the hash record.
> - stream().EmitRecord(bitc::MST_CODE_HASH, Vals, AbbrevHash);
> + Stream.EmitRecord(bitc::MST_CODE_HASH, Vals, AbbrevHash);
> }
>
> Vals.clear();
> }
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> // Helper to emit a single function summary record.
> @@ -3045,7 +3042,7 @@ void ModuleBitcodeWriter::writePerModule
> (HasProfileData ? bitc::FS_PERMODULE_PROFILE : bitc::FS_PERMODULE);
>
> // Emit the finished record.
> - stream().EmitRecord(Code, NameVals, FSAbbrev);
> + Stream.EmitRecord(Code, NameVals, FSAbbrev);
> NameVals.clear();
> }
>
> @@ -3063,21 +3060,21 @@ void ModuleBitcodeWriter::writeModuleLev
> GlobalVarSummary *VS = cast<GlobalVarSummary>(Info->summary());
> for (auto Ref : VS->refs())
> NameVals.push_back(VE.getValueID(Ref.getValue()));
> - stream().EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
> - FSModRefsAbbrev);
> + Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
> + FSModRefsAbbrev);
> NameVals.clear();
> }
>
> /// Emit the per-module summary section alongside the rest of
> /// the module's bitcode.
> void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
> - if (M->empty())
> + if (M.empty())
> return;
>
> if (Index->begin() == Index->end())
> return;
>
> - stream().EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
>
> // Abbrev for FS_PERMODULE.
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> @@ -3089,7 +3086,7 @@ void ModuleBitcodeWriter::writePerModule
> // numrefs x valueid, n x (valueid, callsitecount)
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> - unsigned FSCallsAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSCallsAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for FS_PERMODULE_PROFILE.
> Abbv = new BitCodeAbbrev();
> @@ -3101,7 +3098,7 @@ void ModuleBitcodeWriter::writePerModule
> // numrefs x valueid, n x (valueid, callsitecount, profilecount)
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> - unsigned FSCallsProfileAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSCallsProfileAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for FS_PERMODULE_GLOBALVAR_INIT_REFS.
> Abbv = new BitCodeAbbrev();
> @@ -3110,7 +3107,7 @@ void ModuleBitcodeWriter::writePerModule
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); // valueids
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> - unsigned FSModRefsAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for FS_ALIAS.
> Abbv = new BitCodeAbbrev();
> @@ -3118,12 +3115,12 @@ void ModuleBitcodeWriter::writePerModule
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
> - unsigned FSAliasAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv);
>
> SmallVector<uint64_t, 64> NameVals;
> // Iterate over the list of functions instead of the Index to
> // ensure the ordering is stable.
> - for (const Function &F : *M) {
> + for (const Function &F : M) {
> if (F.isDeclaration())
> continue;
> // Summary emission does not support anonymous functions, they have to
> @@ -3134,16 +3131,16 @@ void ModuleBitcodeWriter::writePerModule
> auto *Info = Index->getGlobalValueInfo(F);
> writePerModuleFunctionSummaryRecord(
> NameVals, Info,
> - VE.getValueID(M->getValueSymbolTable().lookup(F.getName())),
> + VE.getValueID(M.getValueSymbolTable().lookup(F.getName())),
> FSCallsAbbrev, FSCallsProfileAbbrev, F);
> }
>
> // Capture references from GlobalVariable initializers, which are outside
> // of a function scope.
> - for (const GlobalVariable &G : M->globals())
> + for (const GlobalVariable &G : M.globals())
> writeModuleLevelReferences(G, NameVals, FSModRefsAbbrev);
>
> - for (const GlobalAlias &A : M->aliases()) {
> + for (const GlobalAlias &A : M.aliases()) {
> auto *Aliasee = A.getBaseObject();
> if (!Aliasee->hasName())
> // Nameless function don't have an entry in the summary, skip it.
> @@ -3153,16 +3150,16 @@ void ModuleBitcodeWriter::writePerModule
> NameVals.push_back(AliasId);
> NameVals.push_back(getEncodedLinkage(A.getLinkage()));
> NameVals.push_back(AliaseeId);
> - stream().EmitRecord(bitc::FS_ALIAS, NameVals, FSAliasAbbrev);
> + Stream.EmitRecord(bitc::FS_ALIAS, NameVals, FSAliasAbbrev);
> NameVals.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> /// Emit the combined summary section into the combined index file.
> void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
> - stream().EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
>
> // Abbrev for FS_COMBINED.
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> @@ -3174,7 +3171,7 @@ void IndexBitcodeWriter::writeCombinedGl
> // numrefs x valueid, n x (valueid, callsitecount)
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> - unsigned FSCallsAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSCallsAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for FS_COMBINED_PROFILE.
> Abbv = new BitCodeAbbrev();
> @@ -3186,7 +3183,7 @@ void IndexBitcodeWriter::writeCombinedGl
> // numrefs x valueid, n x (valueid, callsitecount, profilecount)
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> - unsigned FSCallsProfileAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSCallsProfileAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for FS_COMBINED_GLOBALVAR_INIT_REFS.
> Abbv = new BitCodeAbbrev();
> @@ -3195,7 +3192,7 @@ void IndexBitcodeWriter::writeCombinedGl
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); // valueids
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
> - unsigned FSModRefsAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv);
>
> // Abbrev for FS_COMBINED_ALIAS.
> Abbv = new BitCodeAbbrev();
> @@ -3203,7 +3200,7 @@ void IndexBitcodeWriter::writeCombinedGl
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // offset
> - unsigned FSAliasAbbrev = stream().EmitAbbrev(Abbv);
> + unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv);
>
> // The aliases are emitted as a post-pass, and will point to the summary
> // offset id of the aliasee. For this purpose we need to be able to get back
> @@ -3212,7 +3209,7 @@ void IndexBitcodeWriter::writeCombinedGl
> DenseMap<const GlobalValueSummary *, uint64_t> SummaryToOffsetMap;
>
> SmallVector<uint64_t, 64> NameVals;
> - for (const auto &FII : *Index) {
> + for (const auto &FII : Index) {
> for (auto &FI : FII.second) {
> GlobalValueSummary *S = FI->summary();
> assert(S);
> @@ -3224,7 +3221,7 @@ void IndexBitcodeWriter::writeCombinedGl
> }
>
> if (auto *VS = dyn_cast<GlobalVarSummary>(S)) {
> - NameVals.push_back(Index->getModuleId(VS->modulePath()));
> + NameVals.push_back(Index.getModuleId(VS->modulePath()));
> NameVals.push_back(getEncodedLinkage(VS->linkage()));
> for (auto &RI : VS->refs()) {
> NameVals.push_back(getValueId(RI.getGUID()));
> @@ -3233,20 +3230,20 @@ void IndexBitcodeWriter::writeCombinedGl
> // Record the starting offset of this summary entry for use
> // in the VST entry. Add the current code size since the
> // reader will invoke readRecord after the abbrev id read.
> - FI->setBitcodeIndex(stream().GetCurrentBitNo() +
> - stream().GetAbbrevIDWidth());
> + FI->setBitcodeIndex(Stream.GetCurrentBitNo() +
> + Stream.GetAbbrevIDWidth());
> // Store temporarily the offset in the map for a possible alias.
> SummaryToOffsetMap[S] = FI->bitcodeIndex();
>
> // Emit the finished record.
> - stream().EmitRecord(bitc::FS_COMBINED_GLOBALVAR_INIT_REFS, NameVals,
> - FSModRefsAbbrev);
> + Stream.EmitRecord(bitc::FS_COMBINED_GLOBALVAR_INIT_REFS, NameVals,
> + FSModRefsAbbrev);
> NameVals.clear();
> continue;
> }
>
> auto *FS = cast<FunctionSummary>(S);
> - NameVals.push_back(Index->getModuleId(FS->modulePath()));
> + NameVals.push_back(Index.getModuleId(FS->modulePath()));
> NameVals.push_back(getEncodedLinkage(FS->linkage()));
> NameVals.push_back(FS->instCount());
> NameVals.push_back(FS->refs().size());
> @@ -3277,8 +3274,7 @@ void IndexBitcodeWriter::writeCombinedGl
> // Record the starting offset of this summary entry for use
> // in the VST entry. Add the current code size since the
> // reader will invoke readRecord after the abbrev id read.
> - FI->setBitcodeIndex(stream().GetCurrentBitNo() +
> - stream().GetAbbrevIDWidth());
> + FI->setBitcodeIndex(Stream.GetCurrentBitNo() + Stream.GetAbbrevIDWidth());
> // Store temporarily the offset in the map for a possible alias.
> SummaryToOffsetMap[S] = FI->bitcodeIndex();
>
> @@ -3288,14 +3284,14 @@ void IndexBitcodeWriter::writeCombinedGl
> (HasProfileData ? bitc::FS_COMBINED_PROFILE : bitc::FS_COMBINED);
>
> // Emit the finished record.
> - stream().EmitRecord(Code, NameVals, FSAbbrev);
> + Stream.EmitRecord(Code, NameVals, FSAbbrev);
> NameVals.clear();
> }
> }
>
> for (auto GVI : Aliases) {
> AliasSummary *AS = cast<AliasSummary>(GVI->summary());
> - NameVals.push_back(Index->getModuleId(AS->modulePath()));
> + NameVals.push_back(Index.getModuleId(AS->modulePath()));
> NameVals.push_back(getEncodedLinkage(AS->linkage()));
> auto AliaseeOffset = SummaryToOffsetMap[&AS->getAliasee()];
> assert(AliaseeOffset);
> @@ -3304,26 +3300,25 @@ void IndexBitcodeWriter::writeCombinedGl
> // Record the starting offset of this summary entry for use
> // in the VST entry. Add the current code size since the
> // reader will invoke readRecord after the abbrev id read.
> - GVI->setBitcodeIndex(stream().GetCurrentBitNo() +
> - stream().GetAbbrevIDWidth());
> + GVI->setBitcodeIndex(Stream.GetCurrentBitNo() + Stream.GetAbbrevIDWidth());
>
> // Emit the finished record.
> - stream().EmitRecord(bitc::FS_COMBINED_ALIAS, NameVals, FSAliasAbbrev);
> + Stream.EmitRecord(bitc::FS_COMBINED_ALIAS, NameVals, FSAliasAbbrev);
> NameVals.clear();
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeIdentificationBlock() {
> - stream().EnterSubblock(bitc::IDENTIFICATION_BLOCK_ID, 5);
> + Stream.EnterSubblock(bitc::IDENTIFICATION_BLOCK_ID, 5);
>
> // Write the "user readable" string identifying the bitcode producer
> BitCodeAbbrev *Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::IDENTIFICATION_CODE_STRING));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
> - auto StringAbbrev = stream().EmitAbbrev(Abbv);
> + auto StringAbbrev = Stream.EmitAbbrev(Abbv);
> writeStringRecord(bitc::IDENTIFICATION_CODE_STRING,
> "LLVM" LLVM_VERSION_STRING, StringAbbrev);
>
> @@ -3331,18 +3326,18 @@ void ModuleBitcodeWriter::writeIdentific
> Abbv = new BitCodeAbbrev();
> Abbv->Add(BitCodeAbbrevOp(bitc::IDENTIFICATION_CODE_EPOCH));
> Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
> - auto EpochAbbrev = stream().EmitAbbrev(Abbv);
> + auto EpochAbbrev = Stream.EmitAbbrev(Abbv);
> SmallVector<unsigned, 1> Vals = {bitc::BITCODE_CURRENT_EPOCH};
> - stream().EmitRecord(bitc::IDENTIFICATION_CODE_EPOCH, Vals, EpochAbbrev);
> - stream().ExitBlock();
> + Stream.EmitRecord(bitc::IDENTIFICATION_CODE_EPOCH, Vals, EpochAbbrev);
> + Stream.ExitBlock();
> }
>
> void ModuleBitcodeWriter::writeModuleHash(size_t BlockStartPos) {
> // Emit the module's hash.
> // MODULE_CODE_HASH: [5*i32]
> SHA1 Hasher;
> - Hasher.update(ArrayRef<uint8_t>((uint8_t *)&(buffer())[BlockStartPos],
> - buffer().size() - BlockStartPos));
> + Hasher.update(ArrayRef<uint8_t>((uint8_t *)&(Buffer)[BlockStartPos],
> + Buffer.size() - BlockStartPos));
> auto Hash = Hasher.result();
> SmallVector<uint64_t, 20> Vals;
> auto LShift = [&](unsigned char Val, unsigned Amount)
> @@ -3355,7 +3350,7 @@ void ModuleBitcodeWriter::writeModuleHas
> }
>
> // Emit the finished record.
> - stream().EmitRecord(bitc::MODULE_CODE_HASH, Vals);
> + Stream.EmitRecord(bitc::MODULE_CODE_HASH, Vals);
> }
>
> void BitcodeWriter::write() {
> @@ -3376,13 +3371,13 @@ void IndexBitcodeWriter::writeBlocks() {
> }
>
> void ModuleBitcodeWriter::writeModule() {
> - stream().EnterSubblock(bitc::MODULE_BLOCK_ID, 3);
> - size_t BlockStartPos = buffer().size();
> + Stream.EnterSubblock(bitc::MODULE_BLOCK_ID, 3);
> + size_t BlockStartPos = Buffer.size();
>
> SmallVector<unsigned, 1> Vals;
> unsigned CurVersion = 1;
> Vals.push_back(CurVersion);
> - stream().EmitRecord(bitc::MODULE_CODE_VERSION, Vals);
> + Stream.EmitRecord(bitc::MODULE_CODE_VERSION, Vals);
>
> // Emit blockinfo, which defines the standard abbreviations etc.
> writeBlockInfo();
> @@ -3419,7 +3414,7 @@ void ModuleBitcodeWriter::writeModule()
>
> // Emit function bodies.
> DenseMap<const Function *, uint64_t> FunctionToBitcodeIndex;
> - for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F)
> + for (Module::const_iterator F = M.begin(), E = M.end(); F != E; ++F)
> if (!F->isDeclaration())
> writeFunction(*F, FunctionToBitcodeIndex);
>
> @@ -3428,14 +3423,14 @@ void ModuleBitcodeWriter::writeModule()
> if (Index)
> writePerModuleGlobalValueSummary();
>
> - writeValueSymbolTable(M->getValueSymbolTable(),
> + writeValueSymbolTable(M.getValueSymbolTable(),
> /* IsModuleLevel */ true, &FunctionToBitcodeIndex);
>
> if (GenerateHash) {
> writeModuleHash(BlockStartPos);
> }
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> static void writeInt32ToBuffer(uint32_t Value, SmallVectorImpl<char> &Buffer,
> @@ -3506,12 +3501,12 @@ static void emitDarwinBCHeaderAndTrailer
> /// Helper to write the header common to all bitcode files.
> void BitcodeWriter::writeBitcodeHeader() {
> // Emit the file header.
> - stream().Emit((unsigned)'B', 8);
> - stream().Emit((unsigned)'C', 8);
> - stream().Emit(0x0, 4);
> - stream().Emit(0xC, 4);
> - stream().Emit(0xE, 4);
> - stream().Emit(0xD, 4);
> + Stream.Emit((unsigned)'B', 8);
> + Stream.Emit((unsigned)'C', 8);
> + Stream.Emit(0x0, 4);
> + Stream.Emit(0xC, 4);
> + Stream.Emit(0xE, 4);
> + Stream.Emit(0xD, 4);
> }
>
> /// WriteBitcodeToFile - Write the specified module to the specified output
> @@ -3530,8 +3525,8 @@ void llvm::WriteBitcodeToFile(const Modu
> Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0);
>
> // Emit the module into the buffer.
> - ModuleBitcodeWriter ModuleWriter(M, &Buffer, ShouldPreserveUseListOrder,
> - Index, GenerateHash);
> + ModuleBitcodeWriter ModuleWriter(M, Buffer, ShouldPreserveUseListOrder, Index,
> + GenerateHash);
> ModuleWriter.write();
>
> if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
> @@ -3542,12 +3537,12 @@ void llvm::WriteBitcodeToFile(const Modu
> }
>
> void IndexBitcodeWriter::writeIndex() {
> - stream().EnterSubblock(bitc::MODULE_BLOCK_ID, 3);
> + Stream.EnterSubblock(bitc::MODULE_BLOCK_ID, 3);
>
> SmallVector<unsigned, 1> Vals;
> unsigned CurVersion = 1;
> Vals.push_back(CurVersion);
> - stream().EmitRecord(bitc::MODULE_CODE_VERSION, Vals);
> + Stream.EmitRecord(bitc::MODULE_CODE_VERSION, Vals);
>
> // If we have a VST, write the VSTOFFSET record placeholder.
> writeValueSymbolTableForwardDecl();
> @@ -3562,7 +3557,7 @@ void IndexBitcodeWriter::writeIndex() {
> // real VST and real values when this is invoked).
> writeCombinedValueSymbolTable();
>
> - stream().ExitBlock();
> + Stream.ExitBlock();
> }
>
> // Write the specified module summary index to the given raw output stream,
> @@ -3572,7 +3567,7 @@ void llvm::WriteIndexToFile(const Module
> SmallVector<char, 0> Buffer;
> Buffer.reserve(256 * 1024);
>
> - IndexBitcodeWriter IndexWriter(&Buffer, &Index);
> + IndexBitcodeWriter IndexWriter(Buffer, Index);
> IndexWriter.write();
>
> Out.write((char *)&Buffer.front(), Buffer.size());
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list