llvm.org GIT mirror llvm / 9dd98c0
Clang format a few prior patches (NFC) I had clang formatted my earlier patches using the wrong style. Reformatted with the LLVM style. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251812 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 4 years ago
12 changed file(s) with 345 addition(s) and 304 deletion(s). Raw diff Collapse all Expand all
7272 reinterpret_cast(&Value + 1));
7373 }
7474
75 size_t GetBufferOffset() const {
76 return Out.size();
77 }
75 size_t GetBufferOffset() const { return Out.size(); }
7876
7977 size_t GetWordIndex() const {
8078 size_t Offset = GetBufferOffset();
6767 /// the index. Otherwise skip the function summary section, and only create
6868 /// an index object with a map from function name to function summary offset.
6969 /// The index is used to perform lazy function summary reading later.
70 ErrorOr> getFunctionInfoIndex(
71 MemoryBufferRef Buffer, LLVMContext &Context,
72 DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy = false);
70 ErrorOr>
71 getFunctionInfoIndex(MemoryBufferRef Buffer, LLVMContext &Context,
72 DiagnosticHandlerFunction DiagnosticHandler,
73 bool IsLazy = false);
7374
7475 /// This method supports lazy reading of function summary data from the
7576 /// combined index during function importing. When reading the combined index
7778 /// Then this method is called for each function considered for importing,
7879 /// to parse the summary information for the given function name into
7980 /// the index.
80 std::error_code readFunctionSummary(
81 MemoryBufferRef Buffer, LLVMContext &Context,
82 DiagnosticHandlerFunction DiagnosticHandler, StringRef FunctionName,
83 std::unique_ptr Index);
81 std::error_code
82 readFunctionSummary(MemoryBufferRef Buffer, LLVMContext &Context,
83 DiagnosticHandlerFunction DiagnosticHandler,
84 StringRef FunctionName,
85 std::unique_ptr Index);
8486
8587 /// \brief Write the specified module to the specified raw output stream.
8688 ///
2929 /// This is a separate class from FunctionInfo to enable lazy reading of this
3030 /// function summary information from the combined index file during imporing.
3131 class FunctionSummary {
32 private:
32 private:
3333 /// \brief Path of module containing function IR, used to locate module when
3434 /// importing this function.
3535 ///
5656 /// during the initial compile step when the function index is first built.
5757 unsigned InstCount;
5858
59 public:
59 public:
6060 /// Construct a summary object from summary data expected for all
6161 /// summary records.
6262 FunctionSummary(unsigned NumInsts) : InstCount(NumInsts) {}
8989 /// record. After parsing the associated summary information from the summary
9090 /// block the \a FunctionSummary is populated and stored here.
9191 class FunctionInfo {
92 private:
92 private:
9393 /// Function summary information used to help make ThinLTO importing
9494 /// decisions.
9595 std::unique_ptr Summary;
108108 /// VST records with the summary records.
109109 uint64_t BitcodeIndex;
110110
111 public:
111 public:
112112 /// Constructor used during parsing of VST entries.
113113 FunctionInfo(uint64_t FuncOffset)
114114 : Summary(nullptr), BitcodeIndex(FuncOffset) {}
156156 /// Class to hold module path string table and function map,
157157 /// and encapsulate methods for operating on them.
158158 class FunctionInfoIndex {
159 private:
159 private:
160160 /// Map from function name to list of function information instances
161161 /// for functions of that name (may be duplicates in the COMDAT case, e.g.).
162162 FunctionInfoMapTy FunctionMap;
164164 /// Holds strings for combined index, mapping to the corresponding module ID.
165165 ModulePathStringTableTy ModulePathStringTable;
166166
167 public:
167 public:
168168 FunctionInfoIndex() = default;
169169 ~FunctionInfoIndex() = default;
170170
189189 }
190190
191191 /// Iterator to allow writer to walk through table during emission.
192 iterator_range::const_iterator> modPathStringEntries()
193 const {
192 iterator_range::const_iterator>
193 modPathStringEntries() const {
194194 return llvm::make_range(ModulePathStringTable.begin(),
195195 ModulePathStringTable.end());
196196 }
224224 }
225225 };
226226
227 } // End llvm namespace
227 } // End llvm namespace
228228
229229 #endif
4141 ID_Archive,
4242 ID_MachOUniversalBinary,
4343 ID_COFFImportFile,
44 ID_IR, // LLVM IR
44 ID_IR, // LLVM IR
4545 ID_FunctionIndex, // Function summary index
4646
4747 // Object and children.
122122 return TypeID == ID_IR;
123123 }
124124
125 bool isFunctionIndex() const {
126 return TypeID == ID_FunctionIndex;
127 }
125 bool isFunctionIndex() const { return TypeID == ID_FunctionIndex; }
128126
129127 bool isLittleEndian() const {
130128 return !(TypeID == ID_ELF32B || TypeID == ID_ELF64B ||
2828 class FunctionIndexObjectFile : public SymbolicFile {
2929 std::unique_ptr Index;
3030
31 public:
31 public:
3232 FunctionIndexObjectFile(MemoryBufferRef Object,
3333 std::unique_ptr I);
3434 ~FunctionIndexObjectFile() override;
7171 /// \brief Finds and returns bitcode in the given memory buffer (which may
7272 /// be either a bitcode file or a native object file with embedded bitcode),
7373 /// or an error code if not found.
74 static ErrorOr findBitcodeInMemBuffer(
75 MemoryBufferRef Object);
74 static ErrorOr
75 findBitcodeInMemBuffer(MemoryBufferRef Object);
7676
7777 /// \brief Looks for function summary in the given memory buffer,
7878 /// returns true if found, else false.
8282 /// \brief Parse function index in the given memory buffer.
8383 /// Return new FunctionIndexObjectFile instance containing parsed function
8484 /// summary/index.
85 static ErrorOr> create(
86 MemoryBufferRef Object, LLVMContext &Context, bool IsLazy = false);
85 static ErrorOr>
86 create(MemoryBufferRef Object, LLVMContext &Context, bool IsLazy = false);
8787
8888 /// \brief Parse the function summary information for function with the
8989 /// given name out of the given buffer. Parsed information is
455455 /// summary records.
456456 DenseMap ModuleIdMap;
457457
458 public:
458 public:
459459 std::error_code error(BitcodeError E, const Twine &Message);
460460 std::error_code error(BitcodeError E);
461461 std::error_code error(const Twine &Message);
487487 FunctionInfoIndex *I,
488488 size_t FunctionSummaryOffset);
489489
490 private:
490 private:
491491 std::error_code parseModule();
492492 std::error_code parseValueSymbolTable();
493493 std::error_code parseEntireSummary();
30513051 std::error_code BitcodeReader::rememberAndSkipFunctionBodies() {
30523052 Stream.JumpToBit(NextUnreadBit);
30533053
3054 if (Stream.AtEndOfStream()) return error("Could not find function in stream");
3054 if (Stream.AtEndOfStream())
3055 return error("Could not find function in stream");
30553056
30563057 assert(SeenFirstFunctionBody);
30573058 // An old bitcode file with the symbol table at the end would have
30633064 while (1) {
30643065 BitstreamEntry Entry = Stream.advance();
30653066 switch (Entry.Kind) {
3067 default:
3068 return error("Expect SubBlock");
3069 case BitstreamEntry::SubBlock:
3070 switch (Entry.ID) {
30663071 default:
3067 return error("Expect SubBlock");
3068 case BitstreamEntry::SubBlock:
3069 switch (Entry.ID) {
3070 default:
3071 return error("Expect function block");
3072 case bitc::FUNCTION_BLOCK_ID:
3073 if (std::error_code EC = rememberAndSkipFunctionBody()) return EC;
3074 NextUnreadBit = Stream.GetCurrentBitNo();
3075 return std::error_code();
3076 }
3072 return error("Expect function block");
3073 case bitc::FUNCTION_BLOCK_ID:
3074 if (std::error_code EC = rememberAndSkipFunctionBody())
3075 return EC;
3076 NextUnreadBit = Stream.GetCurrentBitNo();
3077 return std::error_code();
3078 }
30773079 }
30783080 }
30793081 }
35993601 return EC;
36003602
36013603 // Sniff for the signature.
3602 if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
3604 if (!hasValidBitcodeHeader(Stream))
3605 return error("Invalid bitcode signature");
36033606
36043607 // We expect a number of well-defined blocks, though we don't necessarily
36053608 // need to understand them all.
36713674 return EC;
36723675
36733676 // Sniff for the signature.
3674 if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
3677 if (!hasValidBitcodeHeader(Stream))
3678 return error("Invalid bitcode signature");
36753679
36763680 // We expect a number of well-defined blocks, though we don't necessarily
36773681 // need to understand them all.
50805084 assert(VSTOffset == 0 || !F->hasName());
50815085 // Parse the next body in the stream and set its position in the
50825086 // DeferredFunctionInfo map.
5083 if (std::error_code EC = rememberAndSkipFunctionBodies()) return EC;
5087 if (std::error_code EC = rememberAndSkipFunctionBodies())
5088 return EC;
50845089 }
50855090 return std::error_code();
50865091 }
52855290 DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy,
52865291 bool CheckFuncSummaryPresenceOnly)
52875292 : DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
5288 Buffer(Buffer),
5289 IsLazy(IsLazy),
5293 Buffer(Buffer), IsLazy(IsLazy),
52905294 CheckFuncSummaryPresenceOnly(CheckFuncSummaryPresenceOnly) {}
52915295
52925296 FunctionIndexBitcodeReader::FunctionIndexBitcodeReader(
52935297 LLVMContext &Context, DiagnosticHandlerFunction DiagnosticHandler,
52945298 bool IsLazy, bool CheckFuncSummaryPresenceOnly)
52955299 : DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
5296 Buffer(nullptr),
5297 IsLazy(IsLazy),
5300 Buffer(nullptr), IsLazy(IsLazy),
52985301 CheckFuncSummaryPresenceOnly(CheckFuncSummaryPresenceOnly) {}
52995302
53005303 void FunctionIndexBitcodeReader::freeState() { Buffer = nullptr; }
53195322 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
53205323
53215324 switch (Entry.Kind) {
5322 case BitstreamEntry::SubBlock: // Handled for us already.
5323 case BitstreamEntry::Error:
5324 return error("Malformed block");
5325 case BitstreamEntry::EndBlock:
5326 return std::error_code();
5327 case BitstreamEntry::Record:
5328 // The interesting case.
5329 break;
5325 case BitstreamEntry::SubBlock: // Handled for us already.
5326 case BitstreamEntry::Error:
5327 return error("Malformed block");
5328 case BitstreamEntry::EndBlock:
5329 return std::error_code();
5330 case BitstreamEntry::Record:
5331 // The interesting case.
5332 break;
53305333 }
53315334
53325335 // Read a record.
53335336 Record.clear();
53345337 switch (Stream.readRecord(Entry.ID, Record)) {
5335 default: // Default behavior: ignore (e.g. VST_CODE_BBENTRY records).
5336 break;
5337 case bitc::VST_CODE_FNENTRY: {
5338 // VST_FNENTRY: [valueid, offset, namechar x N]
5339 if (convertToString(Record, 2, ValueName))
5340 return error("Invalid record");
5341 unsigned ValueID = Record[0];
5342 uint64_t FuncOffset = Record[1];
5343 std::unique_ptr FuncInfo =
5344 llvm::make_unique(FuncOffset);
5345 if (foundFuncSummary() && !IsLazy) {
5346 DenseMap>::iterator SMI =
5347 SummaryMap.find(ValueID);
5348 assert(SMI != SummaryMap.end() && "Summary info not found");
5349 FuncInfo->setFunctionSummary(std::move(SMI->second));
5350 }
5351 TheIndex->addFunctionInfo(ValueName, std::move(FuncInfo));
5352
5353 ValueName.clear();
5354 break;
5355 }
5356 case bitc::VST_CODE_COMBINED_FNENTRY: {
5357 // VST_FNENTRY: [offset, namechar x N]
5358 if (convertToString(Record, 1, ValueName))
5359 return error("Invalid record");
5360 uint64_t FuncSummaryOffset = Record[0];
5361 std::unique_ptr FuncInfo =
5362 llvm::make_unique(FuncSummaryOffset);
5363 if (foundFuncSummary() && !IsLazy) {
5364 DenseMap>::iterator SMI =
5365 SummaryMap.find(FuncSummaryOffset);
5366 assert(SMI != SummaryMap.end() && "Summary info not found");
5367 FuncInfo->setFunctionSummary(std::move(SMI->second));
5368 }
5369 TheIndex->addFunctionInfo(ValueName, std::move(FuncInfo));
5370
5371 ValueName.clear();
5372 break;
5373 }
5338 default: // Default behavior: ignore (e.g. VST_CODE_BBENTRY records).
5339 break;
5340 case bitc::VST_CODE_FNENTRY: {
5341 // VST_FNENTRY: [valueid, offset, namechar x N]
5342 if (convertToString(Record, 2, ValueName))
5343 return error("Invalid record");
5344 unsigned ValueID = Record[0];
5345 uint64_t FuncOffset = Record[1];
5346 std::unique_ptr FuncInfo =
5347 llvm::make_unique(FuncOffset);
5348 if (foundFuncSummary() && !IsLazy) {
5349 DenseMap>::iterator SMI =
5350 SummaryMap.find(ValueID);
5351 assert(SMI != SummaryMap.end() && "Summary info not found");
5352 FuncInfo->setFunctionSummary(std::move(SMI->second));
5353 }
5354 TheIndex->addFunctionInfo(ValueName, std::move(FuncInfo));
5355
5356 ValueName.clear();
5357 break;
5358 }
5359 case bitc::VST_CODE_COMBINED_FNENTRY: {
5360 // VST_FNENTRY: [offset, namechar x N]
5361 if (convertToString(Record, 1, ValueName))
5362 return error("Invalid record");
5363 uint64_t FuncSummaryOffset = Record[0];
5364 std::unique_ptr FuncInfo =
5365 llvm::make_unique(FuncSummaryOffset);
5366 if (foundFuncSummary() && !IsLazy) {
5367 DenseMap>::iterator SMI =
5368 SummaryMap.find(FuncSummaryOffset);
5369 assert(SMI != SummaryMap.end() && "Summary info not found");
5370 FuncInfo->setFunctionSummary(std::move(SMI->second));
5371 }
5372 TheIndex->addFunctionInfo(ValueName, std::move(FuncInfo));
5373
5374 ValueName.clear();
5375 break;
5376 }
53745377 }
53755378 }
53765379 }
53905393 BitstreamEntry Entry = Stream.advance();
53915394
53925395 switch (Entry.Kind) {
5393 case BitstreamEntry::Error:
5394 return error("Malformed block");
5395 case BitstreamEntry::EndBlock:
5396 case BitstreamEntry::Error:
5397 return error("Malformed block");
5398 case BitstreamEntry::EndBlock:
5399 return std::error_code();
5400
5401 case BitstreamEntry::SubBlock:
5402 if (CheckFuncSummaryPresenceOnly) {
5403 if (Entry.ID == bitc::FUNCTION_SUMMARY_BLOCK_ID)
5404 SeenFuncSummary = true;
5405 if (Stream.SkipBlock())
5406 return error("Invalid record");
5407 // No need to parse the rest since we found the summary.
53965408 return std::error_code();
5397
5398 case BitstreamEntry::SubBlock:
5399 if (CheckFuncSummaryPresenceOnly) {
5400 if (Entry.ID == bitc::FUNCTION_SUMMARY_BLOCK_ID)
5401 SeenFuncSummary = true;
5402 if (Stream.SkipBlock()) return error("Invalid record");
5403 // No need to parse the rest since we found the summary.
5404 return std::error_code();
5405 }
5406 switch (Entry.ID) {
5407 default: // Skip unknown content.
5408 if (Stream.SkipBlock()) return error("Invalid record");
5409 break;
5410 case bitc::BLOCKINFO_BLOCK_ID:
5411 // Need to parse these to get abbrev ids (e.g. for VST)
5412 if (Stream.ReadBlockInfoBlock()) return error("Malformed block");
5413 break;
5414 case bitc::VALUE_SYMTAB_BLOCK_ID:
5415 if (std::error_code EC = parseValueSymbolTable()) return EC;
5416 break;
5417 case bitc::FUNCTION_SUMMARY_BLOCK_ID:
5418 SeenFuncSummary = true;
5419 if (IsLazy) {
5420 // Lazy parsing of summary info, skip it.
5421 if (Stream.SkipBlock()) return error("Invalid record");
5422 } else if (std::error_code EC = parseEntireSummary())
5423 return EC;
5424 break;
5425 case bitc::MODULE_STRTAB_BLOCK_ID:
5426 if (std::error_code EC = parseModuleStringTable()) return EC;
5427 break;
5428 }
5429 continue;
5430
5431 case BitstreamEntry::Record:
5432 Stream.skipRecord(Entry.ID);
5433 continue;
5409 }
5410 switch (Entry.ID) {
5411 default: // Skip unknown content.
5412 if (Stream.SkipBlock())
5413 return error("Invalid record");
5414 break;
5415 case bitc::BLOCKINFO_BLOCK_ID:
5416 // Need to parse these to get abbrev ids (e.g. for VST)
5417 if (Stream.ReadBlockInfoBlock())
5418 return error("Malformed block");
5419 break;
5420 case bitc::VALUE_SYMTAB_BLOCK_ID:
5421 if (std::error_code EC = parseValueSymbolTable())
5422 return EC;
5423 break;
5424 case bitc::FUNCTION_SUMMARY_BLOCK_ID:
5425 SeenFuncSummary = true;
5426 if (IsLazy) {
5427 // Lazy parsing of summary info, skip it.
5428 if (Stream.SkipBlock())
5429 return error("Invalid record");
5430 } else if (std::error_code EC = parseEntireSummary())
5431 return EC;
5432 break;
5433 case bitc::MODULE_STRTAB_BLOCK_ID:
5434 if (std::error_code EC = parseModuleStringTable())
5435 return EC;
5436 break;
5437 }
5438 continue;
5439
5440 case BitstreamEntry::Record:
5441 Stream.skipRecord(Entry.ID);
5442 continue;
54345443 }
54355444 }
54365445 }
54485457 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
54495458
54505459 switch (Entry.Kind) {
5451 case BitstreamEntry::SubBlock: // Handled for us already.
5452 case BitstreamEntry::Error:
5453 return error("Malformed block");
5454 case BitstreamEntry::EndBlock:
5455 return std::error_code();
5456 case BitstreamEntry::Record:
5457 // The interesting case.
5458 break;
5460 case BitstreamEntry::SubBlock: // Handled for us already.
5461 case BitstreamEntry::Error:
5462 return error("Malformed block");
5463 case BitstreamEntry::EndBlock:
5464 return std::error_code();
5465 case BitstreamEntry::Record:
5466 // The interesting case.
5467 break;
54595468 }
54605469
54615470 // Read a record. The record format depends on whether this
54685477 Record.clear();
54695478 uint64_t CurRecordBit = Stream.GetCurrentBitNo();
54705479 switch (Stream.readRecord(Entry.ID, Record)) {
5471 default: // Default behavior: ignore.
5472 break;
5473 // FS_PERMODULE_ENTRY: [valueid, islocal, instcount]
5474 case bitc::FS_CODE_PERMODULE_ENTRY: {
5475 unsigned ValueID = Record[0];
5476 bool IsLocal = Record[1];
5477 unsigned InstCount = Record[2];
5478 std::unique_ptr FS =
5479 llvm::make_unique(InstCount);
5480 FS->setLocalFunction(IsLocal);
5481 // The module path string ref set in the summary must be owned by the
5482 // index's module string table. Since we don't have a module path
5483 // string table section in the per-module index, we create a single
5484 // module path string table entry with an empty (0) ID to take
5485 // ownership.
5486 FS->setModulePath(
5487 TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0));
5488 SummaryMap[ValueID] = std::move(FS);
5489 }
5490 // FS_COMBINED_ENTRY: [modid, instcount]
5491 case bitc::FS_CODE_COMBINED_ENTRY: {
5492 uint64_t ModuleId = Record[0];
5493 unsigned InstCount = Record[1];
5494 std::unique_ptr FS =
5495 llvm::make_unique(InstCount);
5496 FS->setModulePath(ModuleIdMap[ModuleId]);
5497 SummaryMap[CurRecordBit] = std::move(FS);
5498 }
5480 default: // Default behavior: ignore.
5481 break;
5482 // FS_PERMODULE_ENTRY: [valueid, islocal, instcount]
5483 case bitc::FS_CODE_PERMODULE_ENTRY: {
5484 unsigned ValueID = Record[0];
5485 bool IsLocal = Record[1];
5486 unsigned InstCount = Record[2];
5487 std::unique_ptr FS =
5488 llvm::make_unique(InstCount);
5489 FS->setLocalFunction(IsLocal);
5490 // The module path string ref set in the summary must be owned by the
5491 // index's module string table. Since we don't have a module path
5492 // string table section in the per-module index, we create a single
5493 // module path string table entry with an empty (0) ID to take
5494 // ownership.
5495 FS->setModulePath(
5496 TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0));
5497 SummaryMap[ValueID] = std::move(FS);
5498 }
5499 // FS_COMBINED_ENTRY: [modid, instcount]
5500 case bitc::FS_CODE_COMBINED_ENTRY: {
5501 uint64_t ModuleId = Record[0];
5502 unsigned InstCount = Record[1];
5503 std::unique_ptr FS =
5504 llvm::make_unique(InstCount);
5505 FS->setModulePath(ModuleIdMap[ModuleId]);
5506 SummaryMap[CurRecordBit] = std::move(FS);
5507 }
54995508 }
55005509 }
55015510 llvm_unreachable("Exit infinite loop");
55145523 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
55155524
55165525 switch (Entry.Kind) {
5517 case BitstreamEntry::SubBlock: // Handled for us already.
5518 case BitstreamEntry::Error:
5519 return error("Malformed block");
5520 case BitstreamEntry::EndBlock:
5521 return std::error_code();
5522 case BitstreamEntry::Record:
5523 // The interesting case.
5524 break;
5526 case BitstreamEntry::SubBlock: // Handled for us already.
5527 case BitstreamEntry::Error:
5528 return error("Malformed block");
5529 case BitstreamEntry::EndBlock:
5530 return std::error_code();
5531 case BitstreamEntry::Record:
5532 // The interesting case.
5533 break;
55255534 }
55265535
55275536 Record.clear();
55285537 switch (Stream.readRecord(Entry.ID, Record)) {
5529 default: // Default behavior: ignore.
5530 break;
5531 case bitc::MST_CODE_ENTRY: {
5532 // MST_ENTRY: [modid, namechar x N]
5533 if (convertToString(Record, 1, ModulePath))
5534 return error("Invalid record");
5535 uint64_t ModuleId = Record[0];
5536 StringRef ModulePathInMap =
5537 TheIndex->addModulePath(ModulePath, ModuleId);
5538 ModuleIdMap[ModuleId] = ModulePathInMap;
5539 ModulePath.clear();
5540 break;
5541 }
5538 default: // Default behavior: ignore.
5539 break;
5540 case bitc::MST_CODE_ENTRY: {
5541 // MST_ENTRY: [modid, namechar x N]
5542 if (convertToString(Record, 1, ModulePath))
5543 return error("Invalid record");
5544 uint64_t ModuleId = Record[0];
5545 StringRef ModulePathInMap = TheIndex->addModulePath(ModulePath, ModuleId);
5546 ModuleIdMap[ModuleId] = ModulePathInMap;
5547 ModulePath.clear();
5548 break;
5549 }
55425550 }
55435551 }
55445552 llvm_unreachable("Exit infinite loop");
55495557 std::unique_ptr Streamer, FunctionInfoIndex *I) {
55505558 TheIndex = I;
55515559
5552 if (std::error_code EC = initStream(std::move(Streamer))) return EC;
5560 if (std::error_code EC = initStream(std::move(Streamer)))
5561 return EC;
55535562
55545563 // Sniff for the signature.
5555 if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
5564 if (!hasValidBitcodeHeader(Stream))
5565 return error("Invalid bitcode signature");
55565566
55575567 // We expect a number of well-defined blocks, though we don't necessarily
55585568 // need to understand them all.
55655575 BitstreamEntry Entry =
55665576 Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs);
55675577
5568 if (Entry.Kind != BitstreamEntry::SubBlock) return error("Malformed block");
5578 if (Entry.Kind != BitstreamEntry::SubBlock)
5579 return error("Malformed block");
55695580
55705581 // If we see a MODULE_BLOCK, parse it to find the blocks needed for
55715582 // building the function summary index.
5572 if (Entry.ID == bitc::MODULE_BLOCK_ID) return parseModule();
5573
5574 if (Stream.SkipBlock()) return error("Invalid record");
5583 if (Entry.ID == bitc::MODULE_BLOCK_ID)
5584 return parseModule();
5585
5586 if (Stream.SkipBlock())
5587 return error("Invalid record");
55755588 }
55765589 }
55775590
55855598 size_t FunctionSummaryOffset) {
55865599 TheIndex = I;
55875600
5588 if (std::error_code EC = initStream(std::move(Streamer))) return EC;
5601 if (std::error_code EC = initStream(std::move(Streamer)))
5602 return EC;
55895603
55905604 // Sniff for the signature.
5591 if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
5605 if (!hasValidBitcodeHeader(Stream))
5606 return error("Invalid bitcode signature");
55925607
55935608 Stream.JumpToBit(FunctionSummaryOffset);
55945609
55955610 BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
55965611
55975612 switch (Entry.Kind) {
5598 default:
5599 return error("Malformed block");
5600 case BitstreamEntry::Record:
5601 // The expected case.
5602 break;
5613 default:
5614 return error("Malformed block");
5615 case BitstreamEntry::Record:
5616 // The expected case.
5617 break;
56035618 }
56045619
56055620 // TODO: Read a record. This interface will be completed when ThinLTO
56065621 // importing is added so that it can be tested.
56075622 SmallVector Record;
56085623 switch (Stream.readRecord(Entry.ID, Record)) {
5609 case bitc::FS_CODE_COMBINED_ENTRY:
5610 default:
5611 return error("Invalid record");
5624 case bitc::FS_CODE_COMBINED_ENTRY:
5625 default:
5626 return error("Invalid record");
56125627 }
56135628
56145629 return std::error_code();
56155630 }
56165631
5617 std::error_code FunctionIndexBitcodeReader::initStream(
5618 std::unique_ptr Streamer) {
5619 if (Streamer) return initLazyStream(std::move(Streamer));
5632 std::error_code
5633 FunctionIndexBitcodeReader::initStream(std::unique_ptr Streamer) {
5634 if (Streamer)
5635 return initLazyStream(std::move(Streamer));
56205636 return initStreamFromBuffer();
56215637 }
56225638
56245640 const unsigned char *BufPtr = (const unsigned char *)Buffer->getBufferStart();
56255641 const unsigned char *BufEnd = BufPtr + Buffer->getBufferSize();
56265642
5627 if (Buffer->getBufferSize() & 3) return error("Invalid bitcode signature");
5643 if (Buffer->getBufferSize() & 3)
5644 return error("Invalid bitcode signature");
56285645
56295646 // If we have a wrapper header, parse it and ignore the non-bc file contents.
56305647 // The magic number is 0x0B17C0DE stored in little endian.
56525669 if (Bytes.readBytes(buf, 16, 0) != 16)
56535670 return error("Invalid bitcode signature");
56545671
5655 if (!isBitcode(buf, buf + 16)) return error("Invalid bitcode signature");
5672 if (!isBitcode(buf, buf + 16))
5673 return error("Invalid bitcode signature");
56565674
56575675 if (isBitcodeWrapper(buf, buf + 4)) {
56585676 const unsigned char *bitcodeStart = buf;
57915809 // the index. Otherwise skip the function summary section, and only create
57925810 // an index object with a map from function name to function summary offset.
57935811 // The index is used to perform lazy function summary reading later.
5794 ErrorOr> llvm::getFunctionInfoIndex(
5795 MemoryBufferRef Buffer, LLVMContext &Context,
5796 DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy) {
5812 ErrorOr>
5813 llvm::getFunctionInfoIndex(MemoryBufferRef Buffer, LLVMContext &Context,
5814 DiagnosticHandlerFunction DiagnosticHandler,
5815 bool IsLazy) {
57975816 std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Buffer, false);
57985817 FunctionIndexBitcodeReader R(Buf.get(), Context, DiagnosticHandler, IsLazy);
57995818
58015820 llvm::make_unique();
58025821
58035822 auto cleanupOnError = [&](std::error_code EC) {
5804 R.releaseBuffer(); // Never take ownership on error.
5823 R.releaseBuffer(); // Never take ownership on error.
58055824 return EC;
58065825 };
58075826
58085827 if (std::error_code EC = R.parseSummaryIndexInto(nullptr, Index.get()))
58095828 return cleanupOnError(EC);
58105829
5811 Buf.release(); // The FunctionIndexBitcodeReader owns it now.
5830 Buf.release(); // The FunctionIndexBitcodeReader owns it now.
58125831 return std::move(Index);
58135832 }
58145833
58205839 true);
58215840
58225841 auto cleanupOnError = [&](std::error_code EC) {
5823 R.releaseBuffer(); // Never take ownership on error.
5842 R.releaseBuffer(); // Never take ownership on error.
58245843 return false;
58255844 };
58265845
58275846 if (std::error_code EC = R.parseSummaryIndexInto(nullptr, nullptr))
58285847 return cleanupOnError(EC);
58295848
5830 Buf.release(); // The FunctionIndexBitcodeReader owns it now.
5849 Buf.release(); // The FunctionIndexBitcodeReader owns it now.
58315850 return R.foundFuncSummary();
58325851 }
58335852
58375856 // Then this method is called for each function considered for importing,
58385857 // to parse the summary information for the given function name into
58395858 // the index.
5840 std::error_code llvm::readFunctionSummary(
5841 MemoryBufferRef Buffer, LLVMContext &Context,
5842 DiagnosticHandlerFunction DiagnosticHandler, StringRef FunctionName,
5843 std::unique_ptr Index) {
5859 std::error_code
5860 llvm::readFunctionSummary(MemoryBufferRef Buffer, LLVMContext &Context,
5861 DiagnosticHandlerFunction DiagnosticHandler,
5862 StringRef FunctionName,
5863 std::unique_ptr Index) {
58445864 std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Buffer, false);
58455865 FunctionIndexBitcodeReader R(Buf.get(), Context, DiagnosticHandler);
58465866
58475867 auto cleanupOnError = [&](std::error_code EC) {
5848 R.releaseBuffer(); // Never take ownership on error.
5868 R.releaseBuffer(); // Never take ownership on error.
58495869 return EC;
58505870 };
58515871
58605880 return cleanupOnError(EC);
58615881 }
58625882
5863 Buf.release(); // The FunctionIndexBitcodeReader owns it now.
5883 Buf.release(); // The FunctionIndexBitcodeReader owns it now.
58645884 return std::error_code();
58655885 }
582582 /// after the real VST is written. Returns the bit offset to backpatch.
583583 static uint64_t WriteValueSymbolTableForwardDecl(const ValueSymbolTable &VST,
584584 BitstreamWriter &Stream) {
585 if (VST.empty()) return 0;
585 if (VST.empty())
586 return 0;
586587
587588 // Write a placeholder value in for the offset of the real VST,
588589 // which is written after the function blocks so that it can include
22192220 // 8-bit fixed-width VST_FNENTRY function strings.
22202221 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
22212222 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_FNENTRY));
2222 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2223 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2223 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2224 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
22242225 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
22252226 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
22262227 FnEntry8BitAbbrev = Stream.EmitAbbrev(Abbv);
22282229 // 7-bit fixed width VST_FNENTRY function strings.
22292230 Abbv = new BitCodeAbbrev();
22302231 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_FNENTRY));
2231 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2232 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2232 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2233 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
22332234 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
22342235 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
22352236 FnEntry7BitAbbrev = Stream.EmitAbbrev(Abbv);
22372238 // 6-bit char6 VST_FNENTRY function strings.
22382239 Abbv = new BitCodeAbbrev();
22392240 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_FNENTRY));
2240 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2241 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2241 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2242 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
22422243 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
22432244 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
22442245 FnEntry6BitAbbrev = Stream.EmitAbbrev(Abbv);
23022303 AbbrevToUse = VST_ENTRY_7_ABBREV;
23032304 }
23042305
2305 for (const auto P : Name.getKey()) NameVals.push_back((unsigned char)P);
2306 for (const auto P : Name.getKey())
2307 NameVals.push_back((unsigned char)P);
23062308
23072309 // Emit the finished record.
23082310 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
23202322 // 8-bit fixed-width VST_COMBINED_FNENTRY function strings.
23212323 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
23222324 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_COMBINED_FNENTRY));
2323 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2325 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
23242326 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
23252327 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
23262328 unsigned FnEntry8BitAbbrev = Stream.EmitAbbrev(Abbv);
23282330 // 7-bit fixed width VST_COMBINED_FNENTRY function strings.
23292331 Abbv = new BitCodeAbbrev();
23302332 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_COMBINED_FNENTRY));
2331 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2333 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
23322334 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
23332335 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
23342336 unsigned FnEntry7BitAbbrev = Stream.EmitAbbrev(Abbv);
23362338 // 6-bit char6 VST_COMBINED_FNENTRY function strings.
23372339 Abbv = new BitCodeAbbrev();
23382340 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_COMBINED_FNENTRY));
2339 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
2341 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // funcoffset
23402342 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
23412343 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
23422344 unsigned FnEntry6BitAbbrev = Stream.EmitAbbrev(Abbv);
23602362 else if (Bits == SE_Fixed7)
23612363 AbbrevToUse = FnEntry7BitAbbrev;
23622364
2363 for (const auto P : FuncName) NameVals.push_back((unsigned char)P);
2365 for (const auto P : FuncName)
2366 NameVals.push_back((unsigned char)P);
23642367
23652368 // Emit the finished record.
23662369 Stream.EmitRecord(bitc::VST_CODE_COMBINED_FNENTRY, NameVals, AbbrevToUse);
24652468 I != E; ++I) {
24662469 WriteInstruction(*I, InstID, VE, Stream, Vals);
24672470
2468 if (!isa(I)) ++NumInsts;
2471 if (!isa(I))
2472 ++NumInsts;
24692473
24702474 if (!I->getType()->isVoidTy())
24712475 ++InstID;
27272731
27282732 NameVals.push_back(MPSE.getValue());
27292733
2730 for (const auto P : MPSE.getKey()) NameVals.push_back((unsigned char)P);
2734 for (const auto P : MPSE.getKey())
2735 NameVals.push_back((unsigned char)P);
27312736
27322737 // Emit the finished record.
27332738 Stream.EmitRecord(bitc::MST_CODE_ENTRY, NameVals, AbbrevToUse);
27602765 // Abbrev for FS_CODE_PERMODULE_ENTRY.
27612766 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
27622767 Abbv->Add(BitCodeAbbrevOp(bitc::FS_CODE_PERMODULE_ENTRY));
2763 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
2764 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // islocal
2765 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
2768 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid
2769 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // islocal
2770 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
27662771 unsigned FSAbbrev = Stream.EmitAbbrev(Abbv);
27672772
27682773 SmallVector NameVals;
27692774 for (auto &I : FunctionIndex) {
27702775 // Skip anonymous functions. We will emit a function summary for
27712776 // any aliases below.
2772 if (!I.first->hasName()) continue;
2777 if (!I.first->hasName())
2778 continue;
27732779
27742780 WritePerModuleFunctionSummaryRecord(
27752781 NameVals, I.second->functionSummary(),
27782784 }
27792785
27802786 for (const GlobalAlias &A : M->aliases()) {
2781 if (!A.getBaseObject()) continue;
2787 if (!A.getBaseObject())
2788 continue;
27822789 const Function *F = dyn_cast(A.getBaseObject());
2783 if (!F || F->isDeclaration()) continue;
2790 if (!F || F->isDeclaration())
2791 continue;
27842792
27852793 assert(FunctionIndex.count(F) == 1);
27862794 WritePerModuleFunctionSummaryRecord(
28012809 // Abbrev for FS_CODE_COMBINED_ENTRY.
28022810 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
28032811 Abbv->Add(BitCodeAbbrevOp(bitc::FS_CODE_COMBINED_ENTRY));
2804 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
2805 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
2812 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid
2813 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount
28062814 unsigned FSAbbrev = Stream.EmitAbbrev(Abbv);
28072815
28082816 SmallVector NameVals;
None //===- FunctionIndexObjectFile.cpp - Function index file implementation ----===//
0 //===- FunctionIndexObjectFile.cpp - Function index file implementation
1 //----===//
12 //
23 // The LLVM Compiler Infrastructure
34 //
3132 return std::move(Index);
3233 }
3334
34 ErrorOr FunctionIndexObjectFile::findBitcodeInObject(
35 const ObjectFile &Obj) {
35 ErrorOr
36 FunctionIndexObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
3637 for (const SectionRef &Sec : Obj.sections()) {
3738 StringRef SecName;
38 if (std::error_code EC = Sec.getName(SecName)) return EC;
39 if (std::error_code EC = Sec.getName(SecName))
40 return EC;
3941 if (SecName == ".llvmbc") {
4042 StringRef SecContents;
41 if (std::error_code EC = Sec.getContents(SecContents)) return EC;
43 if (std::error_code EC = Sec.getContents(SecContents))
44 return EC;
4245 return MemoryBufferRef(SecContents, Obj.getFileName());
4346 }
4447 }
4649 return object_error::bitcode_section_not_found;
4750 }
4851
49 ErrorOr FunctionIndexObjectFile::findBitcodeInMemBuffer(
50 MemoryBufferRef Object) {
52 ErrorOr
53 FunctionIndexObjectFile::findBitcodeInMemBuffer(MemoryBufferRef Object) {
5154 sys::fs::file_magic Type = sys::fs::identify_magic(Object.getBuffer());
5255 switch (Type) {
53 case sys::fs::file_magic::bitcode:
54 return Object;
55 case sys::fs::file_magic::elf_relocatable:
56 case sys::fs::file_magic::macho_object:
57 case sys::fs::file_magic::coff_object: {
58 ErrorOr> ObjFile =
59 ObjectFile::createObjectFile(Object, Type);
60 if (!ObjFile) return ObjFile.getError();
61 return findBitcodeInObject(*ObjFile->get());
62 }
63 default:
64 return object_error::invalid_file_type;
56 case sys::fs::file_magic::bitcode:
57 return Object;
58 case sys::fs::file_magic::elf_relocatable:
59 case sys::fs::file_magic::macho_object:
60 case sys::fs::file_magic::coff_object: {
61 ErrorOr> ObjFile =
62 ObjectFile::createObjectFile(Object, Type);
63 if (!ObjFile)
64 return ObjFile.getError();
65 return findBitcodeInObject(*ObjFile->get());
66 }
67 default:
68 return object_error::invalid_file_type;
6569 }
6670 }
6771
7074 bool FunctionIndexObjectFile::hasFunctionSummaryInMemBuffer(
7175 MemoryBufferRef Object, LLVMContext &Context) {
7276 ErrorOr BCOrErr = findBitcodeInMemBuffer(Object);
73 if (!BCOrErr) return false;
77 if (!BCOrErr)
78 return false;
7479
7580 return hasFunctionSummary(BCOrErr.get(), Context, nullptr);
7681 }
8489 std::unique_ptr Index;
8590
8691 ErrorOr BCOrErr = findBitcodeInMemBuffer(Object);
87 if (!BCOrErr) return BCOrErr.getError();
92 if (!BCOrErr)
93 return BCOrErr.getError();
8894
8995 ErrorOr> IOrErr =
9096 getFunctionInfoIndex(BCOrErr.get(), Context, nullptr, IsLazy);
9197
92 if (std::error_code EC = IOrErr.getError()) return EC;
98 if (std::error_code EC = IOrErr.getError())
99 return EC;
93100
94101 Index = std::move(IOrErr.get());
95102
103110 MemoryBufferRef Object, LLVMContext &Context, StringRef FunctionName) {
104111 sys::fs::file_magic Type = sys::fs::identify_magic(Object.getBuffer());
105112 switch (Type) {
106 case sys::fs::file_magic::bitcode: {
107 return readFunctionSummary(Object, Context, nullptr, FunctionName,
108 std::move(Index));
109 }
110 default:
111 return object_error::invalid_file_type;
113 case sys::fs::file_magic::bitcode: {
114 return readFunctionSummary(Object, Context, nullptr, FunctionName,
115 std::move(Index));
116 }
117 default:
118 return object_error::invalid_file_type;
112119 }
113120 }
None //===-- ElimAvailExtern.cpp - DCE unreachable internal functions ----------------===//
0 //===-- ElimAvailExtern.cpp - DCE unreachable internal functions
1 //----------------===//
12 //
23 // The LLVM Compiler Infrastructure
34 //
2526 STATISTIC(NumVariables, "Number of global variables removed");
2627
2728 namespace {
28 struct EliminateAvailableExternally : public ModulePass {
29 static char ID; // Pass identification, replacement for typeid
30 EliminateAvailableExternally() : ModulePass(ID) {
31 initializeEliminateAvailableExternallyPass(
32 *PassRegistry::getPassRegistry());
33 }
29 struct EliminateAvailableExternally : public ModulePass {
30 static char ID; // Pass identification, replacement for typeid
31 EliminateAvailableExternally() : ModulePass(ID) {
32 initializeEliminateAvailableExternallyPass(
33 *PassRegistry::getPassRegistry());
34 }
3435
35 // run - Do the EliminateAvailableExternally pass on the specified module,
36 // optionally updating the specified callgraph to reflect the changes.
37 //
38 bool runOnModule(Module &M) override;
39 };
36 // run - Do the EliminateAvailableExternally pass on the specified module,
37 // optionally updating the specified callgraph to reflect the changes.
38 //
39 bool runOnModule(Module &M) override;
40 };
4041 }
4142
4243 char EliminateAvailableExternally::ID = 0;
5152 bool Changed = false;
5253
5354 // Drop initializers of available externally global variables.
54 for (GlobalVariable &GV :M.globals()) {
55 for (GlobalVariable &GV : M.globals()) {
5556 if (!GV.hasAvailableExternallyLinkage())
5657 continue;
5758 if (GV.hasInitializer()) {
384384
385385 // If we are doing ThinLTO compilation, don't need to process the symbols.
386386 // Later we simply build a combined index file after all files are claimed.
387 if (options::thinlto) return LDPS_OK;
387 if (options::thinlto)
388 return LDPS_OK;
388389
389390 for (auto &Sym : Obj->symbols()) {
390391 uint32_t Symflags = Sym.getFlags();
601602 Sym.comdat_key = nullptr;
602603 }
603604
604 static std::unique_ptr getFunctionIndexForFile(
605 LLVMContext &Context, claimed_file &F, ld_plugin_input_file &Info) {
605 static std::unique_ptr
606 getFunctionIndexForFile(LLVMContext &Context, claimed_file &F,
607 ld_plugin_input_file &Info) {
606608
607609 if (get_symbols(F.handle, F.syms.size(), &F.syms[0]) != LDPS_OK)
608610 message(LDPL_FATAL, "Failed to get symbol information");
283283 }
284284 case bitc::MODULE_STRTAB_BLOCK_ID:
285285 switch (CodeID) {
286 default: return nullptr;
287 STRINGIFY_CODE(MST_CODE, ENTRY)
286 default:
287 return nullptr;
288 STRINGIFY_CODE(MST_CODE, ENTRY)
288289 }
289290 case bitc::FUNCTION_SUMMARY_BLOCK_ID:
290291 switch (CodeID) {
291 default: return nullptr;
292 STRINGIFY_CODE(FS_CODE, PERMODULE_ENTRY)
293 STRINGIFY_CODE(FS_CODE, COMBINED_ENTRY)
292 default:
293 return nullptr;
294 STRINGIFY_CODE(FS_CODE, PERMODULE_ENTRY)
295 STRINGIFY_CODE(FS_CODE, COMBINED_ENTRY)
294296 }
295297 case bitc::METADATA_ATTACHMENT_ID:
296298 switch(CodeID) {
533535 }
534536 Str += (char)Record[j];
535537 }
536 if (ArrayIsPrintable) outs() << " record string = '" << Str << "'";
538 if (ArrayIsPrintable)
539 outs() << " record string = '" << Str << "'";
537540 break;
538541 }
539542 }
5858 UseDiagnosticHandler("use-diagnostic-handler", cl::init(false),
5959 cl::desc("Use a diagnostic handler to test the handler interface"));
6060
61 static cl::opt ThinLTO(
62 "thinlto", cl::init(false),
63 cl::desc("Only write combined global index for ThinLTO backends"));
61 static cl::opt
62 ThinLTO("thinlto", cl::init(false),
63 cl::desc("Only write combined global index for ThinLTO backends"));
6464
6565 static cl::list
6666 InputFilenames(cl::Positional, cl::OneOrMore,
159159
160160 /// Parse the function index out of an IR file and return the function
161161 /// index object if found, or nullptr if not.
162 static std::unique_ptr getFunctionIndexForFile(
163 StringRef Path, std::string &Error, LLVMContext &Context) {
162 static std::unique_ptr
163 getFunctionIndexForFile(StringRef Path, std::string &Error,
164 LLVMContext &Context) {
164165 std::unique_ptr Buffer;
165166 ErrorOr> BufferOrErr =
166167 MemoryBuffer::getFile(Path);
237238 if (ListSymbolsOnly)
238239 return listSymbols(argv[0], Options);
239240
240 if (ThinLTO) return createCombinedFunctionIndex(argv[0]);
241 if (ThinLTO)
242 return createCombinedFunctionIndex(argv[0]);
241243
242244 unsigned BaseArg = 0;
243245