Clang format a few prior patches (NFC)

I had clang formatted my earlier patches using the wrong style.
Reformatted with the LLVM style.

llvm-svn: 251812
This commit is contained in:
Teresa Johnson 2015-11-02 18:02:11 +00:00
parent 89a6eefe6f
commit f72278f051
12 changed files with 340 additions and 299 deletions

View File

@ -73,9 +73,7 @@ class BitstreamWriter {
reinterpret_cast<const char *>(&Value + 1));
}
size_t GetBufferOffset() const {
return Out.size();
}
size_t GetBufferOffset() const { return Out.size(); }
size_t GetWordIndex() const {
size_t Offset = GetBufferOffset();

View File

@ -68,9 +68,10 @@ namespace llvm {
/// the index. Otherwise skip the function summary section, and only create
/// an index object with a map from function name to function summary offset.
/// The index is used to perform lazy function summary reading later.
ErrorOr<std::unique_ptr<FunctionInfoIndex>> getFunctionInfoIndex(
MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy = false);
ErrorOr<std::unique_ptr<FunctionInfoIndex>>
getFunctionInfoIndex(MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler,
bool IsLazy = false);
/// This method supports lazy reading of function summary data from the
/// combined index during function importing. When reading the combined index
@ -78,9 +79,10 @@ namespace llvm {
/// Then this method is called for each function considered for importing,
/// to parse the summary information for the given function name into
/// the index.
std::error_code readFunctionSummary(
MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler, StringRef FunctionName,
std::error_code
readFunctionSummary(MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler,
StringRef FunctionName,
std::unique_ptr<FunctionInfoIndex> Index);
/// \brief Write the specified module to the specified raw output stream.

View File

@ -30,7 +30,7 @@ namespace llvm {
/// This is a separate class from FunctionInfo to enable lazy reading of this
/// function summary information from the combined index file during imporing.
class FunctionSummary {
private:
private:
/// \brief Path of module containing function IR, used to locate module when
/// importing this function.
///
@ -57,7 +57,7 @@ class FunctionSummary {
/// during the initial compile step when the function index is first built.
unsigned InstCount;
public:
public:
/// Construct a summary object from summary data expected for all
/// summary records.
FunctionSummary(unsigned NumInsts) : InstCount(NumInsts) {}
@ -90,7 +90,7 @@ class FunctionSummary {
/// record. After parsing the associated summary information from the summary
/// block the \a FunctionSummary is populated and stored here.
class FunctionInfo {
private:
private:
/// Function summary information used to help make ThinLTO importing
/// decisions.
std::unique_ptr<FunctionSummary> Summary;
@ -109,7 +109,7 @@ class FunctionInfo {
/// VST records with the summary records.
uint64_t BitcodeIndex;
public:
public:
/// Constructor used during parsing of VST entries.
FunctionInfo(uint64_t FuncOffset)
: Summary(nullptr), BitcodeIndex(FuncOffset) {}
@ -157,7 +157,7 @@ typedef StringMap<uint64_t> ModulePathStringTableTy;
/// Class to hold module path string table and function map,
/// and encapsulate methods for operating on them.
class FunctionInfoIndex {
private:
private:
/// Map from function name to list of function information instances
/// for functions of that name (may be duplicates in the COMDAT case, e.g.).
FunctionInfoMapTy FunctionMap;
@ -165,7 +165,7 @@ class FunctionInfoIndex {
/// Holds strings for combined index, mapping to the corresponding module ID.
ModulePathStringTableTy ModulePathStringTable;
public:
public:
FunctionInfoIndex() = default;
~FunctionInfoIndex() = default;
@ -190,8 +190,8 @@ class FunctionInfoIndex {
}
/// Iterator to allow writer to walk through table during emission.
iterator_range<StringMap<uint64_t>::const_iterator> modPathStringEntries()
const {
iterator_range<StringMap<uint64_t>::const_iterator>
modPathStringEntries() const {
return llvm::make_range(ModulePathStringTable.begin(),
ModulePathStringTable.end());
}

View File

@ -123,9 +123,7 @@ public:
return TypeID == ID_IR;
}
bool isFunctionIndex() const {
return TypeID == ID_FunctionIndex;
}
bool isFunctionIndex() const { return TypeID == ID_FunctionIndex; }
bool isLittleEndian() const {
return !(TypeID == ID_ELF32B || TypeID == ID_ELF64B ||

View File

@ -29,7 +29,7 @@ class ObjectFile;
class FunctionIndexObjectFile : public SymbolicFile {
std::unique_ptr<FunctionInfoIndex> Index;
public:
public:
FunctionIndexObjectFile(MemoryBufferRef Object,
std::unique_ptr<FunctionInfoIndex> I);
~FunctionIndexObjectFile() override;
@ -72,8 +72,8 @@ class FunctionIndexObjectFile : public SymbolicFile {
/// \brief Finds and returns bitcode in the given memory buffer (which may
/// be either a bitcode file or a native object file with embedded bitcode),
/// or an error code if not found.
static ErrorOr<MemoryBufferRef> findBitcodeInMemBuffer(
MemoryBufferRef Object);
static ErrorOr<MemoryBufferRef>
findBitcodeInMemBuffer(MemoryBufferRef Object);
/// \brief Looks for function summary in the given memory buffer,
/// returns true if found, else false.
@ -83,8 +83,8 @@ class FunctionIndexObjectFile : public SymbolicFile {
/// \brief Parse function index in the given memory buffer.
/// Return new FunctionIndexObjectFile instance containing parsed function
/// summary/index.
static ErrorOr<std::unique_ptr<FunctionIndexObjectFile>> create(
MemoryBufferRef Object, LLVMContext &Context, bool IsLazy = false);
static ErrorOr<std::unique_ptr<FunctionIndexObjectFile>>
create(MemoryBufferRef Object, LLVMContext &Context, bool IsLazy = false);
/// \brief Parse the function summary information for function with the
/// given name out of the given buffer. Parsed information is

View File

@ -456,7 +456,7 @@ class FunctionIndexBitcodeReader {
/// summary records.
DenseMap<uint64_t, StringRef> ModuleIdMap;
public:
public:
std::error_code error(BitcodeError E, const Twine &Message);
std::error_code error(BitcodeError E);
std::error_code error(const Twine &Message);
@ -488,7 +488,7 @@ class FunctionIndexBitcodeReader {
FunctionInfoIndex *I,
size_t FunctionSummaryOffset);
private:
private:
std::error_code parseModule();
std::error_code parseValueSymbolTable();
std::error_code parseEntireSummary();
@ -3052,7 +3052,8 @@ std::error_code BitcodeReader::globalCleanup() {
std::error_code BitcodeReader::rememberAndSkipFunctionBodies() {
Stream.JumpToBit(NextUnreadBit);
if (Stream.AtEndOfStream()) return error("Could not find function in stream");
if (Stream.AtEndOfStream())
return error("Could not find function in stream");
assert(SeenFirstFunctionBody);
// An old bitcode file with the symbol table at the end would have
@ -3071,7 +3072,8 @@ std::error_code BitcodeReader::rememberAndSkipFunctionBodies() {
default:
return error("Expect function block");
case bitc::FUNCTION_BLOCK_ID:
if (std::error_code EC = rememberAndSkipFunctionBody()) return EC;
if (std::error_code EC = rememberAndSkipFunctionBody())
return EC;
NextUnreadBit = Stream.GetCurrentBitNo();
return std::error_code();
}
@ -3600,7 +3602,8 @@ BitcodeReader::parseBitcodeInto(std::unique_ptr<DataStreamer> Streamer,
return EC;
// Sniff for the signature.
if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
if (!hasValidBitcodeHeader(Stream))
return error("Invalid bitcode signature");
// We expect a number of well-defined blocks, though we don't necessarily
// need to understand them all.
@ -3672,7 +3675,8 @@ ErrorOr<std::string> BitcodeReader::parseTriple() {
return EC;
// Sniff for the signature.
if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
if (!hasValidBitcodeHeader(Stream))
return error("Invalid bitcode signature");
// We expect a number of well-defined blocks, though we don't necessarily
// need to understand them all.
@ -5081,7 +5085,8 @@ std::error_code BitcodeReader::findFunctionInStream(
assert(VSTOffset == 0 || !F->hasName());
// Parse the next body in the stream and set its position in the
// DeferredFunctionInfo map.
if (std::error_code EC = rememberAndSkipFunctionBodies()) return EC;
if (std::error_code EC = rememberAndSkipFunctionBodies())
return EC;
}
return std::error_code();
}
@ -5286,16 +5291,14 @@ FunctionIndexBitcodeReader::FunctionIndexBitcodeReader(
DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy,
bool CheckFuncSummaryPresenceOnly)
: DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
Buffer(Buffer),
IsLazy(IsLazy),
Buffer(Buffer), IsLazy(IsLazy),
CheckFuncSummaryPresenceOnly(CheckFuncSummaryPresenceOnly) {}
FunctionIndexBitcodeReader::FunctionIndexBitcodeReader(
LLVMContext &Context, DiagnosticHandlerFunction DiagnosticHandler,
bool IsLazy, bool CheckFuncSummaryPresenceOnly)
: DiagnosticHandler(getDiagHandler(DiagnosticHandler, Context)),
Buffer(nullptr),
IsLazy(IsLazy),
Buffer(nullptr), IsLazy(IsLazy),
CheckFuncSummaryPresenceOnly(CheckFuncSummaryPresenceOnly) {}
void FunctionIndexBitcodeReader::freeState() { Buffer = nullptr; }
@ -5400,31 +5403,37 @@ std::error_code FunctionIndexBitcodeReader::parseModule() {
if (CheckFuncSummaryPresenceOnly) {
if (Entry.ID == bitc::FUNCTION_SUMMARY_BLOCK_ID)
SeenFuncSummary = true;
if (Stream.SkipBlock()) return error("Invalid record");
if (Stream.SkipBlock())
return error("Invalid record");
// No need to parse the rest since we found the summary.
return std::error_code();
}
switch (Entry.ID) {
default: // Skip unknown content.
if (Stream.SkipBlock()) return error("Invalid record");
if (Stream.SkipBlock())
return error("Invalid record");
break;
case bitc::BLOCKINFO_BLOCK_ID:
// Need to parse these to get abbrev ids (e.g. for VST)
if (Stream.ReadBlockInfoBlock()) return error("Malformed block");
if (Stream.ReadBlockInfoBlock())
return error("Malformed block");
break;
case bitc::VALUE_SYMTAB_BLOCK_ID:
if (std::error_code EC = parseValueSymbolTable()) return EC;
if (std::error_code EC = parseValueSymbolTable())
return EC;
break;
case bitc::FUNCTION_SUMMARY_BLOCK_ID:
SeenFuncSummary = true;
if (IsLazy) {
// Lazy parsing of summary info, skip it.
if (Stream.SkipBlock()) return error("Invalid record");
if (Stream.SkipBlock())
return error("Invalid record");
} else if (std::error_code EC = parseEntireSummary())
return EC;
break;
case bitc::MODULE_STRTAB_BLOCK_ID:
if (std::error_code EC = parseModuleStringTable()) return EC;
if (std::error_code EC = parseModuleStringTable())
return EC;
break;
}
continue;
@ -5534,8 +5543,7 @@ std::error_code FunctionIndexBitcodeReader::parseModuleStringTable() {
if (convertToString(Record, 1, ModulePath))
return error("Invalid record");
uint64_t ModuleId = Record[0];
StringRef ModulePathInMap =
TheIndex->addModulePath(ModulePath, ModuleId);
StringRef ModulePathInMap = TheIndex->addModulePath(ModulePath, ModuleId);
ModuleIdMap[ModuleId] = ModulePathInMap;
ModulePath.clear();
break;
@ -5550,10 +5558,12 @@ std::error_code FunctionIndexBitcodeReader::parseSummaryIndexInto(
std::unique_ptr<DataStreamer> Streamer, FunctionInfoIndex *I) {
TheIndex = I;
if (std::error_code EC = initStream(std::move(Streamer))) return EC;
if (std::error_code EC = initStream(std::move(Streamer)))
return EC;
// Sniff for the signature.
if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
if (!hasValidBitcodeHeader(Stream))
return error("Invalid bitcode signature");
// We expect a number of well-defined blocks, though we don't necessarily
// need to understand them all.
@ -5566,13 +5576,16 @@ std::error_code FunctionIndexBitcodeReader::parseSummaryIndexInto(
BitstreamEntry Entry =
Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs);
if (Entry.Kind != BitstreamEntry::SubBlock) return error("Malformed block");
if (Entry.Kind != BitstreamEntry::SubBlock)
return error("Malformed block");
// If we see a MODULE_BLOCK, parse it to find the blocks needed for
// building the function summary index.
if (Entry.ID == bitc::MODULE_BLOCK_ID) return parseModule();
if (Entry.ID == bitc::MODULE_BLOCK_ID)
return parseModule();
if (Stream.SkipBlock()) return error("Invalid record");
if (Stream.SkipBlock())
return error("Invalid record");
}
}
@ -5586,10 +5599,12 @@ std::error_code FunctionIndexBitcodeReader::parseFunctionSummary(
size_t FunctionSummaryOffset) {
TheIndex = I;
if (std::error_code EC = initStream(std::move(Streamer))) return EC;
if (std::error_code EC = initStream(std::move(Streamer)))
return EC;
// Sniff for the signature.
if (!hasValidBitcodeHeader(Stream)) return error("Invalid bitcode signature");
if (!hasValidBitcodeHeader(Stream))
return error("Invalid bitcode signature");
Stream.JumpToBit(FunctionSummaryOffset);
@ -5615,9 +5630,10 @@ std::error_code FunctionIndexBitcodeReader::parseFunctionSummary(
return std::error_code();
}
std::error_code FunctionIndexBitcodeReader::initStream(
std::unique_ptr<DataStreamer> Streamer) {
if (Streamer) return initLazyStream(std::move(Streamer));
std::error_code
FunctionIndexBitcodeReader::initStream(std::unique_ptr<DataStreamer> Streamer) {
if (Streamer)
return initLazyStream(std::move(Streamer));
return initStreamFromBuffer();
}
@ -5625,7 +5641,8 @@ std::error_code FunctionIndexBitcodeReader::initStreamFromBuffer() {
const unsigned char *BufPtr = (const unsigned char *)Buffer->getBufferStart();
const unsigned char *BufEnd = BufPtr + Buffer->getBufferSize();
if (Buffer->getBufferSize() & 3) return error("Invalid bitcode signature");
if (Buffer->getBufferSize() & 3)
return error("Invalid bitcode signature");
// If we have a wrapper header, parse it and ignore the non-bc file contents.
// The magic number is 0x0B17C0DE stored in little endian.
@ -5653,7 +5670,8 @@ std::error_code FunctionIndexBitcodeReader::initLazyStream(
if (Bytes.readBytes(buf, 16, 0) != 16)
return error("Invalid bitcode signature");
if (!isBitcode(buf, buf + 16)) return error("Invalid bitcode signature");
if (!isBitcode(buf, buf + 16))
return error("Invalid bitcode signature");
if (isBitcodeWrapper(buf, buf + 4)) {
const unsigned char *bitcodeStart = buf;
@ -5792,9 +5810,10 @@ llvm::getBitcodeTargetTriple(MemoryBufferRef Buffer, LLVMContext &Context,
// the index. Otherwise skip the function summary section, and only create
// an index object with a map from function name to function summary offset.
// The index is used to perform lazy function summary reading later.
ErrorOr<std::unique_ptr<FunctionInfoIndex>> llvm::getFunctionInfoIndex(
MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy) {
ErrorOr<std::unique_ptr<FunctionInfoIndex>>
llvm::getFunctionInfoIndex(MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler,
bool IsLazy) {
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
FunctionIndexBitcodeReader R(Buf.get(), Context, DiagnosticHandler, IsLazy);
@ -5838,9 +5857,10 @@ bool llvm::hasFunctionSummary(MemoryBufferRef Buffer, LLVMContext &Context,
// Then this method is called for each function considered for importing,
// to parse the summary information for the given function name into
// the index.
std::error_code llvm::readFunctionSummary(
MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler, StringRef FunctionName,
std::error_code
llvm::readFunctionSummary(MemoryBufferRef Buffer, LLVMContext &Context,
DiagnosticHandlerFunction DiagnosticHandler,
StringRef FunctionName,
std::unique_ptr<FunctionInfoIndex> Index) {
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
FunctionIndexBitcodeReader R(Buf.get(), Context, DiagnosticHandler);

View File

@ -583,7 +583,8 @@ static void writeComdats(const ValueEnumerator &VE, BitstreamWriter &Stream) {
/// after the real VST is written. Returns the bit offset to backpatch.
static uint64_t WriteValueSymbolTableForwardDecl(const ValueSymbolTable &VST,
BitstreamWriter &Stream) {
if (VST.empty()) return 0;
if (VST.empty())
return 0;
// Write a placeholder value in for the offset of the real VST,
// which is written after the function blocks so that it can include
@ -2303,7 +2304,8 @@ static void WriteValueSymbolTable(
AbbrevToUse = VST_ENTRY_7_ABBREV;
}
for (const auto P : Name.getKey()) NameVals.push_back((unsigned char)P);
for (const auto P : Name.getKey())
NameVals.push_back((unsigned char)P);
// Emit the finished record.
Stream.EmitRecord(Code, NameVals, AbbrevToUse);
@ -2361,7 +2363,8 @@ static void WriteCombinedValueSymbolTable(const FunctionInfoIndex &Index,
else if (Bits == SE_Fixed7)
AbbrevToUse = FnEntry7BitAbbrev;
for (const auto P : FuncName) NameVals.push_back((unsigned char)P);
for (const auto P : FuncName)
NameVals.push_back((unsigned char)P);
// Emit the finished record.
Stream.EmitRecord(bitc::VST_CODE_COMBINED_FNENTRY, NameVals, AbbrevToUse);
@ -2466,7 +2469,8 @@ static void WriteFunction(
I != E; ++I) {
WriteInstruction(*I, InstID, VE, Stream, Vals);
if (!isa<DbgInfoIntrinsic>(I)) ++NumInsts;
if (!isa<DbgInfoIntrinsic>(I))
++NumInsts;
if (!I->getType()->isVoidTy())
++InstID;
@ -2728,7 +2732,8 @@ static void WriteModStrings(const FunctionInfoIndex &I,
NameVals.push_back(MPSE.getValue());
for (const auto P : MPSE.getKey()) NameVals.push_back((unsigned char)P);
for (const auto P : MPSE.getKey())
NameVals.push_back((unsigned char)P);
// Emit the finished record.
Stream.EmitRecord(bitc::MST_CODE_ENTRY, NameVals, AbbrevToUse);
@ -2770,7 +2775,8 @@ static void WritePerModuleFunctionSummary(
for (auto &I : FunctionIndex) {
// Skip anonymous functions. We will emit a function summary for
// any aliases below.
if (!I.first->hasName()) continue;
if (!I.first->hasName())
continue;
WritePerModuleFunctionSummaryRecord(
NameVals, I.second->functionSummary(),
@ -2779,9 +2785,11 @@ static void WritePerModuleFunctionSummary(
}
for (const GlobalAlias &A : M->aliases()) {
if (!A.getBaseObject()) continue;
if (!A.getBaseObject())
continue;
const Function *F = dyn_cast<Function>(A.getBaseObject());
if (!F || F->isDeclaration()) continue;
if (!F || F->isDeclaration())
continue;
assert(FunctionIndex.count(F) == 1);
WritePerModuleFunctionSummaryRecord(

View File

@ -1,4 +1,5 @@
//===- FunctionIndexObjectFile.cpp - Function index file implementation ----===//
//===- FunctionIndexObjectFile.cpp - Function index file implementation
//----===//
//
// The LLVM Compiler Infrastructure
//
@ -32,14 +33,16 @@ std::unique_ptr<FunctionInfoIndex> FunctionIndexObjectFile::takeIndex() {
return std::move(Index);
}
ErrorOr<MemoryBufferRef> FunctionIndexObjectFile::findBitcodeInObject(
const ObjectFile &Obj) {
ErrorOr<MemoryBufferRef>
FunctionIndexObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
for (const SectionRef &Sec : Obj.sections()) {
StringRef SecName;
if (std::error_code EC = Sec.getName(SecName)) return EC;
if (std::error_code EC = Sec.getName(SecName))
return EC;
if (SecName == ".llvmbc") {
StringRef SecContents;
if (std::error_code EC = Sec.getContents(SecContents)) return EC;
if (std::error_code EC = Sec.getContents(SecContents))
return EC;
return MemoryBufferRef(SecContents, Obj.getFileName());
}
}
@ -47,8 +50,8 @@ ErrorOr<MemoryBufferRef> FunctionIndexObjectFile::findBitcodeInObject(
return object_error::bitcode_section_not_found;
}
ErrorOr<MemoryBufferRef> FunctionIndexObjectFile::findBitcodeInMemBuffer(
MemoryBufferRef Object) {
ErrorOr<MemoryBufferRef>
FunctionIndexObjectFile::findBitcodeInMemBuffer(MemoryBufferRef Object) {
sys::fs::file_magic Type = sys::fs::identify_magic(Object.getBuffer());
switch (Type) {
case sys::fs::file_magic::bitcode:
@ -58,7 +61,8 @@ ErrorOr<MemoryBufferRef> FunctionIndexObjectFile::findBitcodeInMemBuffer(
case sys::fs::file_magic::coff_object: {
ErrorOr<std::unique_ptr<ObjectFile>> ObjFile =
ObjectFile::createObjectFile(Object, Type);
if (!ObjFile) return ObjFile.getError();
if (!ObjFile)
return ObjFile.getError();
return findBitcodeInObject(*ObjFile->get());
}
default:
@ -71,7 +75,8 @@ ErrorOr<MemoryBufferRef> FunctionIndexObjectFile::findBitcodeInMemBuffer(
bool FunctionIndexObjectFile::hasFunctionSummaryInMemBuffer(
MemoryBufferRef Object, LLVMContext &Context) {
ErrorOr<MemoryBufferRef> BCOrErr = findBitcodeInMemBuffer(Object);
if (!BCOrErr) return false;
if (!BCOrErr)
return false;
return hasFunctionSummary(BCOrErr.get(), Context, nullptr);
}
@ -85,12 +90,14 @@ FunctionIndexObjectFile::create(MemoryBufferRef Object, LLVMContext &Context,
std::unique_ptr<FunctionInfoIndex> Index;
ErrorOr<MemoryBufferRef> BCOrErr = findBitcodeInMemBuffer(Object);
if (!BCOrErr) return BCOrErr.getError();
if (!BCOrErr)
return BCOrErr.getError();
ErrorOr<std::unique_ptr<FunctionInfoIndex>> IOrErr =
getFunctionInfoIndex(BCOrErr.get(), Context, nullptr, IsLazy);
if (std::error_code EC = IOrErr.getError()) return EC;
if (std::error_code EC = IOrErr.getError())
return EC;
Index = std::move(IOrErr.get());

View File

@ -1,4 +1,5 @@
//===-- ElimAvailExtern.cpp - DCE unreachable internal functions ----------------===//
//===-- ElimAvailExtern.cpp - DCE unreachable internal functions
//----------------===//
//
// The LLVM Compiler Infrastructure
//
@ -26,7 +27,7 @@ STATISTIC(NumFunctions, "Number of functions removed");
STATISTIC(NumVariables, "Number of global variables removed");
namespace {
struct EliminateAvailableExternally : public ModulePass {
struct EliminateAvailableExternally : public ModulePass {
static char ID; // Pass identification, replacement for typeid
EliminateAvailableExternally() : ModulePass(ID) {
initializeEliminateAvailableExternallyPass(
@ -37,7 +38,7 @@ namespace {
// optionally updating the specified callgraph to reflect the changes.
//
bool runOnModule(Module &M) override;
};
};
}
char EliminateAvailableExternally::ID = 0;
@ -52,7 +53,7 @@ bool EliminateAvailableExternally::runOnModule(Module &M) {
bool Changed = false;
// Drop initializers of available externally global variables.
for (GlobalVariable &GV :M.globals()) {
for (GlobalVariable &GV : M.globals()) {
if (!GV.hasAvailableExternallyLinkage())
continue;
if (GV.hasInitializer()) {

View File

@ -385,7 +385,8 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
// If we are doing ThinLTO compilation, don't need to process the symbols.
// Later we simply build a combined index file after all files are claimed.
if (options::thinlto) return LDPS_OK;
if (options::thinlto)
return LDPS_OK;
for (auto &Sym : Obj->symbols()) {
uint32_t Symflags = Sym.getFlags();
@ -602,8 +603,9 @@ static void freeSymName(ld_plugin_symbol &Sym) {
Sym.comdat_key = nullptr;
}
static std::unique_ptr<FunctionInfoIndex> getFunctionIndexForFile(
LLVMContext &Context, claimed_file &F, ld_plugin_input_file &Info) {
static std::unique_ptr<FunctionInfoIndex>
getFunctionIndexForFile(LLVMContext &Context, claimed_file &F,
ld_plugin_input_file &Info) {
if (get_symbols(F.handle, F.syms.size(), &F.syms[0]) != LDPS_OK)
message(LDPL_FATAL, "Failed to get symbol information");

View File

@ -284,12 +284,14 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
}
case bitc::MODULE_STRTAB_BLOCK_ID:
switch (CodeID) {
default: return nullptr;
default:
return nullptr;
STRINGIFY_CODE(MST_CODE, ENTRY)
}
case bitc::FUNCTION_SUMMARY_BLOCK_ID:
switch (CodeID) {
default: return nullptr;
default:
return nullptr;
STRINGIFY_CODE(FS_CODE, PERMODULE_ENTRY)
STRINGIFY_CODE(FS_CODE, COMBINED_ENTRY)
}
@ -534,7 +536,8 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID,
}
Str += (char)Record[j];
}
if (ArrayIsPrintable) outs() << " record string = '" << Str << "'";
if (ArrayIsPrintable)
outs() << " record string = '" << Str << "'";
break;
}
}

View File

@ -59,8 +59,8 @@ static cl::opt<bool>
UseDiagnosticHandler("use-diagnostic-handler", cl::init(false),
cl::desc("Use a diagnostic handler to test the handler interface"));
static cl::opt<bool> ThinLTO(
"thinlto", cl::init(false),
static cl::opt<bool>
ThinLTO("thinlto", cl::init(false),
cl::desc("Only write combined global index for ThinLTO backends"));
static cl::list<std::string>
@ -160,8 +160,9 @@ static int listSymbols(StringRef Command, const TargetOptions &Options) {
/// Parse the function index out of an IR file and return the function
/// index object if found, or nullptr if not.
static std::unique_ptr<FunctionInfoIndex> getFunctionIndexForFile(
StringRef Path, std::string &Error, LLVMContext &Context) {
static std::unique_ptr<FunctionInfoIndex>
getFunctionIndexForFile(StringRef Path, std::string &Error,
LLVMContext &Context) {
std::unique_ptr<MemoryBuffer> Buffer;
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFile(Path);
@ -238,7 +239,8 @@ int main(int argc, char **argv) {
if (ListSymbolsOnly)
return listSymbols(argv[0], Options);
if (ThinLTO) return createCombinedFunctionIndex(argv[0]);
if (ThinLTO)
return createCombinedFunctionIndex(argv[0]);
unsigned BaseArg = 0;