[llvm] 6d4a674 - Revert "[NFC][IR] Make Module::getAliasList() private"

Vasileios Porpodas via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 19:14:25 PST 2023


Author: Vasileios Porpodas
Date: 2023-02-13T19:12:30-08:00
New Revision: 6d4a674acbc56458bb084878d82d16e393d45a6b

URL: https://github.com/llvm/llvm-project/commit/6d4a674acbc56458bb084878d82d16e393d45a6b
DIFF: https://github.com/llvm/llvm-project/commit/6d4a674acbc56458bb084878d82d16e393d45a6b.diff

LOG: Revert "[NFC][IR] Make Module::getAliasList() private"

This reverts commit b64f7d028bdcaf679130afeed9518c09663f6dc8.

Added: 
    

Modified: 
    lldb/source/Expression/IRExecutionUnit.cpp
    llvm/include/llvm/IR/Module.h
    llvm/lib/AsmParser/LLParser.cpp
    llvm/lib/IR/Globals.cpp
    llvm/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/unittests/IR/ModuleTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index 1a7373d0cbb8a..c8068eca5c1b5 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -410,7 +410,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
     RegisterOneValue(global_var);
   }
 
-  for (llvm::GlobalAlias &global_alias : m_module->getAliases()) {
+  for (llvm::GlobalAlias &global_alias : m_module->getAliasList()) {
     RegisterOneValue(global_alias);
   }
 

diff  --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 920729f806660..e86880406b7ea 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -563,16 +563,6 @@ class LLVM_EXTERNAL_VISIBILITY Module {
     return &Module::FunctionList;
   }
 
-  /// Detach \p Alias from the list but don't delete it.
-  void removeAlias(GlobalAlias *Alias) { AliasList.remove(Alias); }
-  /// Remove \p Alias from the list and delete it.
-  void eraseAlias(GlobalAlias *Alias) { AliasList.erase(Alias); }
-  /// Insert \p Alias at the end of the alias list and take ownership.
-  void insertAlias(GlobalAlias *Alias) { AliasList.insert(AliasList.end(), Alias); }
-  // Use alias_size() to get the size of AliasList.
-  // Use aliases() to get a range of all Alias objects in AliasList.
-
-private: // Please use functions like insertAlias(), removeAlias() etc.
   /// Get the Module's list of aliases (constant).
   const AliasListType    &getAliasList() const        { return AliasList; }
   /// Get the Module's list of aliases.
@@ -581,9 +571,7 @@ class LLVM_EXTERNAL_VISIBILITY Module {
   static AliasListType Module::*getSublistAccess(GlobalAlias*) {
     return &Module::AliasList;
   }
-  friend class llvm::SymbolTableListTraits<llvm::GlobalAlias>;
 
-public:
   /// Get the Module's list of ifuncs (constant).
   const IFuncListType    &getIFuncList() const        { return IFuncList; }
   /// Get the Module's list of ifuncs.

diff  --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 2db5e7dc140aa..077b290fe0e00 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -1141,7 +1141,7 @@ bool LLParser::parseAliasOrIFunc(const std::string &Name, LocTy NameLoc,
 
   // Insert into the module, we know its name won't collide now.
   if (IsAlias)
-    M->insertAlias(GA.release());
+    M->getAliasList().push_back(GA.release());
   else
     M->getIFuncList().push_back(GI.release());
   assert(GV->getName() == Name && "Should not be a name conflict!");

diff  --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 7cf812c36984d..a7c45730ff46c 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -514,7 +514,7 @@ GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
                   AddressSpace) {
   setAliasee(Aliasee);
   if (ParentModule)
-    ParentModule->insertAlias(this);
+    ParentModule->getAliasList().push_back(this);
 }
 
 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
@@ -546,11 +546,11 @@ GlobalAlias *GlobalAlias::create(const Twine &Name, GlobalValue *Aliasee) {
 }
 
 void GlobalAlias::removeFromParent() {
-  getParent()->removeAlias(this);
+  getParent()->getAliasList().remove(getIterator());
 }
 
 void GlobalAlias::eraseFromParent() {
-  getParent()->eraseAlias(this);
+  getParent()->getAliasList().erase(getIterator());
 }
 
 void GlobalAlias::setAliasee(Constant *Aliasee) {

diff  --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 040701e243ce5..0317a8bcb6bc7 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2360,7 +2360,7 @@ OptimizeGlobalAliases(Module &M,
       continue;
 
     // Delete the alias.
-    M.eraseAlias(&J);
+    M.getAliasList().erase(&J);
     ++NumAliasesRemoved;
     Changed = true;
   }

diff  --git a/llvm/unittests/IR/ModuleTest.cpp b/llvm/unittests/IR/ModuleTest.cpp
index f9d682d87e7d1..4e2e394a92504 100644
--- a/llvm/unittests/IR/ModuleTest.cpp
+++ b/llvm/unittests/IR/ModuleTest.cpp
@@ -159,44 +159,4 @@ TEST(ModuleTest, setPartialSampleProfileRatio) {
   EXPECT_EQ(Ratio, ProfileSummary->getPartialProfileRatio());
 }
 
-TEST(ModuleTest, AliasList) {
-  // This tests all Module's functions that interact with Module::AliasList.
-  LLVMContext C;
-  SMDiagnostic Err;
-  LLVMContext Context;
-  std::unique_ptr<Module> M = parseAssemblyString(R"(
-declare void @Foo()
- at GA = alias void (), ptr @Foo
-)",
-                                                  Err, Context);
-  Function *Foo = M->getFunction("Foo");
-  auto *GA = M->getNamedAlias("GA");
-  EXPECT_EQ(M->alias_size(), 1u);
-  auto *NewGA =
-      GlobalAlias::create(Foo->getType(), 0, GlobalValue::ExternalLinkage,
-                          "NewGA", Foo, /*Parent=*/nullptr);
-  EXPECT_EQ(M->alias_size(), 1u);
-
-  M->insertAlias(NewGA);
-  EXPECT_EQ(&*std::prev(M->aliases().end()), NewGA);
-
-  M->removeAlias(NewGA);
-  EXPECT_EQ(M->alias_size(), 1u);
-  M->insertAlias(NewGA);
-  EXPECT_EQ(M->alias_size(), 2u);
-  EXPECT_EQ(&*std::prev(M->aliases().end()), NewGA);
-
-  auto Range = M->aliases();
-  EXPECT_EQ(&*Range.begin(), GA);
-  EXPECT_EQ(&*std::next(Range.begin()), NewGA);
-  EXPECT_EQ(std::next(Range.begin(), 2), Range.end());
-
-  M->removeAlias(NewGA);
-  EXPECT_EQ(M->alias_size(), 1u);
-
-  M->insertAlias(NewGA);
-  M->eraseAlias(NewGA);
-  EXPECT_EQ(M->alias_size(), 1u);
-}
-
 } // end namespace


        


More information about the llvm-commits mailing list