llvm.org GIT mirror llvm / c9d578a
Revert "Function bitcode index in Value Symbol Table and lazy reading support" Temporarily revert to fix some buildbot issues. One is a minor issue with a variable unused in NDEBUG mode. More concerning are some test failures on win7 that I need to dig into. This reverts commit 4e66a74543459832cfd571db42b4543580ae1d1d. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247898 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 5 years ago
5 changed file(s) with 45 addition(s) and 341 deletion(s). Raw diff Collapse all Expand all
4141
4242 TYPE_BLOCK_ID_NEW,
4343
44 USELIST_BLOCK_ID,
45
46 MODULE_STRTAB_BLOCK_ID,
47 FUNCTION_SUMMARY_BLOCK_ID
44 USELIST_BLOCK_ID
4845 };
4946
5047
7572
7673 MODULE_CODE_GCNAME = 11, // GCNAME: [strchr x N]
7774 MODULE_CODE_COMDAT = 12, // COMDAT: [selection_kind, name]
78
79 MODULE_CODE_VSTOFFSET = 13, // VSTOFFSET: [offset]
8075 };
8176
8277 /// PARAMATTR blocks have code for defining a parameter attribute set.
135130 TST_CODE_ENTRY = 1 // TST_ENTRY: [typeid, namechar x N]
136131 };
137132
138 // Value symbol table codes.
133 // The value symbol table only has one code (VST_ENTRY_CODE).
139134 enum ValueSymtabCodes {
140 VST_CODE_ENTRY = 1, // VST_ENTRY: [valueid, namechar x N]
141 VST_CODE_BBENTRY = 2, // VST_BBENTRY: [bbid, namechar x N]
142 VST_CODE_FNENTRY = 3, // VST_FNENTRY: [valueid, offset, namechar x N]
135 VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N]
136 VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N]
143137 };
144138
145139 enum MetadataCodes {
146146 BitstreamCursor Stream;
147147 uint64_t NextUnreadBit = 0;
148148 bool SeenValueSymbolTable = false;
149 unsigned VSTOffset = 0;
150149
151150 std::vector TypeList;
152151 BitcodeReaderValueList ValueList;
370369 std::error_code parseTypeTable();
371370 std::error_code parseTypeTableBody();
372371
373 ErrorOr recordValue(SmallVectorImpl &Record,
374 unsigned NameIndex, Triple &TT);
375 std::error_code parseValueSymbolTable(unsigned Offset = 0);
372 std::error_code parseValueSymbolTable();
376373 std::error_code parseConstants();
377374 std::error_code rememberAndSkipFunctionBody();
378375 /// Save the positions of the Metadata blocks and skip parsing the blocks.
15851582 }
15861583 }
15871584
1588 /// Associate a value with its name from the given index in the provided record.
1589 ErrorOr BitcodeReader::recordValue(SmallVectorImpl &Record,
1590 unsigned NameIndex, Triple &TT) {
1591 SmallString<128> ValueName;
1592 if (convertToString(Record, NameIndex, ValueName))
1593 return error("Invalid record");
1594 unsigned ValueID = Record[0];
1595 if (ValueID >= ValueList.size() || !ValueList[ValueID])
1596 return error("Invalid record");
1597 Value *V = ValueList[ValueID];
1598
1599 V->setName(StringRef(ValueName.data(), ValueName.size()));
1600 auto *GO = dyn_cast(V);
1601 if (GO) {
1602 if (GO->getComdat() == reinterpret_cast(1)) {
1603 if (TT.isOSBinFormatMachO())
1604 GO->setComdat(nullptr);
1605 else
1606 GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
1607 }
1608 }
1609 return V;
1610 }
1611
1612 /// Parse the value symbol table at either the current parsing location or
1613 /// at the given bit offset if provided.
1614 std::error_code BitcodeReader::parseValueSymbolTable(unsigned Offset) {
1615 uint64_t CurrentBit;
1616 // Pass in the Offset to distinguish between calling for the module-level
1617 // VST (where we want to jump to the VST offset) and the function-level
1618 // VST (where we don't).
1619 if (Offset > 0) {
1620 // Save the current parsing location so we can jump back at the end
1621 // of the VST read.
1622 CurrentBit = Stream.GetCurrentBitNo();
1623 Stream.JumpToBit(Offset * 32);
1624 BitstreamEntry Entry = Stream.advance();
1625 assert(Entry.Kind == BitstreamEntry::SubBlock);
1626 assert(Entry.ID == bitc::VALUE_SYMTAB_BLOCK_ID);
1627 }
1628
1629 // Compute the delta between the bitcode indices in the VST (the word offset
1630 // to the word-aligned ENTER_SUBBLOCK for the function block, and that
1631 // expected by the lazy reader. The reader's EnterSubBlock expects to have
1632 // already read the ENTER_SUBBLOCK code (size getAbbrevIDWidth) and BlockID
1633 // (size BlockIDWidth). Note that we access the stream's AbbrevID width here
1634 // just before entering the VST subblock because: 1) the EnterSubBlock
1635 // changes the AbbrevID width; 2) the VST block is nested within the same
1636 // outer MODULE_BLOCK as the FUNCTION_BLOCKs and therefore have the same
1637 // AbbrevID width before calling EnterSubBlock; and 3) when we want to
1638 // jump to the FUNCTION_BLOCK using this offset later, we don't want
1639 // to rely on the stream's AbbrevID width being that of the MODULE_BLOCK.
1640 unsigned FuncBitcodeOffsetDelta =
1641 Stream.getAbbrevIDWidth() + bitc::BlockIDWidth;
1642
1585 std::error_code BitcodeReader::parseValueSymbolTable() {
16431586 if (Stream.EnterSubBlock(bitc::VALUE_SYMTAB_BLOCK_ID))
16441587 return error("Invalid record");
16451588
16571600 case BitstreamEntry::Error:
16581601 return error("Malformed block");
16591602 case BitstreamEntry::EndBlock:
1660 if (Offset > 0)
1661 Stream.JumpToBit(CurrentBit);
16621603 return std::error_code();
16631604 case BitstreamEntry::Record:
16641605 // The interesting case.
16711612 default: // Default behavior: unknown type.
16721613 break;
16731614 case bitc::VST_CODE_ENTRY: { // VST_ENTRY: [valueid, namechar x N]
1674 ErrorOr ValOrErr = recordValue(Record, 1, TT);
1675 if (std::error_code EC = ValOrErr.getError())
1676 return EC;
1677 ValOrErr.get();
1678 break;
1679 }
1680 case bitc::VST_CODE_FNENTRY: {
1681 // VST_FNENTRY: [valueid, offset, namechar x N]
1682 ErrorOr ValOrErr = recordValue(Record, 2, TT);
1683 if (std::error_code EC = ValOrErr.getError())
1684 return EC;
1685 Value *V = ValOrErr.get();
1686
1687 auto *GO = dyn_cast(V);
1688 if (!GO) {
1689 // If this is an alias, need to get the actual Function object
1690 // it aliases, in order to set up the DeferredFunctionInfo entry below.
1691 auto *GA = dyn_cast(V);
1692 if (GA)
1693 GO = GA->getBaseObject();
1694 assert(GO);
1695 }
1696
1697 uint64_t FuncWordOffset = Record[1];
1698 Function *F = dyn_cast(GO);
1699 assert(F);
1700 uint64_t FuncBitOffset = FuncWordOffset * 32;
1701 DeferredFunctionInfo[F] = FuncBitOffset + FuncBitcodeOffsetDelta;
1702 // Set the NextUnreadBit to point to the last function block.
1703 // Later when parsing is resumed after function materialization,
1704 // we can simply skip that last function block.
1705 if (FuncBitOffset > NextUnreadBit)
1706 NextUnreadBit = FuncBitOffset;
1615 if (convertToString(Record, 1, ValueName))
1616 return error("Invalid record");
1617 unsigned ValueID = Record[0];
1618 if (ValueID >= ValueList.size() || !ValueList[ValueID])
1619 return error("Invalid record");
1620 Value *V = ValueList[ValueID];
1621
1622 V->setName(StringRef(ValueName.data(), ValueName.size()));
1623 if (auto *GO = dyn_cast(V)) {
1624 if (GO->getComdat() == reinterpret_cast(1)) {
1625 if (TT.isOSBinFormatMachO())
1626 GO->setComdat(nullptr);
1627 else
1628 GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
1629 }
1630 }
1631 ValueName.clear();
17071632 break;
17081633 }
17091634 case bitc::VST_CODE_BBENTRY: {
29262851 return EC;
29272852 break;
29282853 case bitc::VALUE_SYMTAB_BLOCK_ID:
2929 if (!SeenValueSymbolTable) {
2930 // Either this is an old form VST without function index and an
2931 // associated VST forward declaration record (which would have caused
2932 // the VST to be jumped to and parsed before it was encountered
2933 // normally in the stream), or there were no function blocks to
2934 // trigger an earlier parsing of the VST.
2935 assert(VSTOffset == 0 || FunctionsWithBodies.empty());
2936 if (std::error_code EC = parseValueSymbolTable())
2937 return EC;
2938 SeenValueSymbolTable = true;
2939 } else {
2940 // We must have had a VST forward declaration record, which caused
2941 // the parser to jump to and parse the VST earlier.
2942 assert(VSTOffset > 0);
2943 if (Stream.SkipBlock())
2944 return error("Invalid record");
2945 }
2854 if (std::error_code EC = parseValueSymbolTable())
2855 return EC;
2856 SeenValueSymbolTable = true;
29462857 break;
29472858 case bitc::CONSTANTS_BLOCK_ID:
29482859 if (std::error_code EC = parseConstants())
29702881 SeenFirstFunctionBody = true;
29712882 }
29722883
2973 if (VSTOffset > 0) {
2974 // If we have a VST forward declaration record, make sure we
2975 // parse the VST now if we haven't already. It is needed to
2976 // set up the DeferredFunctionInfo vector for lazy reading.
2977 if (!SeenValueSymbolTable) {
2978 if (std::error_code EC =
2979 BitcodeReader::parseValueSymbolTable(VSTOffset))
2980 return EC;
2981 SeenValueSymbolTable = true;
2982 return std::error_code();
2983 } else {
2984 // If we have a VST forward declaration record, but have already
2985 // parsed the VST (just above, when the first function body was
2986 // encountered here), then we are resuming the parse after
2987 // materializing functions. The NextUnreadBit points to the start
2988 // of the last function block recorded in the VST (set when
2989 // parsing the VST function entries). Skip it.
2990 if (Stream.SkipBlock())
2991 return error("Invalid record");
2992 continue;
2993 }
2994 }
2995
2996 // Support older bitcode files that did not have the function
2997 // index in the VST, nor a VST forward declaration record.
2998 // Build the DeferredFunctionInfo vector on the fly.
29992884 if (std::error_code EC = rememberAndSkipFunctionBody())
30002885 return EC;
30012886 // Suspend parsing when we reach the function bodies. Subsequent
32983183 if (Record.size() < 1 || Record[0] > ValueList.size())
32993184 return error("Invalid record");
33003185 ValueList.shrinkTo(Record[0]);
3301 break;
3302 /// MODULE_CODE_VSTOFFSET: [offset]
3303 case bitc::MODULE_CODE_VSTOFFSET:
3304 if (Record.size() < 1)
3305 return error("Invalid record");
3306 VSTOffset = Record[0];
33073186 break;
33083187 }
33093188 Record.clear();
47624641 Function *F,
47634642 DenseMap::iterator DeferredFunctionInfoIterator) {
47644643 while (DeferredFunctionInfoIterator->second == 0) {
4765 // This is the fallback handling for the old format bitcode that
4766 // didn't contain the function index in the VST. Assert if we end up
4767 // here for the new format (which is the only time the VSTOffset would
4768 // be non-zero).
4769 assert(VSTOffset == 0);
47704644 if (Stream.AtEndOfStream())
47714645 return error("Could not find function in stream");
47724646 // ParseModule will parse the next body in the stream and set its
573573 }
574574 }
575575
576 /// Write a record that will eventually hold the word offset of the
577 /// module-level VST. For now the offset is 0, which will be backpatched
578 /// after the real VST is written. Returns the bit offset to backpatch.
579 static uint64_t WriteValueSymbolTableForwardDecl(const ValueSymbolTable &VST,
580 BitstreamWriter &Stream) {
581 if (VST.empty()) return 0;
582
583 // Write a placeholder value in for the offset of the real VST,
584 // which is written after the function blocks so that it can include
585 // the offset of each function. The placeholder offset will be
586 // updated when the real VST is written.
587 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
588 Abbv->Add(BitCodeAbbrevOp(bitc::MODULE_CODE_VSTOFFSET));
589 // Blocks are 32-bit aligned, so we can use a 32-bit word offset to
590 // hold the real VST offset. Must use fixed instead of VBR as we don't
591 // know how many VBR chunks to reserve ahead of time.
592 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
593 unsigned VSTOffsetAbbrev = Stream.EmitAbbrev(Abbv);
594
595 // Emit the placeholder
596 ArrayRef Vals = {llvm::bitc::MODULE_CODE_VSTOFFSET, 0};
597 Stream.EmitRecordWithAbbrev(VSTOffsetAbbrev, Vals);
598
599 // Compute and return the bit offset to the placeholder, which will be
600 // patched when the real VST is written. We can simply subtract the 32-bit
601 // fixed size from the current bit number to get the location to backpatch.
602 return Stream.GetCurrentBitNo() - 32;
603 }
604
605 /// Emit top-level description of module, including target triple, inline asm,
606 /// descriptors for global variables, and function prototype info.
607 /// Returns the bit offset to backpatch with the location of the real VST.
608 static uint64_t WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
609 BitstreamWriter &Stream) {
576 // Emit top-level description of module, including target triple, inline asm,
577 // descriptors for global variables, and function prototype info.
578 static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
579 BitstreamWriter &Stream) {
610580 // Emit various pieces of data attached to a module.
611581 if (!M->getTargetTriple().empty())
612582 WriteStringRecord(bitc::MODULE_CODE_TRIPLE, M->getTargetTriple(),
766736 Stream.EmitRecord(bitc::MODULE_CODE_ALIAS, Vals, AbbrevToUse);
767737 Vals.clear();
768738 }
769
770 uint64_t VSTOffsetPlaceholder =
771 WriteValueSymbolTableForwardDecl(M->getValueSymbolTable(), Stream);
772 return VSTOffsetPlaceholder;
773739 }
774740
775741 static uint64_t GetOptimizationFlags(const Value *V) {
21242090 return SE_Fixed7;
21252091 }
21262092
2127 /// Emit names for globals/functions etc. The VSTOffsetPlaceholder,
2128 /// BitcodeStartBit and FunctionIndex are only passed for the module-level
2129 /// VST, where we are including a function bitcode index and need to
2130 /// backpatch the VST forward declaration record.
2131 static void WriteValueSymbolTable(
2132 const ValueSymbolTable &VST, const ValueEnumerator &VE,
2133 BitstreamWriter &Stream, uint64_t VSTOffsetPlaceholder = 0,
2134 uint64_t BitcodeStartBit = 0,
2135 DenseMap *FunctionIndex = nullptr) {
2136 if (VST.empty()) {
2137 // WriteValueSymbolTableForwardDecl should have returned early as
2138 // well. Ensure this handling remains in sync by asserting that
2139 // the placeholder offset is not set.
2140 assert(VSTOffsetPlaceholder == 0);
2141 return;
2142 }
2143
2144 if (VSTOffsetPlaceholder > 0) {
2145 // Get the offset of the VST we are writing, and backpatch it into
2146 // the VST forward declaration record.
2147 uint64_t VSTOffset = Stream.GetCurrentBitNo();
2148 // The BitcodeStartBit was the stream offset of the actual bitcode
2149 // (e.g. excluding any initial darwin header).
2150 VSTOffset -= BitcodeStartBit;
2151 assert((VSTOffset & 31) == 0 && "VST block not 32-bit aligned");
2152 Stream.BackpatchWord(VSTOffsetPlaceholder, VSTOffset / 32);
2153 }
2154
2093 // Emit names for globals/functions etc.
2094 static void WriteValueSymbolTable(const ValueSymbolTable &VST,
2095 const ValueEnumerator &VE,
2096 BitstreamWriter &Stream) {
2097 if (VST.empty()) return;
21552098 Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 4);
2156
2157 // For the module-level VST, add abbrev Ids for the VST_CODE_FNENTRY
2158 // records, which are not used in the per-function VSTs.
2159 unsigned FnEntry8BitAbbrev;
2160 unsigned FnEntry7BitAbbrev;
2161 unsigned FnEntry6BitAbbrev;
2162 if (VSTOffsetPlaceholder > 0) {
2163 // 8-bit fixed-width VST_FNENTRY function strings.
2164 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
2165 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_FNENTRY));
2166 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2167 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2168 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2169 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
2170 FnEntry8BitAbbrev = Stream.EmitAbbrev(Abbv);
2171
2172 // 7-bit fixed width VST_FNENTRY function strings.
2173 Abbv = new BitCodeAbbrev();
2174 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_FNENTRY));
2175 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2176 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2177 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2178 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2179 FnEntry7BitAbbrev = Stream.EmitAbbrev(Abbv);
2180
2181 // 6-bit char6 VST_FNENTRY function strings.
2182 Abbv = new BitCodeAbbrev();
2183 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_FNENTRY));
2184 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2185 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2186 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2187 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
2188 FnEntry6BitAbbrev = Stream.EmitAbbrev(Abbv);
2189 }
21902099
21912100 // FIXME: Set up the abbrev, we know how many values there are!
21922101 // FIXME: We know if the type names can use 7-bit ascii.
21932102 SmallVector NameVals;
21942103
21952104 for (const ValueName &Name : VST) {
2105
21962106 // Figure out the encoding to use for the name.
21972107 StringEncoding Bits =
21982108 getStringEncoding(Name.getKeyData(), Name.getKeyLength());
21992109
22002110 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2201 NameVals.push_back(VE.getValueID(Name.getValue()));
2202
2203 Function *F = dyn_cast(Name.getValue());
2204 if (!F) {
2205 // If value is an alias, need to get the aliased base object to
2206 // see if it is a function.
2207 auto *GA = dyn_cast(Name.getValue());
2208 if (GA && GA->getBaseObject())
2209 F = dyn_cast(GA->getBaseObject());
2210 }
22112111
22122112 // VST_ENTRY: [valueid, namechar x N]
2213 // VST_FNENTRY: [valueid, funcoffset, namechar x N]
22142113 // VST_BBENTRY: [bbid, namechar x N]
22152114 unsigned Code;
22162115 if (isa(Name.getValue())) {
22172116 Code = bitc::VST_CODE_BBENTRY;
22182117 if (Bits == SE_Char6)
22192118 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2220 } else if (F && !F->isDeclaration()) {
2221 // Must be the module-level VST, where we pass in the Index and
2222 // have a VSTOffsetPlaceholder. The function-level VST should not
2223 // contain any Function symbols.
2224 assert(FunctionIndex);
2225 assert(VSTOffsetPlaceholder > 0);
2226
2227 // Save the word offset of the function (from the start of the
2228 // actual bitcode written to the stream).
2229 assert(FunctionIndex->count(F) == 1);
2230 uint64_t BitcodeIndex = (*FunctionIndex)[F] - BitcodeStartBit;
2231 assert((BitcodeIndex & 31) == 0 && "function block not 32-bit aligned");
2232 NameVals.push_back(BitcodeIndex / 32);
2233
2234 Code = bitc::VST_CODE_FNENTRY;
2235 AbbrevToUse = FnEntry8BitAbbrev;
2236 if (Bits == SE_Char6)
2237 AbbrevToUse = FnEntry6BitAbbrev;
2238 else if (Bits == SE_Fixed7)
2239 AbbrevToUse = FnEntry7BitAbbrev;
22402119 } else {
22412120 Code = bitc::VST_CODE_ENTRY;
22422121 if (Bits == SE_Char6)
22452124 AbbrevToUse = VST_ENTRY_7_ABBREV;
22462125 }
22472126
2127 NameVals.push_back(VE.getValueID(Name.getValue()));
22482128 for (const char *P = Name.getKeyData(),
22492129 *E = Name.getKeyData()+Name.getKeyLength(); P != E; ++P)
22502130 NameVals.push_back((unsigned char)*P);
22922172
22932173 /// WriteFunction - Emit a function body to the module stream.
22942174 static void WriteFunction(const Function &F, ValueEnumerator &VE,
2295 BitstreamWriter &Stream,
2296 DenseMap &FunctionIndex) {
2297 // Save the bitcode index of the start of this function block for recording
2298 // in the VST.
2299 uint64_t BitcodeIndex = Stream.GetCurrentBitNo();
2300 FunctionIndex[&F] = BitcodeIndex;
2301
2175 BitstreamWriter &Stream) {
23022176 Stream.EnterSubblock(bitc::FUNCTION_BLOCK_ID, 4);
23032177 VE.incorporateFunction(F);
23042178
25462420
25472421 /// WriteModule - Emit the specified module to the bitstream.
25482422 static void WriteModule(const Module *M, BitstreamWriter &Stream,
2549 bool ShouldPreserveUseListOrder,
2550 uint64_t BitcodeStartBit) {
2423 bool ShouldPreserveUseListOrder) {
25512424 Stream.EnterSubblock(bitc::MODULE_BLOCK_ID, 3);
25522425
25532426 SmallVector Vals;
25742447
25752448 // Emit top-level description of module, including target triple, inline asm,
25762449 // descriptors for global variables, and function prototype info.
2577 uint64_t VSTOffsetPlaceholder = WriteModuleInfo(M, VE, Stream);
2450 WriteModuleInfo(M, VE, Stream);
25782451
25792452 // Emit constants.
25802453 WriteModuleConstants(VE, Stream);
25842457
25852458 // Emit metadata.
25862459 WriteModuleMetadataStore(M, Stream);
2460
2461 // Emit names for globals/functions etc.
2462 WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream);
25872463
25882464 // Emit module-level use-lists.
25892465 if (VE.shouldPreserveUseListOrder())
25902466 WriteUseListBlock(nullptr, VE, Stream);
25912467
25922468 // Emit function bodies.
2593 DenseMap FunctionIndex;
25942469 for (Module::const_iterator F = M->begin(), E = M->end(); F != E; ++F)
25952470 if (!F->isDeclaration())
2596 WriteFunction(*F, VE, Stream, FunctionIndex);
2597
2598 WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream,
2599 VSTOffsetPlaceholder, BitcodeStartBit, &FunctionIndex);
2471 WriteFunction(*F, VE, Stream);
26002472
26012473 Stream.ExitBlock();
26022474 }
26872559 // Emit the module into the buffer.
26882560 {
26892561 BitstreamWriter Stream(Buffer);
2690 // Save the start bit of the actual bitcode, in case there is space
2691 // saved at the start for the darwin header above. The reader stream
2692 // will start at the bitcode, and we need the offset of the VST
2693 // to line up.
2694 uint64_t BitcodeStartBit = Stream.GetCurrentBitNo();
26952562
26962563 // Emit the file header.
26972564 Stream.Emit((unsigned)'B', 8);
27022569 Stream.Emit(0xD, 4);
27032570
27042571 // Emit the module.
2705 WriteModule(M, Stream, ShouldPreserveUseListOrder, BitcodeStartBit);
2572 WriteModule(M, Stream, ShouldPreserveUseListOrder);
27062573 }
27072574
27082575 if (TT.isOSDarwin())
+0
-29
test/Bitcode/vst-forward-declaration.ll less more
None ; RUN: llvm-as < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=BC
1 ; Check for VST forward declaration record and VST function index records.
2
3 ; BC:
4 ; BC:
5 ; BC:
6
7 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
8 ; Check that this round-trips correctly.
9
10 ; ModuleID = ''
11 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
12 target triple = "x86_64-unknown-linux-gnu"
13
14 ; CHECK: define i32 @foo()
15
16 ; Function Attrs: nounwind uwtable
17 define i32 @foo() #0 {
18 entry:
19 ret i32 1
20 }
21
22 ; CHECK: define i32 @bar(i32 %x)
23
24 ; Function Attrs: nounwind uwtable
25 define i32 @bar(i32 %x) #0 {
26 entry:
27 ret i32 %x
28 }
164164 STRINGIFY_CODE(MODULE_CODE, ALIAS)
165165 STRINGIFY_CODE(MODULE_CODE, PURGEVALS)
166166 STRINGIFY_CODE(MODULE_CODE, GCNAME)
167 STRINGIFY_CODE(MODULE_CODE, VSTOFFSET)
168167 }
169168 case bitc::PARAMATTR_BLOCK_ID:
170169 switch (CodeID) {
266265 default: return nullptr;
267266 STRINGIFY_CODE(VST_CODE, ENTRY)
268267 STRINGIFY_CODE(VST_CODE, BBENTRY)
269 STRINGIFY_CODE(VST_CODE, FNENTRY)
270268 }
271269 case bitc::METADATA_ATTACHMENT_ID:
272270 switch(CodeID) {