Skip to content

Commit 20e9c36

Browse files
committed
Internalize functions from various tools. NFC
And internalize some classes if I noticed them:)
1 parent 6f24774 commit 20e9c36

File tree

16 files changed

+58
-61
lines changed

16 files changed

+58
-61
lines changed

lld/MachO/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void MachOOptTable::printHelp(const char *argv0, bool showHidden) const {
8888
lld::outs() << "\n";
8989
}
9090

91-
HeaderFileType getOutputType(const opt::InputArgList &args) {
91+
static HeaderFileType getOutputType(const opt::InputArgList &args) {
9292
// TODO: -r, -dylinker, -preload...
9393
opt::Arg *outputArg = args.getLastArg(OPT_bundle, OPT_dylib, OPT_execute);
9494
if (outputArg == nullptr)

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static bool canSafelyConvertTo16Bit(Value &V) {
8383
}
8484

8585
// Convert a value to 16-bit.
86-
Value *convertTo16Bit(Value &V, InstCombiner::BuilderTy &Builder) {
86+
static Value *convertTo16Bit(Value &V, InstCombiner::BuilderTy &Builder) {
8787
Type *VTy = V.getType();
8888
if (isa<FPExtInst>(&V) || isa<SExtInst>(&V) || isa<ZExtInst>(&V))
8989
return cast<Instruction>(&V)->getOperand(0);

llvm/tools/llvm-ar/llvm-ar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ USAGE: llvm-ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [f
125125
[V] - display the version and exit
126126
)";
127127

128-
void printHelpMessage() {
128+
static void printHelpMessage() {
129129
if (Stem.contains_lower("ranlib"))
130130
outs() << RanlibHelp;
131131
else if (Stem.contains_lower("ar"))

llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ cl::opt<bool> Summarize("summarize", cl::desc("Print the summary only."),
6060

6161
ExitOnError ExitOnErr;
6262

63-
void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
63+
static void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
6464
auto FileOrErr = MemoryBuffer::getFile(LineInfo.FileName);
6565
if (!FileOrErr) {
6666
errs() << "Could not open file: " << LineInfo.FileName << "\n";
@@ -84,10 +84,10 @@ void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
8484
}
8585
}
8686

87-
void printInstructionInformation(const FileAnalysis &Analysis,
88-
const Instr &InstrMeta,
89-
const GraphResult &Graph,
90-
CFIProtectionStatus ProtectionStatus) {
87+
static void printInstructionInformation(const FileAnalysis &Analysis,
88+
const Instr &InstrMeta,
89+
const GraphResult &Graph,
90+
CFIProtectionStatus ProtectionStatus) {
9191
outs() << "Instruction: " << format_hex(InstrMeta.VMAddress, 2) << " ("
9292
<< stringCFIProtectionStatus(ProtectionStatus) << "): ";
9393
Analysis.printInstruction(InstrMeta, outs());
@@ -97,8 +97,8 @@ void printInstructionInformation(const FileAnalysis &Analysis,
9797
Graph.printToDOT(Analysis, outs());
9898
}
9999

100-
void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
101-
const DILineInfo &LineInfo) {
100+
static void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
101+
const DILineInfo &LineInfo) {
102102
if (BlameLine) {
103103
outs() << "Blacklist Match: " << BlacklistFilename << ":" << BlameLine
104104
<< "\n";
@@ -122,8 +122,9 @@ void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
122122
}
123123
}
124124

125-
void printIndirectCFInstructions(FileAnalysis &Analysis,
126-
const SpecialCaseList *SpecialCaseList) {
125+
static void
126+
printIndirectCFInstructions(FileAnalysis &Analysis,
127+
const SpecialCaseList *SpecialCaseList) {
127128
uint64_t ExpectedProtected = 0;
128129
uint64_t UnexpectedProtected = 0;
129130
uint64_t ExpectedUnprotected = 0;

llvm/tools/llvm-cvtres/llvm-cvtres.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CvtResOptTable : public opt::OptTable {
6767
};
6868
}
6969

70-
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
70+
static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
7171
errs() << Msg;
7272
exit(1);
7373
}
@@ -76,13 +76,7 @@ static void reportError(StringRef Input, std::error_code EC) {
7676
reportError(Twine(Input) + ": " + EC.message() + ".\n");
7777
}
7878

79-
void error(std::error_code EC) {
80-
if (!EC)
81-
return;
82-
reportError(EC.message() + ".\n");
83-
}
84-
85-
void error(Error EC) {
79+
static void error(Error EC) {
8680
if (!EC)
8781
return;
8882
handleAllErrors(std::move(EC),

llvm/tools/llvm-dwp/llvm-dwp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ writeIndex(MCStreamer &Out, MCSection *Section,
377377
&DWARFUnitIndex::Entry::SectionContribution::Length);
378378
}
379379

380-
std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWOName) {
380+
static std::string buildDWODescription(StringRef Name, StringRef DWPName,
381+
StringRef DWOName) {
381382
std::string Text = "\'";
382383
Text += Name;
383384
Text += '\'';

llvm/tools/llvm-ifs/llvm-ifs.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum class IFSSymbolType {
6262
Unknown = 16,
6363
};
6464

65-
std::string getTypeName(IFSSymbolType Type) {
65+
static std::string getTypeName(IFSSymbolType Type) {
6666
switch (Type) {
6767
case IFSSymbolType::NoType:
6868
return "NoType";
@@ -213,8 +213,8 @@ static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
213213
return std::move(Stub);
214214
}
215215

216-
int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
217-
const StringRef Format, raw_ostream &Out) {
216+
static int writeTbdStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
217+
const StringRef Format, raw_ostream &Out) {
218218

219219
auto PlatformKindOrError =
220220
[](const llvm::Triple &T) -> llvm::Expected<llvm::MachO::PlatformKind> {
@@ -275,8 +275,8 @@ int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
275275
return 0;
276276
}
277277

278-
int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
279-
const StringRef Format, raw_ostream &Out) {
278+
static int writeElfStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
279+
const StringRef Format, raw_ostream &Out) {
280280
SmallString<0> Storage;
281281
Storage.clear();
282282
raw_svector_ostream OS(Storage);
@@ -358,7 +358,7 @@ int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
358358
return convertYAML(YIn, Out, ErrHandler) ? 0 : 1;
359359
}
360360

361-
int writeIfso(const IFSStub &Stub, bool IsWriteIfs, raw_ostream &Out) {
361+
static int writeIfso(const IFSStub &Stub, bool IsWriteIfs, raw_ostream &Out) {
362362
if (IsWriteIfs) {
363363
yaml::Output YamlOut(Out, NULL, /*WrapColumn =*/0);
364364
YamlOut << const_cast<IFSStub &>(Stub);

llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ Session::findSymbolInfo(StringRef SymbolName, Twine ErrorMsgStem) {
770770

771771
} // end namespace llvm
772772

773-
Triple getFirstFileTriple() {
773+
static Triple getFirstFileTriple() {
774774
assert(!InputFiles.empty() && "InputFiles can not be empty");
775775
auto ObjBuffer =
776776
ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(InputFiles.front())));
@@ -779,7 +779,7 @@ Triple getFirstFileTriple() {
779779
return Obj->makeTriple();
780780
}
781781

782-
Error sanitizeArguments(const Session &S) {
782+
static Error sanitizeArguments(const Session &S) {
783783
if (EntryPointName.empty()) {
784784
if (S.TPC->getTargetTriple().getObjectFormat() == Triple::MachO)
785785
EntryPointName = "_main";
@@ -801,7 +801,7 @@ Error sanitizeArguments(const Session &S) {
801801
return Error::success();
802802
}
803803

804-
Error loadProcessSymbols(Session &S) {
804+
static Error loadProcessSymbols(Session &S) {
805805
auto InternedEntryPointName = S.ES.intern(EntryPointName);
806806
auto FilterMainEntryPoint = [InternedEntryPointName](SymbolStringPtr Name) {
807807
return Name != InternedEntryPointName;
@@ -813,7 +813,7 @@ Error loadProcessSymbols(Session &S) {
813813
return Error::success();
814814
}
815815

816-
Error loadDylibs() {
816+
static Error loadDylibs() {
817817
// FIXME: This should all be handled inside DynamicLibrary.
818818
for (const auto &Dylib : Dylibs) {
819819
if (!sys::fs::is_regular_file(Dylib))
@@ -827,12 +827,11 @@ Error loadDylibs() {
827827
return Error::success();
828828
}
829829

830-
void addPhonyExternalsGenerator(Session &S) {
830+
static void addPhonyExternalsGenerator(Session &S) {
831831
S.MainJD->addGenerator(std::make_unique<PhonyExternalsGenerator>());
832832
}
833833

834-
Error loadObjects(Session &S) {
835-
834+
static Error loadObjects(Session &S) {
836835
std::map<unsigned, JITDylib *> IdxToJLD;
837836

838837
// First, set up JITDylibs.
@@ -941,7 +940,7 @@ Error loadObjects(Session &S) {
941940
return Error::success();
942941
}
943942

944-
Error runChecks(Session &S) {
943+
static Error runChecks(Session &S) {
945944

946945
auto TripleName = S.TPC->getTargetTriple().str();
947946
std::string ErrorStr;
@@ -1036,12 +1035,14 @@ static Expected<JITEvaluatedSymbol> getMainEntryPoint(Session &S) {
10361035
return S.ES.lookup(S.JDSearchOrder, EntryPointName);
10371036
}
10381037

1038+
namespace {
10391039
struct JITLinkTimers {
10401040
TimerGroup JITLinkTG{"llvm-jitlink timers", "timers for llvm-jitlink phases"};
10411041
Timer LoadObjectsTimer{"load", "time to load/add object files", JITLinkTG};
10421042
Timer LinkTimer{"link", "time to link object files", JITLinkTG};
10431043
Timer RunTimer{"run", "time to execute jitlink'd code", JITLinkTG};
10441044
};
1045+
} // namespace
10451046

10461047
int main(int argc, char *argv[]) {
10471048
InitLLVM X(argc, argv);

llvm/tools/llvm-lto/llvm-lto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer,
337337
}
338338

339339
/// Print some statistics on the index for each input files.
340-
void printIndexStats() {
340+
static void printIndexStats() {
341341
for (auto &Filename : InputFilenames) {
342342
ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': ");
343343
std::unique_ptr<ModuleSummaryIndex> Index =

llvm/tools/llvm-mt/llvm-mt.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CvtResOptTable : public opt::OptTable {
6464
};
6565
} // namespace
6666

67-
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
67+
LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) {
6868
WithColor::error(errs(), "llvm-mt") << Msg << '\n';
6969
exit(1);
7070
}
@@ -73,12 +73,7 @@ static void reportError(StringRef Input, std::error_code EC) {
7373
reportError(Twine(Input) + ": " + EC.message());
7474
}
7575

76-
void error(std::error_code EC) {
77-
if (EC)
78-
reportError(EC.message());
79-
}
80-
81-
void error(Error EC) {
76+
static void error(Error EC) {
8277
if (EC)
8378
handleAllErrors(std::move(EC), [&](const ErrorInfoBase &EI) {
8479
reportError(EI.message());

llvm/tools/llvm-xray/xray-stacks.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,15 @@ struct format_xray_record : public FormatAdapter<XRayRecord> {
252252
/// maintain an index of unique functions, and provide a means of iterating
253253
/// through all the instrumented call stacks which we know about.
254254

255+
namespace {
255256
struct StackDuration {
256257
llvm::SmallVector<int64_t, 4> TerminalDurations;
257258
llvm::SmallVector<int64_t, 4> IntermediateDurations;
258259
};
260+
} // namespace
259261

260-
StackDuration mergeStackDuration(const StackDuration &Left,
261-
const StackDuration &Right) {
262+
static StackDuration mergeStackDuration(const StackDuration &Left,
263+
const StackDuration &Right) {
262264
StackDuration Data{};
263265
Data.TerminalDurations.reserve(Left.TerminalDurations.size() +
264266
Right.TerminalDurations.size());
@@ -280,7 +282,7 @@ StackDuration mergeStackDuration(const StackDuration &Left,
280282
using StackTrieNode = TrieNode<StackDuration>;
281283

282284
template <AggregationType AggType>
283-
std::size_t GetValueForStack(const StackTrieNode *Node);
285+
static std::size_t GetValueForStack(const StackTrieNode *Node);
284286

285287
// When computing total time spent in a stack, we're adding the timings from
286288
// its callees and the timings from when it was a leaf.
@@ -669,9 +671,9 @@ class StackTrie {
669671
}
670672
};
671673

672-
std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error,
673-
const XRayRecord &Record,
674-
const FuncIdConversionHelper &Converter) {
674+
static std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error,
675+
const XRayRecord &Record,
676+
const FuncIdConversionHelper &Converter) {
675677
switch (Error) {
676678
case StackTrie::AccountRecordStatus::ENTRY_NOT_FOUND:
677679
return std::string(

llvm/tools/opt/opt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
446446
void initializeExampleIRTransforms(llvm::PassRegistry &Registry);
447447
#endif
448448

449-
450-
void exportDebugifyStats(llvm::StringRef Path, const DebugifyStatsMap &Map) {
449+
static void exportDebugifyStats(llvm::StringRef Path,
450+
const DebugifyStatsMap &Map) {
451451
std::error_code EC;
452452
raw_fd_ostream OS{Path, EC};
453453
if (EC) {

llvm/tools/sanstats/sanstats.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ inline uint64_t CountFromData(uint64_t Data, char SizeofPtr) {
3636
return Data & ((1ull << (SizeofPtr * 8 - kSanitizerStatKindBits)) - 1);
3737
}
3838

39-
uint64_t ReadLE(char Size, const char *Begin, const char *End) {
39+
static uint64_t ReadLE(char Size, const char *Begin, const char *End) {
4040
uint64_t Result = 0;
4141
char Pos = 0;
4242
while (Begin < End && Pos != Size) {
@@ -47,7 +47,8 @@ uint64_t ReadLE(char Size, const char *Begin, const char *End) {
4747
return Result;
4848
}
4949

50-
const char *ReadModule(char SizeofPtr, const char *Begin, const char *End) {
50+
static const char *ReadModule(char SizeofPtr, const char *Begin,
51+
const char *End) {
5152
const char *FilenameBegin = Begin;
5253
while (Begin != End && *Begin)
5354
++Begin;

llvm/utils/FileCheck/FileCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ struct InputAnnotation {
324324
};
325325

326326
/// Get an abbreviation for the check type.
327-
std::string GetCheckTypeAbbreviation(Check::FileCheckType Ty) {
327+
static std::string GetCheckTypeAbbreviation(Check::FileCheckType Ty) {
328328
switch (Ty) {
329329
case Check::CheckPlain:
330330
if (Ty.getCount() > 1)

llvm/utils/TableGen/RegisterInfoEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ EmitRegUnitPressure(raw_ostream &OS, const CodeGenRegBank &RegBank,
356356
using DwarfRegNumsMapPair = std::pair<Record*, std::vector<int64_t>>;
357357
using DwarfRegNumsVecTy = std::vector<DwarfRegNumsMapPair>;
358358

359-
void finalizeDwarfRegNumsKeys(DwarfRegNumsVecTy &DwarfRegNums) {
359+
static void finalizeDwarfRegNumsKeys(DwarfRegNumsVecTy &DwarfRegNums) {
360360
// Sort and unique to get a map-like vector. We want the last assignment to
361361
// match previous behaviour.
362362
std::stable_sort(DwarfRegNums.begin(), DwarfRegNums.end(),

llvm/utils/TableGen/SubtargetEmitter.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,8 @@ static void emitPredicates(const CodeGenSchedTransition &T,
15071507

15081508
// Used by method `SubtargetEmitter::emitSchedModelHelpersImpl()` to generate
15091509
// epilogue code for the auto-generated helper.
1510-
void emitSchedModelHelperEpilogue(raw_ostream &OS, bool ShouldReturnZero) {
1510+
static void emitSchedModelHelperEpilogue(raw_ostream &OS,
1511+
bool ShouldReturnZero) {
15111512
if (ShouldReturnZero) {
15121513
OS << " // Don't know how to resolve this scheduling class.\n"
15131514
<< " return 0;\n";
@@ -1517,15 +1518,15 @@ void emitSchedModelHelperEpilogue(raw_ostream &OS, bool ShouldReturnZero) {
15171518
OS << " report_fatal_error(\"Expected a variant SchedClass\");\n";
15181519
}
15191520

1520-
bool hasMCSchedPredicates(const CodeGenSchedTransition &T) {
1521+
static bool hasMCSchedPredicates(const CodeGenSchedTransition &T) {
15211522
return all_of(T.PredTerm, [](const Record *Rec) {
15221523
return Rec->isSubClassOf("MCSchedPredicate");
15231524
});
15241525
}
15251526

1526-
void collectVariantClasses(const CodeGenSchedModels &SchedModels,
1527-
IdxVec &VariantClasses,
1528-
bool OnlyExpandMCInstPredicates) {
1527+
static void collectVariantClasses(const CodeGenSchedModels &SchedModels,
1528+
IdxVec &VariantClasses,
1529+
bool OnlyExpandMCInstPredicates) {
15291530
for (const CodeGenSchedClass &SC : SchedModels.schedClasses()) {
15301531
// Ignore non-variant scheduling classes.
15311532
if (SC.Transitions.empty())
@@ -1544,7 +1545,8 @@ void collectVariantClasses(const CodeGenSchedModels &SchedModels,
15441545
}
15451546
}
15461547

1547-
void collectProcessorIndices(const CodeGenSchedClass &SC, IdxVec &ProcIndices) {
1548+
static void collectProcessorIndices(const CodeGenSchedClass &SC,
1549+
IdxVec &ProcIndices) {
15481550
// A variant scheduling class may define transitions for multiple
15491551
// processors. This function identifies wich processors are associated with
15501552
// transition rules specified by variant class `SC`.

0 commit comments

Comments
 (0)