llvm.org GIT mirror llvm / f95cab8
[Bitcode] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312760 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 2 years ago
11 changed file(s) with 314 addition(s) and 160 deletion(s). Raw diff Collapse all Expand all
None //===-- llvm/Bitcode/BitcodeReader.h - Bitcode reader ----*- C++ -*-===//
0 //===- llvm/Bitcode/BitcodeReader.h - Bitcode reader ------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 #ifndef LLVM_BITCODE_BITCODEREADER_H
1414 #define LLVM_BITCODE_BITCODEREADER_H
1515
16 #include "llvm/ADT/ArrayRef.h"
17 #include "llvm/ADT/StringRef.h"
1618 #include "llvm/Bitcode/BitCodes.h"
17 #include "llvm/IR/DiagnosticInfo.h"
1819 #include "llvm/IR/ModuleSummaryIndex.h"
1920 #include "llvm/Support/Endian.h"
2021 #include "llvm/Support/Error.h"
2122 #include "llvm/Support/ErrorOr.h"
2223 #include "llvm/Support/MemoryBuffer.h"
24 #include
2325 #include
24
26 #include
27 #include
28 #include
2529 namespace llvm {
26 class LLVMContext;
27 class Module;
30
31 class LLVMContext;
32 class Module;
2833
2934 // These functions are for converting Expected/Error values to
3035 // ErrorOr/std::error_code for compatibility with legacy clients. FIXME:
8085 StringRef getBuffer() const {
8186 return StringRef((const char *)Buffer.begin(), Buffer.size());
8287 }
88
8389 StringRef getStrtab() const { return Strtab; }
8490
8591 StringRef getModuleIdentifier() const { return ModuleIdentifier; }
181187
182188 /// isBitcodeWrapper - Return true if the given bytes are the magic bytes
183189 /// for an LLVM IR bitcode wrapper.
184 ///
185190 inline bool isBitcodeWrapper(const unsigned char *BufPtr,
186191 const unsigned char *BufEnd) {
187192 // See if you can find the hidden message in the magic bytes :-).
195200
196201 /// isRawBitcode - Return true if the given bytes are the magic bytes for
197202 /// raw LLVM IR bitcode (without a wrapper).
198 ///
199203 inline bool isRawBitcode(const unsigned char *BufPtr,
200204 const unsigned char *BufEnd) {
201205 // These bytes sort of have a hidden message, but it's not in
209213
210214 /// isBitcode - Return true if the given bytes are the magic bytes for
211215 /// LLVM IR bitcode, either with or without a wrapper.
212 ///
213216 inline bool isBitcode(const unsigned char *BufPtr,
214217 const unsigned char *BufEnd) {
215218 return isBitcodeWrapper(BufPtr, BufEnd) ||
257260 return std::error_code(static_cast(E), BitcodeErrorCategory());
258261 }
259262
260 } // End llvm namespace
263 } // end namespace llvm
261264
262265 namespace std {
266
263267 template <> struct is_error_code_enum : std::true_type {};
264 }
265
266 #endif
268
269 } // end namespace std
270
271 #endif // LLVM_BITCODE_BITCODEREADER_H
None //===-- llvm/Bitcode/BitcodeWriter.h - Bitcode writers ----*- C++ -*-===//
0 //===- llvm/Bitcode/BitcodeWriter.h - Bitcode writers -----------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 #ifndef LLVM_BITCODE_BITCODEWRITER_H
1414 #define LLVM_BITCODE_BITCODEWRITER_H
1515
16 #include "llvm/ADT/StringRef.h"
1617 #include "llvm/IR/ModuleSummaryIndex.h"
1718 #include "llvm/MC/StringTableBuilder.h"
19 #include "llvm/Support/Allocator.h"
20 #include
21 #include
1822 #include
23 #include
1924
2025 namespace llvm {
21 class BitstreamWriter;
22 class Module;
23 class raw_ostream;
26
27 class BitstreamWriter;
28 class Module;
29 class raw_ostream;
2430
2531 class BitcodeWriter {
2632 SmallVectorImpl &Buffer;
3844
3945 std::vector Mods;
4046
41 public:
47 public:
4248 /// Create a BitcodeWriter that writes to Buffer.
4349 BitcodeWriter(SmallVectorImpl &Buffer);
4450
144150 void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out,
145151 const std::map
146152 *ModuleToSummariesForIndex = nullptr);
147 } // End llvm namespace
148153
149 #endif
154 } // end namespace llvm
155
156 #endif // LLVM_BITCODE_BITCODEWRITER_H
4242 unsigned BlockID;
4343 std::vector> Abbrevs;
4444 std::string Name;
45 std::vector > RecordNames;
45 std::vector> RecordNames;
4646 };
4747
4848 private:
8787 /// follow the word size of the host machine for efficiency. We use word_t in
8888 /// places that are aware of this to make it perfectly explicit what is going
8989 /// on.
90 typedef size_t word_t;
90 using word_t = size_t;
9191
9292 private:
9393 word_t CurWord = 0;
99 #include "llvm/Bitcode/BitcodeReader.h"
1010 #include "MetadataLoader.h"
1111 #include "ValueList.h"
12
1312 #include "llvm/ADT/APFloat.h"
1413 #include "llvm/ADT/APInt.h"
1514 #include "llvm/ADT/ArrayRef.h"
1615 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/None.h"
16 #include "llvm/ADT/Optional.h"
1817 #include "llvm/ADT/STLExtras.h"
1918 #include "llvm/ADT/SmallString.h"
2019 #include "llvm/ADT/SmallVector.h"
3231 #include "llvm/IR/Comdat.h"
3332 #include "llvm/IR/Constant.h"
3433 #include "llvm/IR/Constants.h"
34 #include "llvm/IR/DataLayout.h"
3535 #include "llvm/IR/DebugInfo.h"
3636 #include "llvm/IR/DebugInfoMetadata.h"
3737 #include "llvm/IR/DebugLoc.h"
3838 #include "llvm/IR/DerivedTypes.h"
39 #include "llvm/IR/DiagnosticInfo.h"
40 #include "llvm/IR/DiagnosticPrinter.h"
4139 #include "llvm/IR/Function.h"
4240 #include "llvm/IR/GVMaterializer.h"
4341 #include "llvm/IR/GlobalAlias.h"
5351 #include "llvm/IR/Instructions.h"
5452 #include "llvm/IR/Intrinsics.h"
5553 #include "llvm/IR/LLVMContext.h"
54 #include "llvm/IR/Metadata.h"
5655 #include "llvm/IR/Module.h"
5756 #include "llvm/IR/ModuleSummaryIndex.h"
58 #include "llvm/IR/OperandTraits.h"
5957 #include "llvm/IR/Operator.h"
60 #include "llvm/IR/TrackingMDRef.h"
6158 #include "llvm/IR/Type.h"
62 #include "llvm/IR/ValueHandle.h"
59 #include "llvm/IR/Value.h"
6360 #include "llvm/IR/Verifier.h"
6461 #include "llvm/Support/AtomicOrdering.h"
6562 #include "llvm/Support/Casting.h"
6865 #include "llvm/Support/Debug.h"
6966 #include "llvm/Support/Error.h"
7067 #include "llvm/Support/ErrorHandling.h"
68 #include "llvm/Support/ErrorOr.h"
7169 #include "llvm/Support/ManagedStatic.h"
70 #include "llvm/Support/MathExtras.h"
7271 #include "llvm/Support/MemoryBuffer.h"
7372 #include "llvm/Support/raw_ostream.h"
7473 #include
7675 #include
7776 #include
7877 #include
79 #include
8078 #include
8179 #include
80 #include
8281 #include
8382 #include
8483 #include
9897 SWITCH_INST_MAGIC = 0x4B5 // May 2012 => 1205 => Hex
9998 };
10099
101 Error error(const Twine &Message) {
100 } // end anonymous namespace
101
102 static Error error(const Twine &Message) {
102103 return make_error(
103104 Message, make_error_code(BitcodeError::CorruptedBitcode));
104105 }
105106
106107 /// Helper to read the header common to all bitcode files.
107 bool hasValidBitcodeHeader(BitstreamCursor &Stream) {
108 static bool hasValidBitcodeHeader(BitstreamCursor &Stream) {
108109 // Sniff for the signature.
109110 if (!Stream.canSkipToPos(4) ||
110111 Stream.Read(8) != 'B' ||
117118 return true;
118119 }
119120
120 Expected initStream(MemoryBufferRef Buffer) {
121 static Expected initStream(MemoryBufferRef Buffer) {
121122 const unsigned char *BufPtr = (const unsigned char *)Buffer.getBufferStart();
122123 const unsigned char *BufEnd = BufPtr + Buffer.getBufferSize();
123124
150151 }
151152
152153 // Strip all the TBAA attachment for the module.
153 void stripTBAA(Module *M) {
154 static void stripTBAA(Module *M) {
154155 for (auto &F : *M) {
155156 if (F.isMaterializable())
156157 continue;
161162
162163 /// Read the "IDENTIFICATION_BLOCK_ID" block, do some basic enforcement on the
163164 /// "epoch" encoded in the bitcode, and return the producer name if any.
164 Expected readIdentificationBlock(BitstreamCursor &Stream) {
165 static Expected readIdentificationBlock(BitstreamCursor &Stream) {
165166 if (Stream.EnterSubBlock(bitc::IDENTIFICATION_BLOCK_ID))
166167 return error("Invalid record");
167168
205206 }
206207 }
207208
208 Expected readIdentificationCode(BitstreamCursor &Stream) {
209 static Expected readIdentificationCode(BitstreamCursor &Stream) {
209210 // We expect a number of well-defined blocks, though we don't necessarily
210211 // need to understand them all.
211212 while (true) {
233234 }
234235 }
235236
236 Expected hasObjCCategoryInModule(BitstreamCursor &Stream) {
237 static Expected hasObjCCategoryInModule(BitstreamCursor &Stream) {
237238 if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
238239 return error("Invalid record");
239240
274275 llvm_unreachable("Exit infinite loop");
275276 }
276277
277 Expected hasObjCCategory(BitstreamCursor &Stream) {
278 static Expected hasObjCCategory(BitstreamCursor &Stream) {
278279 // We expect a number of well-defined blocks, though we don't necessarily
279280 // need to understand them all.
280281 while (true) {
302303 }
303304 }
304305
305 Expected readModuleTriple(BitstreamCursor &Stream) {
306 static Expected readModuleTriple(BitstreamCursor &Stream) {
306307 if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
307308 return error("Invalid record");
308309
341342 llvm_unreachable("Exit infinite loop");
342343 }
343344
344 Expected readTriple(BitstreamCursor &Stream) {
345 static Expected readTriple(BitstreamCursor &Stream) {
345346 // We expect a number of well-defined blocks, though we don't necessarily
346347 // need to understand them all.
347348 while (true) {
369370 }
370371 }
371372
373 namespace {
374
372375 class BitcodeReaderBase {
373376 protected:
374377 BitcodeReaderBase(BitstreamCursor Stream, StringRef Strtab)
399402
400403 Error error(const Twine &Message);
401404 };
405
406 } // end anonymous namespace
402407
403408 Error BitcodeReaderBase::error(const Twine &Message) {
404409 std::string FullMsg = Message.str();
410415
411416 Expected
412417 BitcodeReaderBase::parseVersionRecord(ArrayRef Record) {
413 if (Record.size() < 1)
418 if (Record.empty())
414419 return error("Invalid record");
415420 unsigned ModuleVersion = Record[0];
416421 if (ModuleVersion > 2)
428433 return {"", {}};
429434 return {StringRef(Strtab.data() + Record[0], Record[1]), Record.slice(2)};
430435 }
436
437 namespace {
431438
432439 class BitcodeReader : public BitcodeReaderBase, public GVMaterializer {
433440 LLVMContext &Context;
448455 std::vector ComdatList;
449456 SmallVector InstructionList;
450457
451 std::vector > GlobalInits;
452 std::vector > IndirectSymbolInits;
453 std::vector > FunctionPrefixes;
454 std::vector > FunctionPrologues;
455 std::vectorFunction*, unsigned> > FunctionPersonalityFns;
458 std::vectorGlobalVariable *, unsigned>> GlobalInits;
459 std::vector> IndirectSymbolInits;
460 std::vector> FunctionPrefixes;
461 std::vector> FunctionPrologues;
462 std::vector> FunctionPersonalityFns;
456463
457464 /// The set of attributes by index. Index zero in the file is for null, and
458465 /// is thus not represented here. As such all indices are off by one.
471478
472479 // When intrinsic functions are encountered which require upgrading they are
473480 // stored here with their replacement function.
474 typedef DenseMap UpdatedIntrinsicMap;
481 using UpdatedIntrinsicMap = DenseMap;
475482 UpdatedIntrinsicMap UpgradedIntrinsics;
476483 // Intrinsics which were remangled because of types rename
477484 UpdatedIntrinsicMap RemangledIntrinsics;
10491056 case 6: GV->setDLLStorageClass(GlobalValue::DLLExportStorageClass); break;
10501057 }
10511058 }
1052
10531059
10541060 Type *BitcodeReader::getTypeByID(unsigned ID) {
10551061 // The type table size is always specified correctly.
12251231 switch (Stream.readRecord(Entry.ID, Record)) {
12261232 default: // Default behavior: ignore.
12271233 break;
1228 case bitc::PARAMATTR_CODE_ENTRY_OLD: { // ENTRY: [paramidx0, attr0, ...]
1234 case bitc::PARAMATTR_CODE_ENTRY_OLD: // ENTRY: [paramidx0, attr0, ...]
12291235 // FIXME: Remove in 4.0.
12301236 if (Record.size() & 1)
12311237 return error("Invalid record");
12391245 MAttributes.push_back(AttributeList::get(Context, Attrs));
12401246 Attrs.clear();
12411247 break;
1242 }
1243 case bitc::PARAMATTR_CODE_ENTRY: { // ENTRY: [attrgrp0, attrgrp1, ...]
1248 case bitc::PARAMATTR_CODE_ENTRY: // ENTRY: [attrgrp0, attrgrp1, ...]
12441249 for (unsigned i = 0, e = Record.size(); i != e; ++i)
12451250 Attrs.push_back(MAttributeGroups[Record[i]]);
12461251
12471252 MAttributes.push_back(AttributeList::get(Context, Attrs));
12481253 Attrs.clear();
12491254 break;
1250 }
12511255 }
12521256 }
12531257 }
19992003
20002004 /// Resolve all of the initializers for global values and aliases that we can.
20012005 Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() {
2002 std::vector > GlobalInitWorklist;
2003 std::vectorIndirectSymbol*, unsigned> >
2006 std::vectorVariable *, unsigned>> GlobalInitWorklist;
2007 std::vector>
20042008 IndirectSymbolInitWorklist;
2005 std::vector > FunctionPrefixWorklist;
2006 std::vector > FunctionPrologueWorklist;
2007 std::vector*, unsigned> > FunctionPersonalityFnWorklist;
2009 std::vector *, unsigned>> FunctionPrefixWorklist;
2010 std::vector> FunctionPrologueWorklist;
2011 std::vector> FunctionPersonalityFnWorklist;
20082012
20092013 GlobalInitWorklist.swap(GlobalInits);
20102014 IndirectSymbolInitWorklist.swap(IndirectSymbolInits);
27182722
27192723 // Force deallocation of memory for these vectors to favor the client that
27202724 // want lazy deserialization.
2721 std::vector >().swap(GlobalInits);
2722 std::vectorIndirectSymbol*, unsigned> >().swap(
2725 std::vectorVariable *, unsigned>>().swap(GlobalInits);
2726 std::vector>().swap(
27232727 IndirectSymbolInits);
27242728 return Error::success();
27252729 }
27762780 StringRef Name;
27772781 std::tie(Name, Record) = readNameFromStrtab(Record);
27782782
2779 if (Record.size() < 1)
2783 if (Record.empty())
27802784 return error("Invalid record");
27812785 Comdat::SelectionKind SK = getDecodedComdatSelectionKind(Record[0]);
27822786 std::string OldFormatName;
32433247 GCTable.push_back(S);
32443248 break;
32453249 }
3246 case bitc::MODULE_CODE_COMDAT: {
3250 case bitc::MODULE_CODE_COMDAT:
32473251 if (Error Err = parseComdatRecord(Record))
32483252 return Err;
32493253 break;
3250 }
3251 case bitc::MODULE_CODE_GLOBALVAR: {
3254 case bitc::MODULE_CODE_GLOBALVAR:
32523255 if (Error Err = parseGlobalVarRecord(Record))
32533256 return Err;
32543257 break;
3255 }
3256 case bitc::MODULE_CODE_FUNCTION: {
3258 case bitc::MODULE_CODE_FUNCTION:
32573259 if (Error Err = parseFunctionRecord(Record))
32583260 return Err;
32593261 break;
3260 }
32613262 case bitc::MODULE_CODE_IFUNC:
32623263 case bitc::MODULE_CODE_ALIAS:
3263 case bitc::MODULE_CODE_ALIAS_OLD: {
3264 case bitc::MODULE_CODE_ALIAS_OLD:
32643265 if (Error Err = parseGlobalIndirectSymbolRecord(BitCode, Record))
32653266 return Err;
32663267 break;
3267 }
32683268 /// MODULE_CODE_VSTOFFSET: [offset]
32693269 case bitc::MODULE_CODE_VSTOFFSET:
32703270 if (Record.size() < 1)
32933293 [&](unsigned ID) { return getTypeByID(ID); });
32943294 return parseModule(0, ShouldLazyLoadMetadata);
32953295 }
3296
32973296
32983297 Error BitcodeReader::typeCheckLoadStoreInst(Type *ValType, Type *PtrType) {
32993298 if (!isa(PtrType))
52985297 LastSeenGUID = 0;
52995298 break;
53005299 }
5301 case bitc::FS_TYPE_TESTS: {
5300 case bitc::FS_TYPE_TESTS:
53025301 assert(PendingTypeTests.empty());
53035302 PendingTypeTests.insert(PendingTypeTests.end(), Record.begin(),
53045303 Record.end());
53055304 break;
5306 }
5307 case bitc::FS_TYPE_TEST_ASSUME_VCALLS: {
5305
5306 case bitc::FS_TYPE_TEST_ASSUME_VCALLS:
53085307 assert(PendingTypeTestAssumeVCalls.empty());
53095308 for (unsigned I = 0; I != Record.size(); I += 2)
53105309 PendingTypeTestAssumeVCalls.push_back({Record[I], Record[I+1]});
53115310 break;
5312 }
5313 case bitc::FS_TYPE_CHECKED_LOAD_VCALLS: {
5311
5312 case bitc::FS_TYPE_CHECKED_LOAD_VCALLS:
53145313 assert(PendingTypeCheckedLoadVCalls.empty());
53155314 for (unsigned I = 0; I != Record.size(); I += 2)
53165315 PendingTypeCheckedLoadVCalls.push_back({Record[I], Record[I+1]});
53175316 break;
5318 }
5319 case bitc::FS_TYPE_TEST_ASSUME_CONST_VCALL: {
5317
5318 case bitc::FS_TYPE_TEST_ASSUME_CONST_VCALL:
53205319 PendingTypeTestAssumeConstVCalls.push_back(
53215320 {{Record[0], Record[1]}, {Record.begin() + 2, Record.end()}});
53225321 break;
5323 }
5324 case bitc::FS_TYPE_CHECKED_LOAD_CONST_VCALL: {
5322
5323 case bitc::FS_TYPE_CHECKED_LOAD_CONST_VCALL:
53255324 PendingTypeCheckedLoadConstVCalls.push_back(
53265325 {{Record[0], Record[1]}, {Record.begin() + 2, Record.end()}});
53275326 break;
5328 }
5327
53295328 case bitc::FS_CFI_FUNCTION_DEFS: {
53305329 std::set &CfiFunctionDefs = TheIndex.cfiFunctionDefs();
53315330 for (unsigned I = 0; I != Record.size(); I += 2)
54165415 const char *name() const noexcept override {
54175416 return "llvm.bitcode";
54185417 }
5418
54195419 std::string message(int IE) const override {
54205420 BitcodeError E = static_cast(IE);
54215421 switch (E) {
54405440 return error("Invalid record");
54415441
54425442 StringRef Strtab;
5443 while (1) {
5443 while (true) {
54445444 BitstreamEntry Entry = Stream.advance();
54455445 switch (Entry.Kind) {
54465446 case BitstreamEntry::EndBlock:
None //===----- ValueList.cpp - Internal BitcodeReader implementation ----------===//
0 //===- ValueList.cpp - Internal BitcodeReader implementation --------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
77 //===----------------------------------------------------------------------===//
88
99 #include "ValueList.h"
10 #include "llvm/ADT/SmallVector.h"
11 #include "llvm/IR/Argument.h"
12 #include "llvm/IR/Constant.h"
1013 #include "llvm/IR/Constants.h"
11 #include "llvm/IR/Instructions.h"
14 #include "llvm/IR/GlobalValue.h"
15 #include "llvm/IR/Instruction.h"
16 #include "llvm/IR/Type.h"
17 #include "llvm/IR/User.h"
18 #include "llvm/IR/Value.h"
19 #include "llvm/IR/ValueHandle.h"
20 #include "llvm/Support/Casting.h"
21 #include "llvm/Support/ErrorHandling.h"
22 #include
23 #include
24 #include
25 #include
26 #include
1227
1328 using namespace llvm;
1429
1530 namespace llvm {
31
1632 namespace {
1733
1834 /// \brief A class for maintaining the slot number definition
1935 /// as a placeholder for the actual definition for forward constants defs.
2036 class ConstantPlaceHolder : public ConstantExpr {
21 void operator=(const ConstantPlaceHolder &) = delete;
22
2337 public:
24 // allocate space for exactly one operand
25 void *operator new(size_t s) { return User::operator new(s, 1); }
2638 explicit ConstantPlaceHolder(Type *Ty, LLVMContext &Context)
2739 : ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) {
2840 Op<0>() = UndefValue::get(Type::getInt32Ty(Context));
2941 }
42
43 ConstantPlaceHolder &operator=(const ConstantPlaceHolder &) = delete;
44
45 // allocate space for exactly one operand
46 void *operator new(size_t s) { return User::operator new(s, 1); }
3047
3148 /// \brief Methods to support type inquiry through isa, cast, and dyn_cast.
3249 static bool classof(const Value *V) {
None //===-- Bitcode/Reader/ValueEnumerator.h - Number values --------*- C++ -*-===//
0 //===-- Bitcode/Reader/ValueList.h - Number values --------------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/IR/LLVMContext.h"
13 #ifndef LLVM_LIB_BITCODE_READER_VALUELIST_H
14 #define LLVM_LIB_BITCODE_READER_VALUELIST_H
15
1416 #include "llvm/IR/ValueHandle.h"
15
17 #include
18 #include
1619 #include
1720
1821 namespace llvm {
22
1923 class Constant;
24 class LLVMContext;
25 class Type;
26 class Value;
2027
2128 class BitcodeReaderValueList {
2229 std::vector ValuePtrs;
2835 ///
2936 /// The key of this vector is the placeholder constant, the value is the slot
3037 /// number that holds the resolved value.
31 typedef std::vector> ResolveConstantsTy;
38 using ResolveConstantsTy = std::vector>;
3239 ResolveConstantsTy ResolveConstants;
3340 LLVMContext &Context;
3441
3542 public:
3643 BitcodeReaderValueList(LLVMContext &C) : Context(C) {}
44
3745 ~BitcodeReaderValueList() {
3846 assert(ResolveConstants.empty() && "Constants not resolved?");
3947 }
7280 void resolveConstantForwardRefs();
7381 };
7482
75 } // namespace llvm
83 } // end namespace llvm
84
85 #endif // LLVM_LIB_BITCODE_READER_VALUELIST_H
None //===--- Bitcode/Writer/BitcodeWriter.cpp - Bitcode Writer ----------------===//
0 //===- Bitcode/Writer/BitcodeWriter.cpp - Bitcode Writer ------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1212
1313 #include "llvm/Bitcode/BitcodeWriter.h"
1414 #include "ValueEnumerator.h"
15 #include "llvm/ADT/StringExtras.h"
15 #include "llvm/ADT/APFloat.h"
16 #include "llvm/ADT/APInt.h"
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/None.h"
20 #include "llvm/ADT/Optional.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/SmallString.h"
23 #include "llvm/ADT/SmallVector.h"
24 #include "llvm/ADT/StringMap.h"
25 #include "llvm/ADT/StringRef.h"
1626 #include "llvm/ADT/Triple.h"
27 #include "llvm/Bitcode/BitCodes.h"
1728 #include "llvm/Bitcode/BitstreamWriter.h"
1829 #include "llvm/Bitcode/LLVMBitCodes.h"
30 #include "llvm/IR/Attributes.h"
31 #include "llvm/IR/BasicBlock.h"
1932 #include "llvm/IR/CallSite.h"
33 #include "llvm/IR/Comdat.h"
34 #include "llvm/IR/Constant.h"
2035 #include "llvm/IR/Constants.h"
2136 #include "llvm/IR/DebugInfoMetadata.h"
37 #include "llvm/IR/DebugLoc.h"
2238 #include "llvm/IR/DerivedTypes.h"
39 #include "llvm/IR/Function.h"
40 #include "llvm/IR/GlobalAlias.h"
41 #include "llvm/IR/GlobalIFunc.h"
42 #include "llvm/IR/GlobalObject.h"
43 #include "llvm/IR/GlobalValue.h"
44 #include "llvm/IR/GlobalVariable.h"
2345 #include "llvm/IR/InlineAsm.h"
46 #include "llvm/IR/InstrTypes.h"
47 #include "llvm/IR/Instruction.h"
2448 #include "llvm/IR/Instructions.h"
2549 #include "llvm/IR/LLVMContext.h"
50 #include "llvm/IR/Metadata.h"
2651 #include "llvm/IR/Module.h"
52 #include "llvm/IR/ModuleSummaryIndex.h"
2753 #include "llvm/IR/Operator.h"
54 #include "llvm/IR/Type.h"
2855 #include "llvm/IR/UseListOrder.h"
56 #include "llvm/IR/Value.h"
2957 #include "llvm/IR/ValueSymbolTable.h"
3058 #include "llvm/MC/StringTableBuilder.h"
3159 #include "llvm/Object/IRSymtab.h"
60 #include "llvm/Support/AtomicOrdering.h"
61 #include "llvm/Support/Casting.h"
62 #include "llvm/Support/CommandLine.h"
63 #include "llvm/Support/Endian.h"
64 #include "llvm/Support/Error.h"
3265 #include "llvm/Support/ErrorHandling.h"
3366 #include "llvm/Support/MathExtras.h"
34 #include "llvm/Support/Program.h"
3567 #include "llvm/Support/SHA1.h"
3668 #include "llvm/Support/TargetRegistry.h"
3769 #include "llvm/Support/raw_ostream.h"
38 #include <cctype>
70 #include <algorithm>
71 #include
72 #include
73 #include
74 #include
3975 #include
76 #include
77 #include
78 #include
79 #include
80
4081 using namespace llvm;
4182
42 namespace {
43
44 cl::opt
83 static cl::opt
4584 IndexThreshold("bitcode-mdindex-threshold", cl::Hidden, cl::init(25),
4685 cl::desc("Number of metadatas above which we emit an index "
4786 "to enable lazy-loading"));
87
88 namespace {
89
4890 /// These are manifest constants used by the bitcode writer. They do not need to
4991 /// be kept in sync with the reader, but need to be consistent within this file.
5092 enum {
168210 void assignValueId(GlobalValue::GUID ValGUID) {
169211 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
170212 }
213
171214 unsigned getValueId(GlobalValue::GUID ValGUID) {
172215 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
173216 // Expect that any GUID value had a value Id assigned by an
176219 "GUID does not have assigned value Id");
177220 return VMI->second;
178221 }
222
179223 // Helper to get the valueId for the type of value recorded in VI.
180224 unsigned getValueId(ValueInfo VI) {
181225 if (!VI.getValue())
182226 return getValueId(VI.getGUID());
183227 return VE.getValueID(VI.getValue());
184228 }
229
185230 std::map &valueIds() { return GUIDToValueIdMap; }
186231 };
187232
373418 }
374419
375420 /// The below iterator returns the GUID and associated summary.
376 typedef std::pair GVInfo;
421 using GVInfo = std::pair;
377422
378423 /// Calls the callback for each value GUID and summary to be written to
379424 /// bitcode. This hides the details of whether they are being pulled from the
427472 return None;
428473 return VMI->second;
429474 }
475
430476 std::map &valueIds() { return GUIDToValueIdMap; }
431477 };
478
432479 } // end anonymous namespace
433480
434481 static unsigned getEncodedCastOpcode(unsigned Opcode) {
725772 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg
726773 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
727774 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
728
729775 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
730776
731777 // Abbrev for TYPE_CODE_STRUCT_ANON.
734780 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked
735781 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
736782 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
737
738783 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
739784
740785 // Abbrev for TYPE_CODE_STRUCT_NAME.
750795 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked
751796 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
752797 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
753
754798 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
755799
756800 // Abbrev for TYPE_CODE_ARRAY.
758802 Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_ARRAY));
759803 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // size
760804 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
761
762805 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
763806
764807 // Emit an entry count so the reader can reserve space.
22052248 Record.push_back(p[0]);
22062249 Record.push_back(p[1]);
22072250 } else {
2208 assert (0 && "Unknown FP type!");
2251 assert(0 && "Unknown FP type!");
22092252 }
22102253 } else if (isa(C) &&
22112254 cast(C)->isString()) {
30503093 llvm_unreachable("Unexpected abbrev ordering!");
30513094 }
30523095
3053
3054
30553096 { // SETTYPE abbrev for CONSTANTS_BLOCK.
30563097 auto Abbv = std::make_shared();
30573098 Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_SETTYPE));
40314072 }
40324073
40334074 namespace {
4075
40344076 /// Class to manage the bitcode writing for a thin link bitcode file.
40354077 class ThinLinkBitcodeWriter : public ModuleBitcodeWriterBase {
40364078 /// ModHash is for use in ThinLTO incremental build, generated while writing
40514093 private:
40524094 void writeSimplifiedModuleInfo();
40534095 };
4054 } // namespace
4096
4097 } // end anonymous namespace
40554098
40564099 // This function writes a simpilified module info for thin link bitcode file.
40574100 // It only contains the source file name along with the name(the offset and
None //===-- ValueEnumerator.cpp - Number values and types for bitcode writer --===//
0 //===- ValueEnumerator.cpp - Number values and types for bitcode writer ---===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "ValueEnumerator.h"
14 #include "llvm/ADT/STLExtras.h"
15 #include "llvm/ADT/SmallPtrSet.h"
16 #include "llvm/IR/Constants.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/IR/Argument.h"
17 #include "llvm/IR/Attributes.h"
18 #include "llvm/IR/BasicBlock.h"
19 #include "llvm/IR/Constant.h"
1720 #include "llvm/IR/DebugInfoMetadata.h"
1821 #include "llvm/IR/DerivedTypes.h"
22 #include "llvm/IR/Function.h"
23 #include "llvm/IR/GlobalAlias.h"
24 #include "llvm/IR/GlobalIFunc.h"
25 #include "llvm/IR/GlobalObject.h"
26 #include "llvm/IR/GlobalValue.h"
27 #include "llvm/IR/GlobalVariable.h"
28 #include "llvm/IR/Instruction.h"
1929 #include "llvm/IR/Instructions.h"
30 #include "llvm/IR/Metadata.h"
2031 #include "llvm/IR/Module.h"
32 #include "llvm/IR/Type.h"
33 #include "llvm/IR/Use.h"
2134 #include "llvm/IR/UseListOrder.h"
35 #include "llvm/IR/User.h"
36 #include "llvm/IR/Value.h"
2237 #include "llvm/IR/ValueSymbolTable.h"
38 #include "llvm/Support/Casting.h"
39 #include "llvm/Support/Compiler.h"
2340 #include "llvm/Support/Debug.h"
41 #include "llvm/Support/MathExtras.h"
2442 #include "llvm/Support/raw_ostream.h"
2543 #include
44 #include
45 #include
46 #include
47 #include
48 #include
49 #include
50
2651 using namespace llvm;
2752
2853 namespace {
54
2955 struct OrderMap {
3056 DenseMap> IDs;
31 unsigned LastGlobalConstantID;
32 unsigned LastGlobalValueID;
33
34 OrderMap() : LastGlobalConstantID(0), LastGlobalValueID(0) {}
57 unsigned LastGlobalConstantID = 0;
58 unsigned LastGlobalValueID = 0;
59
60 OrderMap() = default;
3561
3662 bool isGlobalConstant(unsigned ID) const {
3763 return ID <= LastGlobalConstantID;
3864 }
65
3966 bool isGlobalValue(unsigned ID) const {
4067 return ID <= LastGlobalValueID && !isGlobalConstant(ID);
4168 }
4269
4370 unsigned size() const { return IDs.size(); }
4471 std::pair &operator[](const Value *V) { return IDs[V]; }
72
4573 std::pair lookup(const Value *V) const {
4674 return IDs.lookup(V);
4775 }
76
4877 void index(const Value *V) {
4978 // Explicitly sequence get-size and insert-value operations to avoid UB.
5079 unsigned ID = IDs.size() + 1;
5180 IDs[V].first = ID;
5281 }
5382 };
54 }
83
84 } // end anonymous namespace
5585
5686 static void orderValue(const Value *V, OrderMap &OM) {
5787 if (OM.lookup(V).first)
140170 unsigned ID, const OrderMap &OM,
141171 UseListOrderStack &Stack) {
142172 // Predict use-list order for this one.
143 typedef std::pair Entry;
173 using Entry = std::pair;
144174 SmallVector List;
145175 for (const Use &U : V->uses())
146176 // Check if this user will be serialized.
445475
446476 void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map,
447477 const char *Name) const {
448
449478 OS << "Map Name: " << Name << "\n";
450479 OS << "Size: " << Map.size() << "\n";
451480 for (ValueMapType::const_iterator I = Map.begin(),
452481 E = Map.end(); I != E; ++I) {
453
454482 const Value *V = I->first;
455483 if (V->hasName())
456484 OS << "Value: " << V->getName();
475503
476504 void ValueEnumerator::print(raw_ostream &OS, const MetadataMapType &Map,
477505 const char *Name) const {
478
479506 OS << "Map Name: " << Name << "\n";
480507 OS << "Size: " << Map.size() << "\n";
481508 for (auto I = Map.begin(), E = Map.end(); I != E; ++I) {
516543 for (; CstStart != CstEnd; ++CstStart)
517544 ValueMap[Values[CstStart].first] = CstStart+1;
518545 }
519
520546
521547 /// EnumerateValueSymbolTable - Insert all of the values in the specified symbol
522548 /// table into the values table.
None //===-- Bitcode/Writer/ValueEnumerator.h - Number values --------*- C++ -*-===//
0 //===- Bitcode/Writer/ValueEnumerator.h - Number values ---------*- C++ -*-===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1313 #ifndef LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
1414 #define LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
1515
16 #include "llvm/ADT/ArrayRef.h"
1617 #include "llvm/ADT/DenseMap.h"
1718 #include "llvm/ADT/UniqueVector.h"
1819 #include "llvm/IR/Attributes.h"
19 #include "llvm/IR/Metadata.h"
20 #include "llvm/IR/Type.h"
2120 #include "llvm/IR/UseListOrder.h"
21 #include
22 #include
23 #include
2224 #include
2325
2426 namespace llvm {
2527
26 class Type;
27 class Value;
28 class Instruction;
2928 class BasicBlock;
3029 class Comdat;
3130 class Function;
32 class Module;
33 class Metadata;
31 class Instruction;
3432 class LocalAsMetadata;
3533 class MDNode;
36 class MDOperand;
34 class Metadata;
35 class Module;
3736 class NamedMDNode;
38 class AttributeList;
37 class raw_ostream;
38 class Type;
39 class Value;
3940 class ValueSymbolTable;
40 class MDSymbolTable;
41 class raw_ostream;
4241
4342 class ValueEnumerator {
4443 public:
45 typedef std::vector TypeList;
44 using TypeList = std::vector;
4645
4746 // For each value, we remember its Value* and occurrence frequency.
48 typedef std::vector > ValueList;
47 using ValueList = std::vector>;
4948
5049 /// Attribute groups as encoded in bitcode are almost AttributeSets, but they
5150 /// include the AttributeList index, so we have to track that in our map.
52 typedef std::pair IndexAndAttrSet;
51 using IndexAndAttrSet = std::pair;
5352
5453 UseListOrderStack UseListOrders;
5554
5655 private:
57 typedef DenseMap TypeMapType;
56 using TypeMapType = DenseMap;
5857 TypeMapType TypeMap;
5958 TypeList Types;
6059
61 typedef DenseMap ValueMapType;
60 using ValueMapType = DenseMap;
6261 ValueMapType ValueMap;
6362 ValueList Values;
6463
65 typedef UniqueVector ComdatSetType;
64 using ComdatSetType = UniqueVector;
6665 ComdatSetType Comdats;
6766
6867 std::vector MDs;
8786 }
8887 };
8988
90 typedef DenseMap MetadataMapType;
89 using MetadataMapType = DenseMap;
9190 MetadataMapType MetadataMap;
9291
9392 /// Range of metadata IDs, as a half-open range.
9897 /// Number of strings in the prefix of the metadata range.
9998 unsigned NumStrings = 0;
10099
101 MDRange() {}
100 MDRange() = default;
102101 explicit MDRange(unsigned First) : First(First) {}
103102 };
104103 SmallDenseMap FunctionMDInfo;
105104
106105 bool ShouldPreserveUseListOrder;
107106
108 typedef DenseMap AttributeGroupMapType;
107 using AttributeGroupMapType = DenseMap;
109108 AttributeGroupMapType AttributeGroupMap;
110109 std::vector AttributeGroups;
111110
112 typedef DenseMap AttributeListMapType;
111 using AttributeListMapType = DenseMap;
113112 AttributeListMapType AttributeListMap;
114113 std::vector AttributeLists;
115114
117116 /// the "getGlobalBasicBlockID" method.
118117 mutable DenseMap GlobalBasicBlockIDs;
119118
120 typedef DenseMap InstructionMapType;
119 using InstructionMapType = DenseMap;
121120 InstructionMapType InstructionMap;
122121 unsigned InstructionCount;
123122
137136 unsigned FirstFuncConstantID;
138137 unsigned FirstInstID;
139138
140 ValueEnumerator(const ValueEnumerator &) = delete;
141 void operator=(const ValueEnumerator &) = delete;
142139 public:
143140 ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder);
141 ValueEnumerator(const ValueEnumerator &) = delete;
142 ValueEnumerator &operator=(const ValueEnumerator &) = delete;
144143
145144 void dump() const;
146145 void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const;
148147 const char *Name) const;
149148
150149 unsigned getValueID(const Value *V) const;
150
151151 unsigned getMetadataID(const Metadata *MD) const {
152152 auto ID = getMetadataOrNullID(MD);
153153 assert(ID != 0 && "Metadata not in slotcalculator!");
154154 return ID - 1;
155155 }
156
156157 unsigned getMetadataOrNullID(const Metadata *MD) const {
157158 return MetadataMap.lookup(MD).ID;
158159 }
160
159161 unsigned numMDs() const { return MDs.size(); }
160162
161163 bool shouldPreserveUseListOrder() const { return ShouldPreserveUseListOrder; }
207209 }
208210
209211 const TypeList &getTypes() const { return Types; }
212
210213 const std::vector &getBasicBlocks() const {
211214 return BasicBlocks;
212215 }
216
213217 const std::vector &getAttributeLists() const { return AttributeLists; }
218
214219 const std::vector &getAttributeGroups() const {
215220 return AttributeGroups;
216221 }
225230
226231 /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
227232 /// use these two methods to get its data into the ValueEnumerator!
228 ///
229233 void incorporateFunction(const Function &F);
234
230235 void purgeFunction();
231236 uint64_t computeBitsRequiredForTypeIndicies() const;
232237
291296 void EnumerateNamedMetadata(const Module &M);
292297 };
293298
294 } // End llvm namespace
295
296 #endif
299 } // end namespace llvm
300
301 #endif // LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
None //===-- llvm-cat.cpp - LLVM module concatenation utility ------------------===//
0 //===- llvm-cat.cpp - LLVM module concatenation utility -------------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1212 //
1313 //===----------------------------------------------------------------------===//
1414
15 #include "llvm/ADT/SmallVector.h"
1516 #include "llvm/Bitcode/BitcodeReader.h"
1617 #include "llvm/Bitcode/BitcodeWriter.h"
18 #include "llvm/IR/LLVMContext.h"
19 #include "llvm/IR/Module.h"
1720 #include "llvm/IRReader/IRReader.h"
1821 #include "llvm/Support/CommandLine.h"
22 #include "llvm/Support/Error.h"
1923 #include "llvm/Support/FileSystem.h"
24 #include "llvm/Support/MemoryBuffer.h"
25 #include "llvm/Support/SourceMgr.h"
26 #include "llvm/Support/raw_ostream.h"
27 #include
28 #include
29 #include
30 #include
31 #include
2032
2133 using namespace llvm;
2234
6981 std::error_code EC;
7082 raw_fd_ostream OS(OutputFilename, EC, sys::fs::OpenFlags::F_None);
7183 if (EC) {
72 llvm::errs() << argv[0] << ": cannot open " << OutputFilename
73 << " for writing: " << EC.message();
84 errs() << argv[0] << ": cannot open " << OutputFilename << " for writing: "
85 << EC.message();
7486 return 1;
7587 }
7688
None //===-- llvm-lto: a simple command-line program to link modules with LTO --===//
0 //===- llvm-lto: a simple command-line program to link modules with LTO ---===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "llvm-c/lto.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/SmallString.h"
18 #include "llvm/ADT/StringExtras.h"
19 #include "llvm/ADT/StringRef.h"
1420 #include "llvm/ADT/StringSet.h"
21 #include "llvm/ADT/Twine.h"
1522 #include "llvm/Bitcode/BitcodeReader.h"
1623 #include "llvm/Bitcode/BitcodeWriter.h"
1724 #include "llvm/CodeGen/CommandFlags.h"
25 #include "llvm/IR/DiagnosticInfo.h"
1826 #include "llvm/IR/DiagnosticPrinter.h"
1927 #include "llvm/IR/LLVMContext.h"
28 #include "llvm/IR/Module.h"
29 #include "llvm/IR/ModuleSummaryIndex.h"
2030 #include "llvm/IR/Verifier.h"
2131 #include "llvm/IRReader/IRReader.h"
2232 #include "llvm/LTO/legacy/LTOCodeGenerator.h"
2333 #include "llvm/LTO/legacy/LTOModule.h"
2434 #include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
35 #include "llvm/Support/Allocator.h"
36 #include "llvm/Support/Casting.h"
2537 #include "llvm/Support/CommandLine.h"
38 #include "llvm/Support/Error.h"
39 #include "llvm/Support/ErrorHandling.h"
40 #include "llvm/Support/ErrorOr.h"
2641 #include "llvm/Support/FileSystem.h"
2742 #include "llvm/Support/ManagedStatic.h"
43 #include "llvm/Support/MemoryBuffer.h"
2844 #include "llvm/Support/Path.h"
2945 #include "llvm/Support/PrettyStackTrace.h"
3046 #include "llvm/Support/Signals.h"
3248 #include "llvm/Support/TargetSelect.h"
3349 #include "llvm/Support/ToolOutputFile.h"
3450 #include "llvm/Support/raw_ostream.h"
51 #include "llvm/Target/TargetOptions.h"
52 #include
53 #include
54 #include
55 #include
3556 #include
57 #include
58 #include
59 #include
60 #include
61 #include
62 #include
63 #include
3664
3765 using namespace llvm;
3866
178206 cl::desc("Only check if the module has objective-C defined in it"));
179207
180208 namespace {
209
181210 struct ModuleInfo {
182211 std::vector CanBeHidden;
183212 };
184 }
213
214 } // end anonymous namespace
185215
186216 static void handleDiagnostics(lto_codegen_diagnostic_severity_t Severity,
187217 const char *Msg, void *) {
276306 for (auto &Filename : InputFilenames) {
277307 ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': ");
278308 std::unique_ptr Index =
279 ExitOnErr(llvm::getModuleSummaryIndexForFile(Filename));
309 ExitOnErr(getModuleSummaryIndexForFile(Filename));
280310 // Skip files without a module summary.
281311 if (!Index)
282312 report_fatal_error(Filename + " does not contain an index");
395425 report_fatal_error("Missing -thinlto-index for ThinLTO promotion stage");
396426 ExitOnError ExitOnErr("llvm-lto: error loading file '" + ThinLTOIndex +
397427 "': ");
398 return ExitOnErr(llvm::getModuleSummaryIndexForFile(ThinLTOIndex));
428 return ExitOnErr(getModuleSummaryIndexForFile(ThinLTOIndex));
399429 }
400430
401431 static std::unique_ptr loadModule(StringRef Filename,
488518 raw_fd_ostream OS(OutputFilename, EC, sys::fs::OpenFlags::F_None);
489519 error(EC, "error opening the file '" + OutputFilename + "'");
490520 WriteIndexToFile(*CombinedIndex, OS);
491 return;
492521 }
493522
494523 /// Load the combined index from disk, then compute and generate
744773 /// Load the combined index from disk, then load every file referenced by
745774 };
746775
747 } // namespace thinlto
776 } // end namespace thinlto
748777
749778 int main(int argc, char **argv) {
750779 // Print a stack trace if we signal out.
783812 std::unique_ptr BufferOrErr =
784813 ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(Filename)));
785814 auto Buffer = std::move(BufferOrErr.get());
786 if (ExitOnErr(llvm::isBitcodeContainingObjCCategory(*Buffer)))
815 if (ExitOnErr(isBitcodeContainingObjCCategory(*Buffer)))
787816 outs() << "Bitcode " << Filename << " contains ObjC\n";
788817 else
789818 outs() << "Bitcode " << Filename << " does not contain ObjC\n";
821850 CodeGen.setTargetOptions(Options);
822851 CodeGen.setShouldRestoreGlobalsLinkage(RestoreGlobalsLinkage);
823852
824 llvm::StringSetMallocAllocator> DSOSymbolsSet;
853 StringSet<MallocAllocator> DSOSymbolsSet;
825854 for (unsigned i = 0; i < DSOSymbols.size(); ++i)
826855 DSOSymbolsSet.insert(DSOSymbols[i]);
827856