[lld] 20e9c36 - Internalize functions from various tools. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 26 15:57:22 PDT 2020
Author: Fangrui Song
Date: 2020-09-26T15:57:13-07:00
New Revision: 20e9c36c013c4a9b13cf256ca5262afe3def78ad
URL: https://github.com/llvm/llvm-project/commit/20e9c36c013c4a9b13cf256ca5262afe3def78ad
DIFF: https://github.com/llvm/llvm-project/commit/20e9c36c013c4a9b13cf256ca5262afe3def78ad.diff
LOG: Internalize functions from various tools. NFC
And internalize some classes if I noticed them:)
Added:
Modified:
lld/MachO/Driver.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
llvm/tools/llvm-ar/llvm-ar.cpp
llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
llvm/tools/llvm-cvtres/llvm-cvtres.cpp
llvm/tools/llvm-dwp/llvm-dwp.cpp
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-mt/llvm-mt.cpp
llvm/tools/llvm-xray/xray-stacks.cpp
llvm/tools/opt/opt.cpp
llvm/tools/sanstats/sanstats.cpp
llvm/utils/FileCheck/FileCheck.cpp
llvm/utils/TableGen/RegisterInfoEmitter.cpp
llvm/utils/TableGen/SubtargetEmitter.cpp
Removed:
################################################################################
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 7a8215bd0398..482e4a13a8b4 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -88,7 +88,7 @@ void MachOOptTable::printHelp(const char *argv0, bool showHidden) const {
lld::outs() << "\n";
}
-HeaderFileType getOutputType(const opt::InputArgList &args) {
+static HeaderFileType getOutputType(const opt::InputArgList &args) {
// TODO: -r, -dylinker, -preload...
opt::Arg *outputArg = args.getLastArg(OPT_bundle, OPT_dylib, OPT_execute);
if (outputArg == nullptr)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index 209f93253654..4b2624350b74 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -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);
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index d699d4323f0a..4c26c8cad3fa 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -125,7 +125,7 @@ USAGE: llvm-ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [f
[V] - display the version and exit
)";
-void printHelpMessage() {
+static void printHelpMessage() {
if (Stem.contains_lower("ranlib"))
outs() << RanlibHelp;
else if (Stem.contains_lower("ar"))
diff --git a/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp b/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
index 79bf63af5f44..1331442bc65c 100644
--- a/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
+++ b/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
@@ -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,10 +84,10 @@ void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
}
}
-void printInstructionInformation(const FileAnalysis &Analysis,
- const Instr &InstrMeta,
- const GraphResult &Graph,
- CFIProtectionStatus ProtectionStatus) {
+static void printInstructionInformation(const FileAnalysis &Analysis,
+ const Instr &InstrMeta,
+ const GraphResult &Graph,
+ CFIProtectionStatus ProtectionStatus) {
outs() << "Instruction: " << format_hex(InstrMeta.VMAddress, 2) << " ("
<< stringCFIProtectionStatus(ProtectionStatus) << "): ";
Analysis.printInstruction(InstrMeta, outs());
@@ -97,8 +97,8 @@ void printInstructionInformation(const FileAnalysis &Analysis,
Graph.printToDOT(Analysis, outs());
}
-void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
- const DILineInfo &LineInfo) {
+static void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
+ const DILineInfo &LineInfo) {
if (BlameLine) {
outs() << "Blacklist Match: " << BlacklistFilename << ":" << BlameLine
<< "\n";
@@ -122,8 +122,9 @@ void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
}
}
-void printIndirectCFInstructions(FileAnalysis &Analysis,
- const SpecialCaseList *SpecialCaseList) {
+static void
+printIndirectCFInstructions(FileAnalysis &Analysis,
+ const SpecialCaseList *SpecialCaseList) {
uint64_t ExpectedProtected = 0;
uint64_t UnexpectedProtected = 0;
uint64_t ExpectedUnprotected = 0;
diff --git a/llvm/tools/llvm-cvtres/llvm-cvtres.cpp b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp
index 1322da47a705..2991485a57cd 100644
--- a/llvm/tools/llvm-cvtres/llvm-cvtres.cpp
+++ b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -67,7 +67,7 @@ class CvtResOptTable : public opt::OptTable {
};
}
-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),
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index d5ebe5ab0a57..7bd7575dab41 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -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 += '\'';
diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp
index 0d1a7518dad3..eb18be219766 100644
--- a/llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -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,8 +213,8 @@ static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
return std::move(Stub);
}
-int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
- const StringRef Format, raw_ostream &Out) {
+static int writeTbdStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
+ const StringRef Format, raw_ostream &Out) {
auto PlatformKindOrError =
[](const llvm::Triple &T) -> llvm::Expected<llvm::MachO::PlatformKind> {
@@ -275,8 +275,8 @@ int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
return 0;
}
-int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
- const StringRef Format, raw_ostream &Out) {
+static int writeElfStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
+ const StringRef Format, raw_ostream &Out) {
SmallString<0> Storage;
Storage.clear();
raw_svector_ostream OS(Storage);
@@ -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);
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index a848bf029dbf..be3a26c18754 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -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);
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index d56cd30cca17..164254756f43 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -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 =
diff --git a/llvm/tools/llvm-mt/llvm-mt.cpp b/llvm/tools/llvm-mt/llvm-mt.cpp
index cac9b878abba..997e5acbe23e 100644
--- a/llvm/tools/llvm-mt/llvm-mt.cpp
+++ b/llvm/tools/llvm-mt/llvm-mt.cpp
@@ -64,7 +64,7 @@ class CvtResOptTable : public opt::OptTable {
};
} // 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());
diff --git a/llvm/tools/llvm-xray/xray-stacks.cpp b/llvm/tools/llvm-xray/xray-stacks.cpp
index 1e4490289534..185a32439da2 100644
--- a/llvm/tools/llvm-xray/xray-stacks.cpp
+++ b/llvm/tools/llvm-xray/xray-stacks.cpp
@@ -252,13 +252,15 @@ struct format_xray_record : public FormatAdapter<XRayRecord> {
/// 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,
- const StackDuration &Right) {
+static StackDuration mergeStackDuration(const StackDuration &Left,
+ const StackDuration &Right) {
StackDuration Data{};
Data.TerminalDurations.reserve(Left.TerminalDurations.size() +
Right.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,9 +671,9 @@ class StackTrie {
}
};
-std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error,
- const XRayRecord &Record,
- const FuncIdConversionHelper &Converter) {
+static std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error,
+ const XRayRecord &Record,
+ const FuncIdConversionHelper &Converter) {
switch (Error) {
case StackTrie::AccountRecordStatus::ENTRY_NOT_FOUND:
return std::string(
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index f269437c5f9d..9f03606a738c 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -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) {
diff --git a/llvm/tools/sanstats/sanstats.cpp b/llvm/tools/sanstats/sanstats.cpp
index d470a5b50138..1f154e08f243 100644
--- a/llvm/tools/sanstats/sanstats.cpp
+++ b/llvm/tools/sanstats/sanstats.cpp
@@ -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;
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 66b0a9776aaa..b48ae0b10c9a 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -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)
diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
index b30a8b3fa6c2..6a4ef1b8fec3 100644
--- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -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(),
diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index 4e70d6ea41b0..ae675dbe9106 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -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,15 +1518,15 @@ 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,
- IdxVec &VariantClasses,
- bool OnlyExpandMCInstPredicates) {
+static void collectVariantClasses(const CodeGenSchedModels &SchedModels,
+ IdxVec &VariantClasses,
+ bool OnlyExpandMCInstPredicates) {
for (const CodeGenSchedClass &SC : SchedModels.schedClasses()) {
// Ignore non-variant scheduling classes.
if (SC.Transitions.empty())
@@ -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`.
More information about the llvm-commits
mailing list