[Lldb-commits] [lldb] 1dee479 - [lldb][NFC] Remove misleading ModulePass base class for IRForTarget

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue May 25 04:27:23 PDT 2021


Author: Raphael Isemann
Date: 2021-05-25T13:27:07+02:00
New Revision: 1dee479ff632ef841ca7b28485779d898dd15e84

URL: https://github.com/llvm/llvm-project/commit/1dee479ff632ef841ca7b28485779d898dd15e84
DIFF: https://github.com/llvm/llvm-project/commit/1dee479ff632ef841ca7b28485779d898dd15e84.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
    lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 0173c8f263a5..bb69471841fe 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -41,8 +41,6 @@
 
 using namespace llvm;
 
-static char ID;
-
 typedef SmallVector<Instruction *, 2> InstrList;
 
 IRForTarget::FunctionValueCache::FunctionValueCache(Maker const &maker)
@@ -72,7 +70,7 @@ IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
                          lldb_private::IRExecutionUnit &execution_unit,
                          lldb_private::Stream &error_stream,
                          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_execution_unit(execution_unit),
       m_entry_instruction_finder(FindEntryInstruction) {}
@@ -101,8 +99,6 @@ static std::string PrintType(const llvm::Type *type, bool truncate = false) {
   return s;
 }
 
-IRForTarget::~IRForTarget() {}
-
 bool IRForTarget::FixFunctionLinkage(llvm::Function &llvm_function) {
   llvm_function.setLinkage(GlobalValue::ExternalLinkage);
 
@@ -2018,10 +2014,3 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
 
   return true;
 }
-
-void IRForTarget::assignPassManager(PMStack &pass_mgr_stack,
-                                    PassManagerType pass_mgr_type) {}
-
-PassManagerType IRForTarget::getPotentialPassManagerType() const {
-  return PMT_ModulePassManager;
-}

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index 6ff50ec5f645..5f212fa8f918 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -58,7 +58,7 @@ class IRMemoryMap;
 /// transformations to the IR which make it relocatable.  These
 /// transformations are discussed in more detail next to their relevant
 /// functions.
-class IRForTarget : public llvm::ModulePass {
+class IRForTarget {
 public:
   enum class LookupResult { Success, Fail, Ignore };
 
@@ -87,9 +87,6 @@ class IRForTarget : public llvm::ModulePass {
               lldb_private::Stream &error_stream,
               const char *func_name = "$__lldb_expr");
 
-  /// Destructor
-  ~IRForTarget() override;
-
   /// Run this IR transformer on a single module
   ///
   /// Implementation of the llvm::ModulePass::runOnModule() function.
@@ -101,20 +98,7 @@ class IRForTarget : public llvm::ModulePass {
   ///
   /// \return
   ///     True on success; false otherwise
-  bool runOnModule(llvm::Module &llvm_module) override;
-
-  /// 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;
+  bool runOnModule(llvm::Module &llvm_module);
 
 private:
   /// Ensures that the current function's linkage is set to external.


        


More information about the lldb-commits mailing list