1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[Bitcode] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 312760
This commit is contained in:
Eugene Zelenko 2017-09-07 23:28:24 +00:00
parent b5c890aa13
commit d3b4cc91a1
11 changed files with 312 additions and 158 deletions

View File

@ -1,4 +1,4 @@
//===-- llvm/Bitcode/BitcodeReader.h - Bitcode reader ----*- C++ -*-===//
//===- llvm/Bitcode/BitcodeReader.h - Bitcode reader ------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -14,18 +14,23 @@
#ifndef LLVM_BITCODE_BITCODEREADER_H
#define LLVM_BITCODE_BITCODEREADER_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Bitcode/BitCodes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h"
#include <cstdint>
#include <memory>
#include <string>
#include <system_error>
#include <vector>
namespace llvm {
class LLVMContext;
class Module;
class LLVMContext;
class Module;
// These functions are for converting Expected/Error values to
// ErrorOr/std::error_code for compatibility with legacy clients. FIXME:
@ -81,6 +86,7 @@ namespace llvm {
StringRef getBuffer() const {
return StringRef((const char *)Buffer.begin(), Buffer.size());
}
StringRef getStrtab() const { return Strtab; }
StringRef getModuleIdentifier() const { return ModuleIdentifier; }
@ -182,7 +188,6 @@ namespace llvm {
/// isBitcodeWrapper - Return true if the given bytes are the magic bytes
/// for an LLVM IR bitcode wrapper.
///
inline bool isBitcodeWrapper(const unsigned char *BufPtr,
const unsigned char *BufEnd) {
// See if you can find the hidden message in the magic bytes :-).
@ -196,7 +201,6 @@ namespace llvm {
/// isRawBitcode - Return true if the given bytes are the magic bytes for
/// raw LLVM IR bitcode (without a wrapper).
///
inline bool isRawBitcode(const unsigned char *BufPtr,
const unsigned char *BufEnd) {
// These bytes sort of have a hidden message, but it's not in
@ -210,7 +214,6 @@ namespace llvm {
/// isBitcode - Return true if the given bytes are the magic bytes for
/// LLVM IR bitcode, either with or without a wrapper.
///
inline bool isBitcode(const unsigned char *BufPtr,
const unsigned char *BufEnd) {
return isBitcodeWrapper(BufPtr, BufEnd) ||
@ -258,10 +261,12 @@ namespace llvm {
return std::error_code(static_cast<int>(E), BitcodeErrorCategory());
}
} // End llvm namespace
} // end namespace llvm
namespace std {
template <> struct is_error_code_enum<llvm::BitcodeError> : std::true_type {};
}
#endif
template <> struct is_error_code_enum<llvm::BitcodeError> : std::true_type {};
} // end namespace std
#endif // LLVM_BITCODE_BITCODEREADER_H

View File

@ -1,4 +1,4 @@
//===-- llvm/Bitcode/BitcodeWriter.h - Bitcode writers ----*- C++ -*-===//
//===- llvm/Bitcode/BitcodeWriter.h - Bitcode writers -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -14,14 +14,20 @@
#ifndef LLVM_BITCODE_BITCODEWRITER_H
#define LLVM_BITCODE_BITCODEWRITER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/Allocator.h"
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace llvm {
class BitstreamWriter;
class Module;
class raw_ostream;
class BitstreamWriter;
class Module;
class raw_ostream;
class BitcodeWriter {
SmallVectorImpl<char> &Buffer;
@ -39,7 +45,7 @@ namespace llvm {
std::vector<Module *> Mods;
public:
public:
/// Create a BitcodeWriter that writes to Buffer.
BitcodeWriter(SmallVectorImpl<char> &Buffer);
@ -145,6 +151,7 @@ namespace llvm {
void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out,
const std::map<std::string, GVSummaryMapTy>
*ModuleToSummariesForIndex = nullptr);
} // End llvm namespace
#endif
} // end namespace llvm
#endif // LLVM_BITCODE_BITCODEWRITER_H

View File

@ -43,7 +43,7 @@ public:
unsigned BlockID;
std::vector<std::shared_ptr<BitCodeAbbrev>> Abbrevs;
std::string Name;
std::vector<std::pair<unsigned, std::string> > RecordNames;
std::vector<std::pair<unsigned, std::string>> RecordNames;
};
private:
@ -88,7 +88,7 @@ public:
/// follow the word size of the host machine for efficiency. We use word_t in
/// places that are aware of this to make it perfectly explicit what is going
/// on.
typedef size_t word_t;
using word_t = size_t;
private:
word_t CurWord = 0;

View File

@ -10,12 +10,11 @@
#include "llvm/Bitcode/BitcodeReader.h"
#include "MetadataLoader.h"
#include "ValueList.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
@ -33,12 +32,11 @@
#include "llvm/IR/Comdat.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GVMaterializer.h"
#include "llvm/IR/GlobalAlias.h"
@ -54,13 +52,12 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/OperandTraits.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/TrackingMDRef.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
@ -69,7 +66,9 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@ -77,9 +76,9 @@
#include <cstddef>
#include <cstdint>
#include <deque>
#include <limits>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <system_error>
#include <tuple>
@ -99,13 +98,15 @@ enum {
SWITCH_INST_MAGIC = 0x4B5 // May 2012 => 1205 => Hex
};
Error error(const Twine &Message) {
} // end anonymous namespace
static Error error(const Twine &Message) {
return make_error<StringError>(
Message, make_error_code(BitcodeError::CorruptedBitcode));
}
/// Helper to read the header common to all bitcode files.
bool hasValidBitcodeHeader(BitstreamCursor &Stream) {
static bool hasValidBitcodeHeader(BitstreamCursor &Stream) {
// Sniff for the signature.
if (!Stream.canSkipToPos(4) ||
Stream.Read(8) != 'B' ||
@ -118,7 +119,7 @@ bool hasValidBitcodeHeader(BitstreamCursor &Stream) {
return true;
}
Expected<BitstreamCursor> initStream(MemoryBufferRef Buffer) {
static Expected<BitstreamCursor> initStream(MemoryBufferRef Buffer) {
const unsigned char *BufPtr = (const unsigned char *)Buffer.getBufferStart();
const unsigned char *BufEnd = BufPtr + Buffer.getBufferSize();
@ -151,7 +152,7 @@ static bool convertToString(ArrayRef<uint64_t> Record, unsigned Idx,
}
// Strip all the TBAA attachment for the module.
void stripTBAA(Module *M) {
static void stripTBAA(Module *M) {
for (auto &F : *M) {
if (F.isMaterializable())
continue;
@ -162,7 +163,7 @@ void stripTBAA(Module *M) {
/// Read the "IDENTIFICATION_BLOCK_ID" block, do some basic enforcement on the
/// "epoch" encoded in the bitcode, and return the producer name if any.
Expected<std::string> readIdentificationBlock(BitstreamCursor &Stream) {
static Expected<std::string> readIdentificationBlock(BitstreamCursor &Stream) {
if (Stream.EnterSubBlock(bitc::IDENTIFICATION_BLOCK_ID))
return error("Invalid record");
@ -206,7 +207,7 @@ Expected<std::string> readIdentificationBlock(BitstreamCursor &Stream) {
}
}
Expected<std::string> readIdentificationCode(BitstreamCursor &Stream) {
static Expected<std::string> readIdentificationCode(BitstreamCursor &Stream) {
// We expect a number of well-defined blocks, though we don't necessarily
// need to understand them all.
while (true) {
@ -234,7 +235,7 @@ Expected<std::string> readIdentificationCode(BitstreamCursor &Stream) {
}
}
Expected<bool> hasObjCCategoryInModule(BitstreamCursor &Stream) {
static Expected<bool> hasObjCCategoryInModule(BitstreamCursor &Stream) {
if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
return error("Invalid record");
@ -275,7 +276,7 @@ Expected<bool> hasObjCCategoryInModule(BitstreamCursor &Stream) {
llvm_unreachable("Exit infinite loop");
}
Expected<bool> hasObjCCategory(BitstreamCursor &Stream) {
static Expected<bool> hasObjCCategory(BitstreamCursor &Stream) {
// We expect a number of well-defined blocks, though we don't necessarily
// need to understand them all.
while (true) {
@ -303,7 +304,7 @@ Expected<bool> hasObjCCategory(BitstreamCursor &Stream) {
}
}
Expected<std::string> readModuleTriple(BitstreamCursor &Stream) {
static Expected<std::string> readModuleTriple(BitstreamCursor &Stream) {
if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
return error("Invalid record");
@ -342,7 +343,7 @@ Expected<std::string> readModuleTriple(BitstreamCursor &Stream) {
llvm_unreachable("Exit infinite loop");
}
Expected<std::string> readTriple(BitstreamCursor &Stream) {
static Expected<std::string> readTriple(BitstreamCursor &Stream) {
// We expect a number of well-defined blocks, though we don't necessarily
// need to understand them all.
while (true) {
@ -370,6 +371,8 @@ Expected<std::string> readTriple(BitstreamCursor &Stream) {
}
}
namespace {
class BitcodeReaderBase {
protected:
BitcodeReaderBase(BitstreamCursor Stream, StringRef Strtab)
@ -401,6 +404,8 @@ protected:
Error error(const Twine &Message);
};
} // end anonymous namespace
Error BitcodeReaderBase::error(const Twine &Message) {
std::string FullMsg = Message.str();
if (!ProducerIdentification.empty())
@ -411,7 +416,7 @@ Error BitcodeReaderBase::error(const Twine &Message) {
Expected<unsigned>
BitcodeReaderBase::parseVersionRecord(ArrayRef<uint64_t> Record) {
if (Record.size() < 1)
if (Record.empty())
return error("Invalid record");
unsigned ModuleVersion = Record[0];
if (ModuleVersion > 2)
@ -430,6 +435,8 @@ BitcodeReaderBase::readNameFromStrtab(ArrayRef<uint64_t> Record) {
return {StringRef(Strtab.data() + Record[0], Record[1]), Record.slice(2)};
}
namespace {
class BitcodeReader : public BitcodeReaderBase, public GVMaterializer {
LLVMContext &Context;
Module *TheModule = nullptr;
@ -449,11 +456,11 @@ class BitcodeReader : public BitcodeReaderBase, public GVMaterializer {
std::vector<Comdat *> ComdatList;
SmallVector<Instruction *, 64> InstructionList;
std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits;
std::vector<std::pair<GlobalIndirectSymbol*, unsigned> > IndirectSymbolInits;
std::vector<std::pair<Function*, unsigned> > FunctionPrefixes;
std::vector<std::pair<Function*, unsigned> > FunctionPrologues;
std::vector<std::pair<Function*, unsigned> > FunctionPersonalityFns;
std::vector<std::pair<GlobalVariable *, unsigned>> GlobalInits;
std::vector<std::pair<GlobalIndirectSymbol *, unsigned>> IndirectSymbolInits;
std::vector<std::pair<Function *, unsigned>> FunctionPrefixes;
std::vector<std::pair<Function *, unsigned>> FunctionPrologues;
std::vector<std::pair<Function *, unsigned>> FunctionPersonalityFns;
/// The set of attributes by index. Index zero in the file is for null, and
/// is thus not represented here. As such all indices are off by one.
@ -472,7 +479,7 @@ class BitcodeReader : public BitcodeReaderBase, public GVMaterializer {
// When intrinsic functions are encountered which require upgrading they are
// stored here with their replacement function.
typedef DenseMap<Function*, Function*> UpdatedIntrinsicMap;
using UpdatedIntrinsicMap = DenseMap<Function *, Function *>;
UpdatedIntrinsicMap UpgradedIntrinsics;
// Intrinsics which were remangled because of types rename
UpdatedIntrinsicMap RemangledIntrinsics;
@ -1051,7 +1058,6 @@ static void upgradeDLLImportExportLinkage(GlobalValue *GV, unsigned Val) {
}
}
Type *BitcodeReader::getTypeByID(unsigned ID) {
// The type table size is always specified correctly.
if (ID >= TypeList.size())
@ -1226,7 +1232,7 @@ Error BitcodeReader::parseAttributeBlock() {
switch (Stream.readRecord(Entry.ID, Record)) {
default: // Default behavior: ignore.
break;
case bitc::PARAMATTR_CODE_ENTRY_OLD: { // ENTRY: [paramidx0, attr0, ...]
case bitc::PARAMATTR_CODE_ENTRY_OLD: // ENTRY: [paramidx0, attr0, ...]
// FIXME: Remove in 4.0.
if (Record.size() & 1)
return error("Invalid record");
@ -1240,8 +1246,7 @@ Error BitcodeReader::parseAttributeBlock() {
MAttributes.push_back(AttributeList::get(Context, Attrs));
Attrs.clear();
break;
}
case bitc::PARAMATTR_CODE_ENTRY: { // ENTRY: [attrgrp0, attrgrp1, ...]
case bitc::PARAMATTR_CODE_ENTRY: // ENTRY: [attrgrp0, attrgrp1, ...]
for (unsigned i = 0, e = Record.size(); i != e; ++i)
Attrs.push_back(MAttributeGroups[Record[i]]);
@ -1249,7 +1254,6 @@ Error BitcodeReader::parseAttributeBlock() {
Attrs.clear();
break;
}
}
}
}
@ -2000,12 +2004,12 @@ uint64_t BitcodeReader::decodeSignRotatedValue(uint64_t V) {
/// Resolve all of the initializers for global values and aliases that we can.
Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() {
std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInitWorklist;
std::vector<std::pair<GlobalIndirectSymbol*, unsigned> >
std::vector<std::pair<GlobalVariable *, unsigned>> GlobalInitWorklist;
std::vector<std::pair<GlobalIndirectSymbol *, unsigned>>
IndirectSymbolInitWorklist;
std::vector<std::pair<Function*, unsigned> > FunctionPrefixWorklist;
std::vector<std::pair<Function*, unsigned> > FunctionPrologueWorklist;
std::vector<std::pair<Function*, unsigned> > FunctionPersonalityFnWorklist;
std::vector<std::pair<Function *, unsigned>> FunctionPrefixWorklist;
std::vector<std::pair<Function *, unsigned>> FunctionPrologueWorklist;
std::vector<std::pair<Function *, unsigned>> FunctionPersonalityFnWorklist;
GlobalInitWorklist.swap(GlobalInits);
IndirectSymbolInitWorklist.swap(IndirectSymbolInits);
@ -2719,8 +2723,8 @@ Error BitcodeReader::globalCleanup() {
// Force deallocation of memory for these vectors to favor the client that
// want lazy deserialization.
std::vector<std::pair<GlobalVariable*, unsigned> >().swap(GlobalInits);
std::vector<std::pair<GlobalIndirectSymbol*, unsigned> >().swap(
std::vector<std::pair<GlobalVariable *, unsigned>>().swap(GlobalInits);
std::vector<std::pair<GlobalIndirectSymbol *, unsigned>>().swap(
IndirectSymbolInits);
return Error::success();
}
@ -2777,7 +2781,7 @@ Error BitcodeReader::parseComdatRecord(ArrayRef<uint64_t> Record) {
StringRef Name;
std::tie(Name, Record) = readNameFromStrtab(Record);
if (Record.size() < 1)
if (Record.empty())
return error("Invalid record");
Comdat::SelectionKind SK = getDecodedComdatSelectionKind(Record[0]);
std::string OldFormatName;
@ -3244,28 +3248,24 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit,
GCTable.push_back(S);
break;
}
case bitc::MODULE_CODE_COMDAT: {
case bitc::MODULE_CODE_COMDAT:
if (Error Err = parseComdatRecord(Record))
return Err;
break;
}
case bitc::MODULE_CODE_GLOBALVAR: {
case bitc::MODULE_CODE_GLOBALVAR:
if (Error Err = parseGlobalVarRecord(Record))
return Err;
break;
}
case bitc::MODULE_CODE_FUNCTION: {
case bitc::MODULE_CODE_FUNCTION:
if (Error Err = parseFunctionRecord(Record))
return Err;
break;
}
case bitc::MODULE_CODE_IFUNC:
case bitc::MODULE_CODE_ALIAS:
case bitc::MODULE_CODE_ALIAS_OLD: {
case bitc::MODULE_CODE_ALIAS_OLD:
if (Error Err = parseGlobalIndirectSymbolRecord(BitCode, Record))
return Err;
break;
}
/// MODULE_CODE_VSTOFFSET: [offset]
case bitc::MODULE_CODE_VSTOFFSET:
if (Record.size() < 1)
@ -3295,7 +3295,6 @@ Error BitcodeReader::parseBitcodeInto(Module *M, bool ShouldLazyLoadMetadata,
return parseModule(0, ShouldLazyLoadMetadata);
}
Error BitcodeReader::typeCheckLoadStoreInst(Type *ValType, Type *PtrType) {
if (!isa<PointerType>(PtrType))
return error("Load/Store operand is not a pointer type");
@ -5299,34 +5298,34 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
LastSeenGUID = 0;
break;
}
case bitc::FS_TYPE_TESTS: {
case bitc::FS_TYPE_TESTS:
assert(PendingTypeTests.empty());
PendingTypeTests.insert(PendingTypeTests.end(), Record.begin(),
Record.end());
break;
}
case bitc::FS_TYPE_TEST_ASSUME_VCALLS: {
case bitc::FS_TYPE_TEST_ASSUME_VCALLS:
assert(PendingTypeTestAssumeVCalls.empty());
for (unsigned I = 0; I != Record.size(); I += 2)
PendingTypeTestAssumeVCalls.push_back({Record[I], Record[I+1]});
break;
}
case bitc::FS_TYPE_CHECKED_LOAD_VCALLS: {
case bitc::FS_TYPE_CHECKED_LOAD_VCALLS:
assert(PendingTypeCheckedLoadVCalls.empty());
for (unsigned I = 0; I != Record.size(); I += 2)
PendingTypeCheckedLoadVCalls.push_back({Record[I], Record[I+1]});
break;
}
case bitc::FS_TYPE_TEST_ASSUME_CONST_VCALL: {
case bitc::FS_TYPE_TEST_ASSUME_CONST_VCALL:
PendingTypeTestAssumeConstVCalls.push_back(
{{Record[0], Record[1]}, {Record.begin() + 2, Record.end()}});
break;
}
case bitc::FS_TYPE_CHECKED_LOAD_CONST_VCALL: {
case bitc::FS_TYPE_CHECKED_LOAD_CONST_VCALL:
PendingTypeCheckedLoadConstVCalls.push_back(
{{Record[0], Record[1]}, {Record.begin() + 2, Record.end()}});
break;
}
case bitc::FS_CFI_FUNCTION_DEFS: {
std::set<std::string> &CfiFunctionDefs = TheIndex.cfiFunctionDefs();
for (unsigned I = 0; I != Record.size(); I += 2)
@ -5417,6 +5416,7 @@ class BitcodeErrorCategoryType : public std::error_category {
const char *name() const noexcept override {
return "llvm.bitcode";
}
std::string message(int IE) const override {
BitcodeError E = static_cast<BitcodeError>(IE);
switch (E) {
@ -5441,7 +5441,7 @@ static Expected<StringRef> readBlobInRecord(BitstreamCursor &Stream,
return error("Invalid record");
StringRef Strtab;
while (1) {
while (true) {
BitstreamEntry Entry = Stream.advance();
switch (Entry.Kind) {
case BitstreamEntry::EndBlock:

View File

@ -1,4 +1,4 @@
//===----- ValueList.cpp - Internal BitcodeReader implementation ----------===//
//===- ValueList.cpp - Internal BitcodeReader implementation --------------===//
//
// The LLVM Compiler Infrastructure
//
@ -8,27 +8,44 @@
//===----------------------------------------------------------------------===//
#include "ValueList.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <limits>
#include <utility>
using namespace llvm;
namespace llvm {
namespace {
/// \brief A class for maintaining the slot number definition
/// as a placeholder for the actual definition for forward constants defs.
class ConstantPlaceHolder : public ConstantExpr {
void operator=(const ConstantPlaceHolder &) = delete;
public:
// allocate space for exactly one operand
void *operator new(size_t s) { return User::operator new(s, 1); }
explicit ConstantPlaceHolder(Type *Ty, LLVMContext &Context)
: ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) {
Op<0>() = UndefValue::get(Type::getInt32Ty(Context));
}
ConstantPlaceHolder &operator=(const ConstantPlaceHolder &) = delete;
// allocate space for exactly one operand
void *operator new(size_t s) { return User::operator new(s, 1); }
/// \brief Methods to support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Value *V) {
return isa<ConstantExpr>(V) &&

View File

@ -1,4 +1,4 @@
//===-- Bitcode/Reader/ValueEnumerator.h - Number values --------*- C++ -*-===//
//===-- Bitcode/Reader/ValueList.h - Number values --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -11,13 +11,20 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/ValueHandle.h"
#ifndef LLVM_LIB_BITCODE_READER_VALUELIST_H
#define LLVM_LIB_BITCODE_READER_VALUELIST_H
#include "llvm/IR/ValueHandle.h"
#include <cassert>
#include <utility>
#include <vector>
namespace llvm {
class Constant;
class LLVMContext;
class Type;
class Value;
class BitcodeReaderValueList {
std::vector<WeakTrackingVH> ValuePtrs;
@ -29,12 +36,13 @@ class BitcodeReaderValueList {
///
/// The key of this vector is the placeholder constant, the value is the slot
/// number that holds the resolved value.
typedef std::vector<std::pair<Constant *, unsigned>> ResolveConstantsTy;
using ResolveConstantsTy = std::vector<std::pair<Constant *, unsigned>>;
ResolveConstantsTy ResolveConstants;
LLVMContext &Context;
public:
BitcodeReaderValueList(LLVMContext &C) : Context(C) {}
~BitcodeReaderValueList() {
assert(ResolveConstants.empty() && "Constants not resolved?");
}
@ -73,4 +81,6 @@ public:
void resolveConstantForwardRefs();
};
} // namespace llvm
} // end namespace llvm
#endif // LLVM_LIB_BITCODE_READER_VALUELIST_H

View File

@ -1,4 +1,4 @@
//===--- Bitcode/Writer/BitcodeWriter.cpp - Bitcode Writer ----------------===//
//===- Bitcode/Writer/BitcodeWriter.cpp - Bitcode Writer ------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -13,39 +13,81 @@
#include "llvm/Bitcode/BitcodeWriter.h"
#include "ValueEnumerator.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitCodes.h"
#include "llvm/Bitcode/BitstreamWriter.h"
#include "llvm/Bitcode/LLVMBitCodes.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Comdat.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalIFunc.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/UseListOrder.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Object/IRSymtab.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/SHA1.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include <cctype>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
using namespace llvm;
namespace {
cl::opt<unsigned>
static cl::opt<unsigned>
IndexThreshold("bitcode-mdindex-threshold", cl::Hidden, cl::init(25),
cl::desc("Number of metadatas above which we emit an index "
"to enable lazy-loading"));
namespace {
/// These are manifest constants used by the bitcode writer. They do not need to
/// be kept in sync with the reader, but need to be consistent within this file.
enum {
@ -169,6 +211,7 @@ private:
void assignValueId(GlobalValue::GUID ValGUID) {
GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
}
unsigned getValueId(GlobalValue::GUID ValGUID) {
const auto &VMI = GUIDToValueIdMap.find(ValGUID);
// Expect that any GUID value had a value Id assigned by an
@ -177,12 +220,14 @@ private:
"GUID does not have assigned value Id");
return VMI->second;
}
// Helper to get the valueId for the type of value recorded in VI.
unsigned getValueId(ValueInfo VI) {
if (!VI.getValue())
return getValueId(VI.getGUID());
return VE.getValueID(VI.getValue());
}
std::map<GlobalValue::GUID, unsigned> &valueIds() { return GUIDToValueIdMap; }
};
@ -374,7 +419,7 @@ public:
}
/// The below iterator returns the GUID and associated summary.
typedef std::pair<GlobalValue::GUID, GlobalValueSummary *> GVInfo;
using GVInfo = std::pair<GlobalValue::GUID, GlobalValueSummary *>;
/// Calls the callback for each value GUID and summary to be written to
/// bitcode. This hides the details of whether they are being pulled from the
@ -428,8 +473,10 @@ private:
return None;
return VMI->second;
}
std::map<GlobalValue::GUID, unsigned> &valueIds() { return GUIDToValueIdMap; }
};
} // end anonymous namespace
static unsigned getEncodedCastOpcode(unsigned Opcode) {
@ -726,7 +773,6 @@ void ModuleBitcodeWriter::writeTypeTable() {
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
// Abbrev for TYPE_CODE_STRUCT_ANON.
@ -735,7 +781,6 @@ void ModuleBitcodeWriter::writeTypeTable() {
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
// Abbrev for TYPE_CODE_STRUCT_NAME.
@ -751,7 +796,6 @@ void ModuleBitcodeWriter::writeTypeTable() {
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
// Abbrev for TYPE_CODE_ARRAY.
@ -759,7 +803,6 @@ void ModuleBitcodeWriter::writeTypeTable() {
Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_ARRAY));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // size
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
// Emit an entry count so the reader can reserve space.
@ -2206,7 +2249,7 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
Record.push_back(p[0]);
Record.push_back(p[1]);
} else {
assert (0 && "Unknown FP type!");
assert(0 && "Unknown FP type!");
}
} else if (isa<ConstantDataSequential>(C) &&
cast<ConstantDataSequential>(C)->isString()) {
@ -3051,8 +3094,6 @@ void ModuleBitcodeWriter::writeBlockInfo() {
llvm_unreachable("Unexpected abbrev ordering!");
}
{ // SETTYPE abbrev for CONSTANTS_BLOCK.
auto Abbv = std::make_shared<BitCodeAbbrev>();
Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_SETTYPE));
@ -4032,6 +4073,7 @@ void llvm::WriteIndexToFile(
}
namespace {
/// Class to manage the bitcode writing for a thin link bitcode file.
class ThinLinkBitcodeWriter : public ModuleBitcodeWriterBase {
/// ModHash is for use in ThinLTO incremental build, generated while writing
@ -4052,7 +4094,8 @@ public:
private:
void writeSimplifiedModuleInfo();
};
} // namespace
} // end anonymous namespace
// This function writes a simpilified module info for thin link bitcode file.
// It only contains the source file name along with the name(the offset and

View File

@ -1,4 +1,4 @@
//===-- ValueEnumerator.cpp - Number values and types for bitcode writer --===//
//===- ValueEnumerator.cpp - Number values and types for bitcode writer ---===//
//
// The LLVM Compiler Infrastructure
//
@ -12,47 +12,77 @@
//===----------------------------------------------------------------------===//
#include "ValueEnumerator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/IR/Constants.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalIFunc.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/UseListOrder.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
#include <tuple>
#include <utility>
#include <vector>
using namespace llvm;
namespace {
struct OrderMap {
DenseMap<const Value *, std::pair<unsigned, bool>> IDs;
unsigned LastGlobalConstantID;
unsigned LastGlobalValueID;
unsigned LastGlobalConstantID = 0;
unsigned LastGlobalValueID = 0;
OrderMap() : LastGlobalConstantID(0), LastGlobalValueID(0) {}
OrderMap() = default;
bool isGlobalConstant(unsigned ID) const {
return ID <= LastGlobalConstantID;
}
bool isGlobalValue(unsigned ID) const {
return ID <= LastGlobalValueID && !isGlobalConstant(ID);
}
unsigned size() const { return IDs.size(); }
std::pair<unsigned, bool> &operator[](const Value *V) { return IDs[V]; }
std::pair<unsigned, bool> lookup(const Value *V) const {
return IDs.lookup(V);
}
void index(const Value *V) {
// Explicitly sequence get-size and insert-value operations to avoid UB.
unsigned ID = IDs.size() + 1;
IDs[V].first = ID;
}
};
}
} // end anonymous namespace
static void orderValue(const Value *V, OrderMap &OM) {
if (OM.lookup(V).first)
@ -141,7 +171,7 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F,
unsigned ID, const OrderMap &OM,
UseListOrderStack &Stack) {
// Predict use-list order for this one.
typedef std::pair<const Use *, unsigned> Entry;
using Entry = std::pair<const Use *, unsigned>;
SmallVector<Entry, 64> List;
for (const Use &U : V->uses())
// Check if this user will be serialized.
@ -446,12 +476,10 @@ LLVM_DUMP_METHOD void ValueEnumerator::dump() const {
void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map,
const char *Name) const {
OS << "Map Name: " << Name << "\n";
OS << "Size: " << Map.size() << "\n";
for (ValueMapType::const_iterator I = Map.begin(),
E = Map.end(); I != E; ++I) {
const Value *V = I->first;
if (V->hasName())
OS << "Value: " << V->getName();
@ -476,7 +504,6 @@ void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map,
void ValueEnumerator::print(raw_ostream &OS, const MetadataMapType &Map,
const char *Name) const {
OS << "Map Name: " << Name << "\n";
OS << "Size: " << Map.size() << "\n";
for (auto I = Map.begin(), E = Map.end(); I != E; ++I) {
@ -518,7 +545,6 @@ void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {
ValueMap[Values[CstStart].first] = CstStart+1;
}
/// EnumerateValueSymbolTable - Insert all of the values in the specified symbol
/// table into the values table.
void ValueEnumerator::EnumerateValueSymbolTable(const ValueSymbolTable &VST) {

View File

@ -1,4 +1,4 @@
//===-- Bitcode/Writer/ValueEnumerator.h - Number values --------*- C++ -*-===//
//===- Bitcode/Writer/ValueEnumerator.h - Number values ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -14,56 +14,55 @@
#ifndef LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
#define LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/UniqueVector.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/UseListOrder.h"
#include <cassert>
#include <cstdint>
#include <utility>
#include <vector>
namespace llvm {
class Type;
class Value;
class Instruction;
class BasicBlock;
class Comdat;
class Function;
class Module;
class Metadata;
class Instruction;
class LocalAsMetadata;
class MDNode;
class MDOperand;
class Metadata;
class Module;
class NamedMDNode;
class AttributeList;
class ValueSymbolTable;
class MDSymbolTable;
class raw_ostream;
class Type;
class Value;
class ValueSymbolTable;
class ValueEnumerator {
public:
typedef std::vector<Type*> TypeList;
using TypeList = std::vector<Type *>;
// For each value, we remember its Value* and occurrence frequency.
typedef std::vector<std::pair<const Value*, unsigned> > ValueList;
using ValueList = std::vector<std::pair<const Value *, unsigned>>;
/// Attribute groups as encoded in bitcode are almost AttributeSets, but they
/// include the AttributeList index, so we have to track that in our map.
typedef std::pair<unsigned, AttributeSet> IndexAndAttrSet;
using IndexAndAttrSet = std::pair<unsigned, AttributeSet>;
UseListOrderStack UseListOrders;
private:
typedef DenseMap<Type*, unsigned> TypeMapType;
using TypeMapType = DenseMap<Type *, unsigned>;
TypeMapType TypeMap;
TypeList Types;
typedef DenseMap<const Value*, unsigned> ValueMapType;
using ValueMapType = DenseMap<const Value *, unsigned>;
ValueMapType ValueMap;
ValueList Values;
typedef UniqueVector<const Comdat *> ComdatSetType;
using ComdatSetType = UniqueVector<const Comdat *>;
ComdatSetType Comdats;
std::vector<const Metadata *> MDs;
@ -88,7 +87,7 @@ private:
}
};
typedef DenseMap<const Metadata *, MDIndex> MetadataMapType;
using MetadataMapType = DenseMap<const Metadata *, MDIndex>;
MetadataMapType MetadataMap;
/// Range of metadata IDs, as a half-open range.
@ -99,18 +98,18 @@ private:
/// Number of strings in the prefix of the metadata range.
unsigned NumStrings = 0;
MDRange() {}
MDRange() = default;
explicit MDRange(unsigned First) : First(First) {}
};
SmallDenseMap<unsigned, MDRange, 1> FunctionMDInfo;
bool ShouldPreserveUseListOrder;
typedef DenseMap<IndexAndAttrSet, unsigned> AttributeGroupMapType;
using AttributeGroupMapType = DenseMap<IndexAndAttrSet, unsigned>;
AttributeGroupMapType AttributeGroupMap;
std::vector<IndexAndAttrSet> AttributeGroups;
typedef DenseMap<AttributeList, unsigned> AttributeListMapType;
using AttributeListMapType = DenseMap<AttributeList, unsigned>;
AttributeListMapType AttributeListMap;
std::vector<AttributeList> AttributeLists;
@ -118,7 +117,7 @@ private:
/// the "getGlobalBasicBlockID" method.
mutable DenseMap<const BasicBlock*, unsigned> GlobalBasicBlockIDs;
typedef DenseMap<const Instruction*, unsigned> InstructionMapType;
using InstructionMapType = DenseMap<const Instruction *, unsigned>;
InstructionMapType InstructionMap;
unsigned InstructionCount;
@ -138,10 +137,10 @@ private:
unsigned FirstFuncConstantID;
unsigned FirstInstID;
ValueEnumerator(const ValueEnumerator &) = delete;
void operator=(const ValueEnumerator &) = delete;
public:
ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder);
ValueEnumerator(const ValueEnumerator &) = delete;
ValueEnumerator &operator=(const ValueEnumerator &) = delete;
void dump() const;
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const;
@ -149,14 +148,17 @@ public:
const char *Name) const;
unsigned getValueID(const Value *V) const;
unsigned getMetadataID(const Metadata *MD) const {
auto ID = getMetadataOrNullID(MD);
assert(ID != 0 && "Metadata not in slotcalculator!");
return ID - 1;
}
unsigned getMetadataOrNullID(const Metadata *MD) const {
return MetadataMap.lookup(MD).ID;
}
unsigned numMDs() const { return MDs.size(); }
bool shouldPreserveUseListOrder() const { return ShouldPreserveUseListOrder; }
@ -208,10 +210,13 @@ public:
}
const TypeList &getTypes() const { return Types; }
const std::vector<const BasicBlock*> &getBasicBlocks() const {
return BasicBlocks;
}
const std::vector<AttributeList> &getAttributeLists() const { return AttributeLists; }
const std::vector<IndexAndAttrSet> &getAttributeGroups() const {
return AttributeGroups;
}
@ -226,8 +231,8 @@ public:
/// incorporateFunction/purgeFunction - If you'd like to deal with a function,
/// use these two methods to get its data into the ValueEnumerator!
///
void incorporateFunction(const Function &F);
void purgeFunction();
uint64_t computeBitsRequiredForTypeIndicies() const;
@ -292,6 +297,6 @@ private:
void EnumerateNamedMetadata(const Module &M);
};
} // End llvm namespace
} // end namespace llvm
#endif
#endif // LLVM_LIB_BITCODE_WRITER_VALUEENUMERATOR_H

View File

@ -1,4 +1,4 @@
//===-- llvm-cat.cpp - LLVM module concatenation utility ------------------===//
//===- llvm-cat.cpp - LLVM module concatenation utility -------------------===//
//
// The LLVM Compiler Infrastructure
//
@ -13,11 +13,23 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/SmallVector.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <memory>
#include <string>
#include <system_error>
#include <vector>
using namespace llvm;
@ -70,8 +82,8 @@ int main(int argc, char **argv) {
std::error_code EC;
raw_fd_ostream OS(OutputFilename, EC, sys::fs::OpenFlags::F_None);
if (EC) {
llvm::errs() << argv[0] << ": cannot open " << OutputFilename
<< " for writing: " << EC.message();
errs() << argv[0] << ": cannot open " << OutputFilename << " for writing: "
<< EC.message();
return 1;
}

View File

@ -1,4 +1,4 @@
//===-- llvm-lto: a simple command-line program to link modules with LTO --===//
//===- llvm-lto: a simple command-line program to link modules with LTO ---===//
//
// The LLVM Compiler Infrastructure
//
@ -12,20 +12,36 @@
//
//===----------------------------------------------------------------------===//
#include "llvm-c/lto.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/LTO/legacy/LTOCodeGenerator.h"
#include "llvm/LTO/legacy/LTOModule.h"
#include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
@ -33,7 +49,19 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <list>
#include <map>
#include <memory>
#include <string>
#include <system_error>
#include <tuple>
#include <utility>
#include <vector>
using namespace llvm;
@ -179,10 +207,12 @@ static cl::opt<bool> CheckHasObjC(
cl::desc("Only check if the module has objective-C defined in it"));
namespace {
struct ModuleInfo {
std::vector<bool> CanBeHidden;
};
}
} // end anonymous namespace
static void handleDiagnostics(lto_codegen_diagnostic_severity_t Severity,
const char *Msg, void *) {
@ -277,7 +307,7 @@ void printIndexStats() {
for (auto &Filename : InputFilenames) {
ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': ");
std::unique_ptr<ModuleSummaryIndex> Index =
ExitOnErr(llvm::getModuleSummaryIndexForFile(Filename));
ExitOnErr(getModuleSummaryIndexForFile(Filename));
// Skip files without a module summary.
if (!Index)
report_fatal_error(Filename + " does not contain an index");
@ -396,7 +426,7 @@ std::unique_ptr<ModuleSummaryIndex> loadCombinedIndex() {
report_fatal_error("Missing -thinlto-index for ThinLTO promotion stage");
ExitOnError ExitOnErr("llvm-lto: error loading file '" + ThinLTOIndex +
"': ");
return ExitOnErr(llvm::getModuleSummaryIndexForFile(ThinLTOIndex));
return ExitOnErr(getModuleSummaryIndexForFile(ThinLTOIndex));
}
static std::unique_ptr<Module> loadModule(StringRef Filename,
@ -489,7 +519,6 @@ private:
raw_fd_ostream OS(OutputFilename, EC, sys::fs::OpenFlags::F_None);
error(EC, "error opening the file '" + OutputFilename + "'");
WriteIndexToFile(*CombinedIndex, OS);
return;
}
/// Load the combined index from disk, then compute and generate
@ -745,7 +774,7 @@ private:
/// Load the combined index from disk, then load every file referenced by
};
} // namespace thinlto
} // end namespace thinlto
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
@ -784,7 +813,7 @@ int main(int argc, char **argv) {
std::unique_ptr<MemoryBuffer> BufferOrErr =
ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(Filename)));
auto Buffer = std::move(BufferOrErr.get());
if (ExitOnErr(llvm::isBitcodeContainingObjCCategory(*Buffer)))
if (ExitOnErr(isBitcodeContainingObjCCategory(*Buffer)))
outs() << "Bitcode " << Filename << " contains ObjC\n";
else
outs() << "Bitcode " << Filename << " does not contain ObjC\n";
@ -822,7 +851,7 @@ int main(int argc, char **argv) {
CodeGen.setTargetOptions(Options);
CodeGen.setShouldRestoreGlobalsLinkage(RestoreGlobalsLinkage);
llvm::StringSet<llvm::MallocAllocator> DSOSymbolsSet;
StringSet<MallocAllocator> DSOSymbolsSet;
for (unsigned i = 0; i < DSOSymbols.size(); ++i)
DSOSymbolsSet.insert(DSOSymbols[i]);