1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

Internalize functions from various tools. NFC

And internalize some classes if I noticed them:)
This commit is contained in:
Fangrui Song 2020-09-26 15:57:09 -07:00
parent 366a2adebc
commit 4e56e25d41
15 changed files with 57 additions and 60 deletions

View File

@ -83,7 +83,7 @@ static bool canSafelyConvertTo16Bit(Value &V) {
}
// Convert a value to 16-bit.
Value *convertTo16Bit(Value &V, InstCombiner::BuilderTy &Builder) {
static Value *convertTo16Bit(Value &V, InstCombiner::BuilderTy &Builder) {
Type *VTy = V.getType();
if (isa<FPExtInst>(&V) || isa<SExtInst>(&V) || isa<ZExtInst>(&V))
return cast<Instruction>(&V)->getOperand(0);

View File

@ -125,7 +125,7 @@ MODIFIERS:
[V] - display the version and exit
)";
void printHelpMessage() {
static void printHelpMessage() {
if (Stem.contains_lower("ranlib"))
outs() << RanlibHelp;
else if (Stem.contains_lower("ar"))

View File

@ -60,7 +60,7 @@ cl::opt<bool> Summarize("summarize", cl::desc("Print the summary only."),
ExitOnError ExitOnErr;
void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
static void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
auto FileOrErr = MemoryBuffer::getFile(LineInfo.FileName);
if (!FileOrErr) {
errs() << "Could not open file: " << LineInfo.FileName << "\n";
@ -84,7 +84,7 @@ void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
}
}
void printInstructionInformation(const FileAnalysis &Analysis,
static void printInstructionInformation(const FileAnalysis &Analysis,
const Instr &InstrMeta,
const GraphResult &Graph,
CFIProtectionStatus ProtectionStatus) {
@ -97,7 +97,7 @@ void printInstructionInformation(const FileAnalysis &Analysis,
Graph.printToDOT(Analysis, outs());
}
void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
static void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
const DILineInfo &LineInfo) {
if (BlameLine) {
outs() << "Blacklist Match: " << BlacklistFilename << ":" << BlameLine
@ -122,7 +122,8 @@ void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
}
}
void printIndirectCFInstructions(FileAnalysis &Analysis,
static void
printIndirectCFInstructions(FileAnalysis &Analysis,
const SpecialCaseList *SpecialCaseList) {
uint64_t ExpectedProtected = 0;
uint64_t UnexpectedProtected = 0;

View File

@ -67,7 +67,7 @@ public:
};
}
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
errs() << Msg;
exit(1);
}
@ -76,13 +76,7 @@ static void reportError(StringRef Input, std::error_code EC) {
reportError(Twine(Input) + ": " + EC.message() + ".\n");
}
void error(std::error_code EC) {
if (!EC)
return;
reportError(EC.message() + ".\n");
}
void error(Error EC) {
static void error(Error EC) {
if (!EC)
return;
handleAllErrors(std::move(EC),

View File

@ -377,7 +377,8 @@ writeIndex(MCStreamer &Out, MCSection *Section,
&DWARFUnitIndex::Entry::SectionContribution::Length);
}
std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWOName) {
static std::string buildDWODescription(StringRef Name, StringRef DWPName,
StringRef DWOName) {
std::string Text = "\'";
Text += Name;
Text += '\'';

View File

@ -62,7 +62,7 @@ enum class IFSSymbolType {
Unknown = 16,
};
std::string getTypeName(IFSSymbolType Type) {
static std::string getTypeName(IFSSymbolType Type) {
switch (Type) {
case IFSSymbolType::NoType:
return "NoType";
@ -213,7 +213,7 @@ static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
return std::move(Stub);
}
int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
static int writeTbdStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
const StringRef Format, raw_ostream &Out) {
auto PlatformKindOrError =
@ -275,7 +275,7 @@ int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
return 0;
}
int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
static int writeElfStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
const StringRef Format, raw_ostream &Out) {
SmallString<0> Storage;
Storage.clear();
@ -358,7 +358,7 @@ int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
return convertYAML(YIn, Out, ErrHandler) ? 0 : 1;
}
int writeIfso(const IFSStub &Stub, bool IsWriteIfs, raw_ostream &Out) {
static int writeIfso(const IFSStub &Stub, bool IsWriteIfs, raw_ostream &Out) {
if (IsWriteIfs) {
yaml::Output YamlOut(Out, NULL, /*WrapColumn =*/0);
YamlOut << const_cast<IFSStub &>(Stub);

View File

@ -770,7 +770,7 @@ Session::findSymbolInfo(StringRef SymbolName, Twine ErrorMsgStem) {
} // end namespace llvm
Triple getFirstFileTriple() {
static Triple getFirstFileTriple() {
assert(!InputFiles.empty() && "InputFiles can not be empty");
auto ObjBuffer =
ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(InputFiles.front())));
@ -779,7 +779,7 @@ Triple getFirstFileTriple() {
return Obj->makeTriple();
}
Error sanitizeArguments(const Session &S) {
static Error sanitizeArguments(const Session &S) {
if (EntryPointName.empty()) {
if (S.TPC->getTargetTriple().getObjectFormat() == Triple::MachO)
EntryPointName = "_main";
@ -801,7 +801,7 @@ Error sanitizeArguments(const Session &S) {
return Error::success();
}
Error loadProcessSymbols(Session &S) {
static Error loadProcessSymbols(Session &S) {
auto InternedEntryPointName = S.ES.intern(EntryPointName);
auto FilterMainEntryPoint = [InternedEntryPointName](SymbolStringPtr Name) {
return Name != InternedEntryPointName;
@ -813,7 +813,7 @@ Error loadProcessSymbols(Session &S) {
return Error::success();
}
Error loadDylibs() {
static Error loadDylibs() {
// FIXME: This should all be handled inside DynamicLibrary.
for (const auto &Dylib : Dylibs) {
if (!sys::fs::is_regular_file(Dylib))
@ -827,12 +827,11 @@ Error loadDylibs() {
return Error::success();
}
void addPhonyExternalsGenerator(Session &S) {
static void addPhonyExternalsGenerator(Session &S) {
S.MainJD->addGenerator(std::make_unique<PhonyExternalsGenerator>());
}
Error loadObjects(Session &S) {
static Error loadObjects(Session &S) {
std::map<unsigned, JITDylib *> IdxToJLD;
// First, set up JITDylibs.
@ -941,7 +940,7 @@ Error loadObjects(Session &S) {
return Error::success();
}
Error runChecks(Session &S) {
static Error runChecks(Session &S) {
auto TripleName = S.TPC->getTargetTriple().str();
std::string ErrorStr;
@ -1036,12 +1035,14 @@ static Expected<JITEvaluatedSymbol> getMainEntryPoint(Session &S) {
return S.ES.lookup(S.JDSearchOrder, EntryPointName);
}
namespace {
struct JITLinkTimers {
TimerGroup JITLinkTG{"llvm-jitlink timers", "timers for llvm-jitlink phases"};
Timer LoadObjectsTimer{"load", "time to load/add object files", JITLinkTG};
Timer LinkTimer{"link", "time to link object files", JITLinkTG};
Timer RunTimer{"run", "time to execute jitlink'd code", JITLinkTG};
};
} // namespace
int main(int argc, char *argv[]) {
InitLLVM X(argc, argv);

View File

@ -337,7 +337,7 @@ getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer,
}
/// Print some statistics on the index for each input files.
void printIndexStats() {
static void printIndexStats() {
for (auto &Filename : InputFilenames) {
ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': ");
std::unique_ptr<ModuleSummaryIndex> Index =

View File

@ -64,7 +64,7 @@ public:
};
} // namespace
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) {
WithColor::error(errs(), "llvm-mt") << Msg << '\n';
exit(1);
}
@ -73,12 +73,7 @@ static void reportError(StringRef Input, std::error_code EC) {
reportError(Twine(Input) + ": " + EC.message());
}
void error(std::error_code EC) {
if (EC)
reportError(EC.message());
}
void error(Error EC) {
static void error(Error EC) {
if (EC)
handleAllErrors(std::move(EC), [&](const ErrorInfoBase &EI) {
reportError(EI.message());

View File

@ -252,12 +252,14 @@ private:
/// maintain an index of unique functions, and provide a means of iterating
/// through all the instrumented call stacks which we know about.
namespace {
struct StackDuration {
llvm::SmallVector<int64_t, 4> TerminalDurations;
llvm::SmallVector<int64_t, 4> IntermediateDurations;
};
} // namespace
StackDuration mergeStackDuration(const StackDuration &Left,
static StackDuration mergeStackDuration(const StackDuration &Left,
const StackDuration &Right) {
StackDuration Data{};
Data.TerminalDurations.reserve(Left.TerminalDurations.size() +
@ -280,7 +282,7 @@ StackDuration mergeStackDuration(const StackDuration &Left,
using StackTrieNode = TrieNode<StackDuration>;
template <AggregationType AggType>
std::size_t GetValueForStack(const StackTrieNode *Node);
static std::size_t GetValueForStack(const StackTrieNode *Node);
// When computing total time spent in a stack, we're adding the timings from
// its callees and the timings from when it was a leaf.
@ -669,7 +671,7 @@ public:
}
};
std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error,
static std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error,
const XRayRecord &Record,
const FuncIdConversionHelper &Converter) {
switch (Error) {

View File

@ -446,8 +446,8 @@ static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
void initializeExampleIRTransforms(llvm::PassRegistry &Registry);
#endif
void exportDebugifyStats(llvm::StringRef Path, const DebugifyStatsMap &Map) {
static void exportDebugifyStats(llvm::StringRef Path,
const DebugifyStatsMap &Map) {
std::error_code EC;
raw_fd_ostream OS{Path, EC};
if (EC) {

View File

@ -36,7 +36,7 @@ inline uint64_t CountFromData(uint64_t Data, char SizeofPtr) {
return Data & ((1ull << (SizeofPtr * 8 - kSanitizerStatKindBits)) - 1);
}
uint64_t ReadLE(char Size, const char *Begin, const char *End) {
static uint64_t ReadLE(char Size, const char *Begin, const char *End) {
uint64_t Result = 0;
char Pos = 0;
while (Begin < End && Pos != Size) {
@ -47,7 +47,8 @@ uint64_t ReadLE(char Size, const char *Begin, const char *End) {
return Result;
}
const char *ReadModule(char SizeofPtr, const char *Begin, const char *End) {
static const char *ReadModule(char SizeofPtr, const char *Begin,
const char *End) {
const char *FilenameBegin = Begin;
while (Begin != End && *Begin)
++Begin;

View File

@ -324,7 +324,7 @@ struct InputAnnotation {
};
/// Get an abbreviation for the check type.
std::string GetCheckTypeAbbreviation(Check::FileCheckType Ty) {
static std::string GetCheckTypeAbbreviation(Check::FileCheckType Ty) {
switch (Ty) {
case Check::CheckPlain:
if (Ty.getCount() > 1)

View File

@ -356,7 +356,7 @@ EmitRegUnitPressure(raw_ostream &OS, const CodeGenRegBank &RegBank,
using DwarfRegNumsMapPair = std::pair<Record*, std::vector<int64_t>>;
using DwarfRegNumsVecTy = std::vector<DwarfRegNumsMapPair>;
void finalizeDwarfRegNumsKeys(DwarfRegNumsVecTy &DwarfRegNums) {
static void finalizeDwarfRegNumsKeys(DwarfRegNumsVecTy &DwarfRegNums) {
// Sort and unique to get a map-like vector. We want the last assignment to
// match previous behaviour.
std::stable_sort(DwarfRegNums.begin(), DwarfRegNums.end(),

View File

@ -1507,7 +1507,8 @@ static void emitPredicates(const CodeGenSchedTransition &T,
// Used by method `SubtargetEmitter::emitSchedModelHelpersImpl()` to generate
// epilogue code for the auto-generated helper.
void emitSchedModelHelperEpilogue(raw_ostream &OS, bool ShouldReturnZero) {
static void emitSchedModelHelperEpilogue(raw_ostream &OS,
bool ShouldReturnZero) {
if (ShouldReturnZero) {
OS << " // Don't know how to resolve this scheduling class.\n"
<< " return 0;\n";
@ -1517,13 +1518,13 @@ void emitSchedModelHelperEpilogue(raw_ostream &OS, bool ShouldReturnZero) {
OS << " report_fatal_error(\"Expected a variant SchedClass\");\n";
}
bool hasMCSchedPredicates(const CodeGenSchedTransition &T) {
static bool hasMCSchedPredicates(const CodeGenSchedTransition &T) {
return all_of(T.PredTerm, [](const Record *Rec) {
return Rec->isSubClassOf("MCSchedPredicate");
});
}
void collectVariantClasses(const CodeGenSchedModels &SchedModels,
static void collectVariantClasses(const CodeGenSchedModels &SchedModels,
IdxVec &VariantClasses,
bool OnlyExpandMCInstPredicates) {
for (const CodeGenSchedClass &SC : SchedModels.schedClasses()) {
@ -1544,7 +1545,8 @@ void collectVariantClasses(const CodeGenSchedModels &SchedModels,
}
}
void collectProcessorIndices(const CodeGenSchedClass &SC, IdxVec &ProcIndices) {
static void collectProcessorIndices(const CodeGenSchedClass &SC,
IdxVec &ProcIndices) {
// A variant scheduling class may define transitions for multiple
// processors. This function identifies wich processors are associated with
// transition rules specified by variant class `SC`.