From cee5b84e49d7bfaac46f5c15a19302a3e34355c4 Mon Sep 17 00:00:00 2001 From: Rahul Joshi Date: Thu, 20 Nov 2025 14:22:08 -0800 Subject: [PATCH] Revert "[NFC][bugpoint] Namespace cleanup in `bugpoint` (#168921)" This reverts commit bf91a62269964398836544020def699e3f019b9b. --- llvm/tools/bugpoint/BugDriver.h | 5 ----- llvm/tools/bugpoint/CrashDebugger.cpp | 4 +++- llvm/tools/bugpoint/ExecutionDriver.cpp | 17 ++++++++++------- llvm/tools/bugpoint/ExtractFunction.cpp | 3 +++ llvm/tools/bugpoint/Miscompilation.cpp | 5 +++++ llvm/tools/bugpoint/OptimizerDriver.cpp | 4 ++++ 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/llvm/tools/bugpoint/BugDriver.h b/llvm/tools/bugpoint/BugDriver.h index 71a5aa14bbb2e..ca57405f9d770 100644 --- a/llvm/tools/bugpoint/BugDriver.h +++ b/llvm/tools/bugpoint/BugDriver.h @@ -16,7 +16,6 @@ #define LLVM_TOOLS_BUGPOINT_BUGDRIVER_H #include "llvm/IR/ValueMap.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileSystem.h" #include "llvm/Transforms/Utils/ValueMapper.h" @@ -42,10 +41,6 @@ extern bool DisableSimplifyCFG; /// extern bool BugpointIsInterrupted; -/// Command line options used across files. -extern cl::list InputArgv; -extern cl::opt OutputPrefix; - class BugDriver { LLVMContext &Context; const char *ToolName; // argv[0] of bugpoint diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp index 1c2f1704f868e..240300b324367 100644 --- a/llvm/tools/bugpoint/CrashDebugger.cpp +++ b/llvm/tools/bugpoint/CrashDebugger.cpp @@ -87,9 +87,10 @@ static bool isValidModule(std::unique_ptr &M, return false; } +namespace llvm { // Note this class needs to be in llvm namespace since its declared as a friend // of BugDriver. -class llvm::ReducePassList : public ListReducer { +class ReducePassList : public ListReducer { BugDriver &BD; public: @@ -101,6 +102,7 @@ class llvm::ReducePassList : public ListReducer { Expected doTest(std::vector &Removed, std::vector &Kept) override; }; +} // namespace llvm Expected ReducePassList::doTest(std::vector &Prefix, diff --git a/llvm/tools/bugpoint/ExecutionDriver.cpp b/llvm/tools/bugpoint/ExecutionDriver.cpp index 96eeb35b4db70..8c6b7fbe50c7c 100644 --- a/llvm/tools/bugpoint/ExecutionDriver.cpp +++ b/llvm/tools/bugpoint/ExecutionDriver.cpp @@ -13,6 +13,7 @@ #include "BugDriver.h" #include "ToolRunner.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Program.h" @@ -101,13 +102,15 @@ static cl::opt CustomExecCommand( // Anything specified after the --args option are taken as arguments to the // program being debugged. -cl::list llvm::InputArgv("args", cl::Positional, - cl::desc("..."), - cl::PositionalEatsArgs); - -cl::opt llvm::OutputPrefix( - "output-prefix", cl::init("bugpoint"), - cl::desc("Prefix to use for outputs (default: 'bugpoint')")); +namespace llvm { +cl::list InputArgv("args", cl::Positional, + cl::desc("..."), + cl::PositionalEatsArgs); + +cl::opt + OutputPrefix("output-prefix", cl::init("bugpoint"), + cl::desc("Prefix to use for outputs (default: 'bugpoint')")); +} // namespace llvm static cl::list ToolArgv("tool-args", cl::Positional, cl::desc("..."), diff --git a/llvm/tools/bugpoint/ExtractFunction.cpp b/llvm/tools/bugpoint/ExtractFunction.cpp index 31cdd0d43f2fc..3206589ff38f2 100644 --- a/llvm/tools/bugpoint/ExtractFunction.cpp +++ b/llvm/tools/bugpoint/ExtractFunction.cpp @@ -36,6 +36,9 @@ using namespace llvm; #define DEBUG_TYPE "bugpoint" bool llvm::DisableSimplifyCFG = false; +namespace llvm { +extern cl::opt OutputPrefix; +} // namespace llvm static cl::opt NoDCE("disable-dce", diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp index dcad126d87865..a7f1643aecf15 100644 --- a/llvm/tools/bugpoint/Miscompilation.cpp +++ b/llvm/tools/bugpoint/Miscompilation.cpp @@ -28,6 +28,11 @@ using namespace llvm; +namespace llvm { +extern cl::opt OutputPrefix; +extern cl::list InputArgv; +} // end namespace llvm + static cl::opt DisableLoopExtraction( "disable-loop-extraction", cl::desc("Don't extract loops when searching for miscompilations"), diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp index 191f87c08a0f6..bf2e8c0b4a910 100644 --- a/llvm/tools/bugpoint/OptimizerDriver.cpp +++ b/llvm/tools/bugpoint/OptimizerDriver.cpp @@ -34,6 +34,10 @@ using namespace llvm; #define DEBUG_TYPE "bugpoint" +namespace llvm { +extern cl::opt OutputPrefix; +} + static cl::opt OptCmd("opt-command", cl::init(""), cl::desc("Path to opt. (default: search path "