Skip to content

Commit ebee4ff

Browse files
jurahulakadutta
authored andcommitted
[NFC][LLVM] Code cleanup in bugpoint (llvm#162909)
- Move file local variables and functions out of anonymous namespace and mark them static. - Change a few function names to conform to LLVM coding standard (camelCase). - Add end of namespace comments for anonymous namespaces.
1 parent c869e4a commit ebee4ff

File tree

9 files changed

+177
-199
lines changed

9 files changed

+177
-199
lines changed

llvm/tools/bugpoint/BugDriver.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
#include <memory>
2828
using namespace llvm;
2929

30-
namespace llvm {
31-
Triple TargetTriple;
32-
}
30+
Triple llvm::TargetTriple;
3331

3432
DiscardTemp::~DiscardTemp() {
3533
if (SaveTemps) {
@@ -41,18 +39,14 @@ DiscardTemp::~DiscardTemp() {
4139
errs() << "Failed to delete temp file " << toString(std::move(E)) << '\n';
4240
}
4341

44-
// Anonymous namespace to define command line options for debugging.
45-
//
46-
namespace {
4742
// Output - The user can specify a file containing the expected output of the
4843
// program. If this filename is set, it is used as the reference diff source,
4944
// otherwise the raw input run through an interpreter is used as the reference
5045
// source.
5146
//
52-
cl::opt<std::string> OutputFile("output",
53-
cl::desc("Specify a reference program output "
54-
"(for miscompilation detection)"));
55-
}
47+
static cl::opt<std::string>
48+
OutputFile("output", cl::desc("Specify a reference program output "
49+
"(for miscompilation detection)"));
5650

5751
/// If we reduce or update the program somehow, call this method to update
5852
/// bugdriver with it. This deletes the old module and sets the specified one
@@ -238,7 +232,7 @@ Error BugDriver::run() {
238232
return Error::success();
239233
}
240234

241-
void llvm::PrintFunctionList(const std::vector<Function *> &Funcs) {
235+
void llvm::printFunctionList(const std::vector<Function *> &Funcs) {
242236
unsigned NumPrint = Funcs.size();
243237
if (NumPrint > 10)
244238
NumPrint = 10;
@@ -249,7 +243,7 @@ void llvm::PrintFunctionList(const std::vector<Function *> &Funcs) {
249243
outs().flush();
250244
}
251245

252-
void llvm::PrintGlobalVariableList(const std::vector<GlobalVariable *> &GVs) {
246+
void llvm::printGlobalVariableList(const std::vector<GlobalVariable *> &GVs) {
253247
unsigned NumPrint = GVs.size();
254248
if (NumPrint > 10)
255249
NumPrint = 10;

llvm/tools/bugpoint/BugDriver.h

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class BugDriver {
5757

5858
// FIXME: sort out public/private distinctions...
5959
friend class ReducePassList;
60-
friend class ReduceMisCodegenFunctions;
6160

6261
public:
6362
BugDriver(const char *toolname, bool find_bugs, unsigned timeout,
@@ -76,7 +75,7 @@ class BugDriver {
7675
void setPassesToRun(const std::vector<std::string> &PTR) {
7776
PassesToRun = PTR;
7877
}
79-
const std::vector<std::string> &getPassesToRun() const { return PassesToRun; }
78+
ArrayRef<std::string> getPassesToRun() const { return PassesToRun; }
8079

8180
/// run - The top level method that is invoked after all of the instance
8281
/// variables are set up from command line arguments. The \p as_child argument
@@ -111,7 +110,6 @@ class BugDriver {
111110
Error debugCodeGenerator();
112111

113112
/// isExecutingJIT - Returns true if bugpoint is currently testing the JIT
114-
///
115113
bool isExecutingJIT();
116114

117115
Module &getProgram() const { return *Program; }
@@ -167,7 +165,7 @@ class BugDriver {
167165
bool RemoveBitcode = false) const;
168166

169167
/// This function is used to output M to a file named "bugpoint-ID.bc".
170-
void EmitProgressBitcode(const Module &M, const std::string &ID,
168+
void emitProgressBitcode(const Module &M, const std::string &ID,
171169
bool NoFlyer = false) const;
172170

173171
/// This method clones the current Program and deletes the specified
@@ -214,7 +212,6 @@ class BugDriver {
214212
/// outs() a single line message indicating whether compilation was successful
215213
/// or failed, unless Quiet is set. ExtraArgs specifies additional arguments
216214
/// to pass to the child bugpoint instance.
217-
///
218215
bool runPasses(Module &Program, const std::vector<std::string> &PassesToRun,
219216
std::string &OutputFilename, bool DeleteOutput = false,
220217
bool Quiet = false,
@@ -223,7 +220,6 @@ class BugDriver {
223220
/// runPasses - Just like the method above, but this just returns true or
224221
/// false indicating whether or not the optimizer crashed on the specified
225222
/// input (true = crashed). Does not produce any output.
226-
///
227223
bool runPasses(Module &M, const std::vector<std::string> &PassesToRun) const {
228224
std::string Filename;
229225
return runPasses(M, PassesToRun, Filename, true);
@@ -247,7 +243,6 @@ class BugDriver {
247243
private:
248244
/// initializeExecutionEnvironment - This method is used to set up the
249245
/// environment for executing LLVM programs.
250-
///
251246
Error initializeExecutionEnvironment();
252247
};
253248

@@ -258,37 +253,31 @@ struct DiscardTemp {
258253

259254
/// Given a bitcode or assembly input filename, parse and return it, or return
260255
/// null if not possible.
261-
///
262256
std::unique_ptr<Module> parseInputFile(StringRef InputFilename,
263257
LLVMContext &ctxt);
264258

265259
/// getPassesString - Turn a list of passes into a string which indicates the
266260
/// command line options that must be passed to add the passes.
267-
///
268261
std::string getPassesString(const std::vector<std::string> &Passes);
269262

270-
/// PrintFunctionList - prints out list of problematic functions
271-
///
272-
void PrintFunctionList(const std::vector<Function *> &Funcs);
263+
/// Prints out list of problematic functions
264+
void printFunctionList(const std::vector<Function *> &Funcs);
273265

274-
/// PrintGlobalVariableList - prints out list of problematic global variables
275-
///
276-
void PrintGlobalVariableList(const std::vector<GlobalVariable *> &GVs);
266+
/// Prints out list of problematic global variables
267+
void printGlobalVariableList(const std::vector<GlobalVariable *> &GVs);
277268

278-
// DeleteGlobalInitializer - "Remove" the global variable by deleting its
279-
// initializer, making it external.
280-
//
281-
void DeleteGlobalInitializer(GlobalVariable *GV);
269+
/// "Remove" the global variable by deleting its initializer, making it
270+
/// external.
271+
void deleteGlobalInitializer(GlobalVariable *GV);
282272

283-
// DeleteFunctionBody - "Remove" the function by deleting all of it's basic
284-
// blocks, making it external.
285-
//
286-
void DeleteFunctionBody(Function *F);
273+
/// "Remove" the function by deleting all of it's basic blocks, making it
274+
/// external.
275+
void deleteFunctionBody(Function *F);
287276

288277
/// Given a module and a list of functions in the module, split the functions
289278
/// OUT of the specified module, and place them in the new module.
290279
std::unique_ptr<Module>
291-
SplitFunctionsOutOfModule(Module *M, const std::vector<Function *> &F,
280+
splitFunctionsOutOfModule(Module *M, const std::vector<Function *> &F,
292281
ValueToValueMapTy &VMap);
293282

294283
} // End llvm namespace

0 commit comments

Comments
 (0)