[lldb][NFC] Remove misleading ModulePass base class for IRForTarget

IRForTarget is never used by a pass manager or any other interface that requires
this class to inherit from `Pass`.

Also IRForTarget doesn't implement the current interface correctly because it
uses the `runOnModule` return value to indicate success/failure instead of
changed/not-changed, so if this ever ends up being used as a pass it would most
likely not work as intended.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D102677
This commit is contained in:
Raphael Isemann 2021-05-25 13:11:45 +02:00
parent a3a95286a7
commit 1dee479ff6
2 changed files with 3 additions and 30 deletions

View File

@ -41,8 +41,6 @@
using namespace llvm; using namespace llvm;
static char ID;
typedef SmallVector<Instruction *, 2> InstrList; typedef SmallVector<Instruction *, 2> InstrList;
IRForTarget::FunctionValueCache::FunctionValueCache(Maker const &maker) IRForTarget::FunctionValueCache::FunctionValueCache(Maker const &maker)
@ -72,7 +70,7 @@ IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
lldb_private::IRExecutionUnit &execution_unit, lldb_private::IRExecutionUnit &execution_unit,
lldb_private::Stream &error_stream, lldb_private::Stream &error_stream,
const char *func_name) const char *func_name)
: ModulePass(ID), m_resolve_vars(resolve_vars), m_func_name(func_name), : m_resolve_vars(resolve_vars), m_func_name(func_name),
m_decl_map(decl_map), m_error_stream(error_stream), m_decl_map(decl_map), m_error_stream(error_stream),
m_execution_unit(execution_unit), m_execution_unit(execution_unit),
m_entry_instruction_finder(FindEntryInstruction) {} m_entry_instruction_finder(FindEntryInstruction) {}
@ -101,8 +99,6 @@ static std::string PrintType(const llvm::Type *type, bool truncate = false) {
return s; return s;
} }
IRForTarget::~IRForTarget() {}
bool IRForTarget::FixFunctionLinkage(llvm::Function &llvm_function) { bool IRForTarget::FixFunctionLinkage(llvm::Function &llvm_function) {
llvm_function.setLinkage(GlobalValue::ExternalLinkage); llvm_function.setLinkage(GlobalValue::ExternalLinkage);
@ -2018,10 +2014,3 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
return true; return true;
} }
void IRForTarget::assignPassManager(PMStack &pass_mgr_stack,
PassManagerType pass_mgr_type) {}
PassManagerType IRForTarget::getPotentialPassManagerType() const {
return PMT_ModulePassManager;
}

View File

@ -58,7 +58,7 @@ class IRMemoryMap;
/// transformations to the IR which make it relocatable. These /// transformations to the IR which make it relocatable. These
/// transformations are discussed in more detail next to their relevant /// transformations are discussed in more detail next to their relevant
/// functions. /// functions.
class IRForTarget : public llvm::ModulePass { class IRForTarget {
public: public:
enum class LookupResult { Success, Fail, Ignore }; enum class LookupResult { Success, Fail, Ignore };
@ -87,9 +87,6 @@ public:
lldb_private::Stream &error_stream, lldb_private::Stream &error_stream,
const char *func_name = "$__lldb_expr"); const char *func_name = "$__lldb_expr");
/// Destructor
~IRForTarget() override;
/// Run this IR transformer on a single module /// Run this IR transformer on a single module
/// ///
/// Implementation of the llvm::ModulePass::runOnModule() function. /// Implementation of the llvm::ModulePass::runOnModule() function.
@ -101,20 +98,7 @@ public:
/// ///
/// \return /// \return
/// True on success; false otherwise /// True on success; false otherwise
bool runOnModule(llvm::Module &llvm_module) override; bool runOnModule(llvm::Module &llvm_module);
/// Interface stub
///
/// Implementation of the llvm::ModulePass::assignPassManager() function.
void assignPassManager(llvm::PMStack &pass_mgr_stack,
llvm::PassManagerType pass_mgr_type =
llvm::PMT_ModulePassManager) override;
/// Returns PMT_ModulePassManager
///
/// Implementation of the llvm::ModulePass::getPotentialPassManagerType()
/// function.
llvm::PassManagerType getPotentialPassManagerType() const override;
private: private:
/// Ensures that the current function's linkage is set to external. /// Ensures that the current function's linkage is set to external.