[clang] bebca2b - [NFC] Cleanup: Replaces BB->getInstList().splice() with BB->splice().

2022-12-01 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2022-12-01T15:37:51-08:00
New Revision: bebca2b6d559f545c82047b2071273b4c243d13b

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

LOG: [NFC] Cleanup: Replaces BB->getInstList().splice() with BB->splice().

This is part of a series of cleanup patches towards making 
BasicBlock::getInstList() private.

Differential Revision: https://reviews.llvm.org/D138979

Added: 


Modified: 
clang/lib/CodeGen/CGCleanup.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/lib/Transforms/Scalar/LoopInterchange.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/FlattenCFG.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 5035ed34358d2..8ef2fb871956c 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -556,7 +556,7 @@ static llvm::BasicBlock 
*SimplifyCleanupEntry(CodeGenFunction &CGF,
   Entry->replaceAllUsesWith(Pred);
 
   // Merge the blocks.
-  Pred->getInstList().splice(Pred->end(), Entry->getInstList());
+  Pred->splice(Pred->end(), Entry);
 
   // Kill the entry block.
   Entry->eraseFromParent();

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 23a8895013de2..b0c8261c9addd 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -261,8 +261,7 @@ void llvm::spliceBB(IRBuilderBase::InsertPoint IP, 
BasicBlock *New,
 
   // Move instructions to new block.
   BasicBlock *Old = IP.getBlock();
-  New->getInstList().splice(New->begin(), Old->getInstList(), IP.getPoint(),
-Old->end());
+  New->splice(New->begin(), Old, IP.getPoint(), Old->end());
 
   if (CreateBranch)
 BranchInst::Create(New, Old);

diff  --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 1dea11c6ea7d2..3988054f33bd2 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -115,7 +115,7 @@ void Instruction::moveAfter(Instruction *MovePos) {
 void Instruction::moveBefore(BasicBlock &BB,
  SymbolTableList::iterator I) {
   assert(I == BB.end() || I->getParent() == &BB);
-  BB.getInstList().splice(I, getParent()->getInstList(), getIterator());
+  BB.splice(I, getParent(), getIterator());
 }
 
 bool Instruction::comesBefore(const Instruction *Other) const {

diff  --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp 
b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index b54ece4ad1cdf..36ede8ebccc61 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -201,8 +201,8 @@ static bool replaceCoroEndAsync(AnyCoroEndInst *End) {
   assert(MustTailCallFuncBlock && "Must have a single predecessor block");
   auto It = MustTailCallFuncBlock->getTerminator()->getIterator();
   auto *MustTailCall = cast(&*std::prev(It));
-  CoroEndBlock->getInstList().splice(
-  End->getIterator(), MustTailCallFuncBlock->getInstList(), MustTailCall);
+  CoroEndBlock->splice(End->getIterator(), MustTailCallFuncBlock,
+   MustTailCall->getIterator());
 
   // Insert the return instruction.
   Builder.SetInsertPoint(End);

diff  --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp 
b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 57e1b1c7c8182..a4ea93084c06c 100644
--- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -1350,11 +1350,10 @@ bool LoopInterchangeTransform::transform() {
 /// \brief Move all instructions except the terminator from FromBB right before
 /// InsertBefore
 static void moveBBContents(BasicBlock *FromBB, Instruction *InsertBefore) {
-  auto &ToList = InsertBefore->getParent()->getInstList();
-  auto &FromList = FromBB->getInstList();
+  BasicBlock *ToBB = InsertBefore->getParent();
 
-  ToList.splice(InsertBefore->getIterator(), FromList, FromList.begin(),
-FromBB->getTerminator()->getIterator());
+  ToBB->splice(InsertBefore->getIterator(), FromBB, FromBB->begin(),
+   FromBB->getTerminator()->getIterator());
 }
 
 /// Swap instructions between \p BB1 and \p BB2 but keep terminators intact.

diff  --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp 
b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 35494e86996be..399aa635485ac 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnsw

[clang] ed3e3ee - [NFC][IR] Make Module::getGlobalList() private

2023-02-14 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2023-02-14T14:25:10-08:00
New Revision: ed3e3ee9e30dfbffd2170a770a49b36a7f444916

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

LOG: [NFC][IR] Make Module::getGlobalList() private

This patch adds several missing GlobalList modifier functions, like
removeGlobalVariable(), eraseGlobalVariable() and insertGlobalVariable().
There is no longer need to access the list directly so it also makes
getGlobalList() private.

Differential Revision: https://reviews.llvm.org/D144027

Added: 


Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGObjCMac.cpp
lldb/source/Expression/IRExecutionUnit.cpp
llvm/docs/ProgrammersManual.rst
llvm/include/llvm/IR/Module.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/IPO/SCCP.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Utils/CtorUtils.cpp
llvm/unittests/IR/ModuleTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 5882f491d5972..e9fa273f21cc8 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -175,7 +175,7 @@ void CGHLSLRuntime::finishCodeGen() {
   for (auto &Buf : Buffers) {
 layoutBuffer(Buf, DL);
 GlobalVariable *GV = replaceBuffer(Buf);
-M.getGlobalList().push_back(GV);
+M.insertGlobalVariable(GV);
 llvm::hlsl::ResourceClass RC = Buf.IsCBuffer
? llvm::hlsl::ResourceClass::CBuffer
: llvm::hlsl::ResourceClass::SRV;

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index c739d3742f801..5f4cdc6d91f1d 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -7431,7 +7431,7 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name,
   GV->eraseFromParent();
 }
 GV = NewGV;
-CGM.getModule().getGlobalList().push_back(GV);
+CGM.getModule().insertGlobalVariable(GV);
   }
 
   assert(GV->getLinkage() == L);

diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 73a49e552e3d2..f3cf0f623d24f 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -406,7 +406,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, 
lldb::addr_t &func_addr,
 }
   };
 
-  for (llvm::GlobalVariable &global_var : m_module->getGlobalList()) {
+  for (llvm::GlobalVariable &global_var : m_module->globals()) {
 RegisterOneValue(global_var);
   }
 

diff  --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index 00d51a5a05b85..71298f4a87828 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -3429,17 +3429,14 @@ Important Public Members of the ``Module`` class
 
 * | ``Module::global_iterator`` - Typedef for global variable list iterator
   | ``Module::const_global_iterator`` - Typedef for const_iterator.
+  | ``Module::insertGlobalVariable()`` - Inserts a global variable to the list.
+  | ``Module::removeGlobalVariable()`` - Removes a global variable frome the 
list.
+  | ``Module::eraseGlobalVariable()`` - Removes a global variable frome the 
list and deletes it.
   | ``global_begin()``, ``global_end()``, ``global_size()``, ``global_empty()``
 
   These are forwarding methods that make it easy to access the contents of a
   ``Module`` object's GlobalVariable_ list.
 
-* ``Module::GlobalListType &getGlobalList()``
-
-  Returns the list of GlobalVariable_\ s.  This is necessary to use when you
-  need to update the list or perform a complex action that doesn't have a
-  forwarding method.
-
 
 
 * ``SymbolTable *getSymbolTable()``

diff  --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index dbd3eae0f134c..aacdbbf08b945 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -542,6 +542,24 @@ class LLVM_EXTERNAL_VISIBILITY Module {
 
   llvm::Error materializeMetadata();
 
+  /// Detach global variable \p GV from the list but don't delete it.
+  void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); }
+  /// Remove global variable \p GV from the list and delete it.
+  void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); }
+  /// Insert global variable \p GV at the end of the global variable list and
+  /// take ownership.
+  void insertGlobalVariable(GlobalVariable *GV) {
+insertGlobalVariable(GlobalList.end(), GV);
+  }

[clang] cb5f239 - Revert "[NFC][IR] Make Module::getGlobalList() private"

2023-02-14 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2023-02-14T14:29:42-08:00
New Revision: cb5f239363a3c94db5425c105fcd45e77d2a16a9

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

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

This reverts commit ed3e3ee9e30dfbffd2170a770a49b36a7f444916.

Added: 


Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGObjCMac.cpp
lldb/source/Expression/IRExecutionUnit.cpp
llvm/docs/ProgrammersManual.rst
llvm/include/llvm/IR/Module.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/IPO/SCCP.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Utils/CtorUtils.cpp
llvm/unittests/IR/ModuleTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index e9fa273f21cc8..5882f491d5972 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -175,7 +175,7 @@ void CGHLSLRuntime::finishCodeGen() {
   for (auto &Buf : Buffers) {
 layoutBuffer(Buf, DL);
 GlobalVariable *GV = replaceBuffer(Buf);
-M.insertGlobalVariable(GV);
+M.getGlobalList().push_back(GV);
 llvm::hlsl::ResourceClass RC = Buf.IsCBuffer
? llvm::hlsl::ResourceClass::CBuffer
: llvm::hlsl::ResourceClass::SRV;

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 5f4cdc6d91f1d..c739d3742f801 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -7431,7 +7431,7 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name,
   GV->eraseFromParent();
 }
 GV = NewGV;
-CGM.getModule().insertGlobalVariable(GV);
+CGM.getModule().getGlobalList().push_back(GV);
   }
 
   assert(GV->getLinkage() == L);

diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index f3cf0f623d24f..73a49e552e3d2 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -406,7 +406,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, 
lldb::addr_t &func_addr,
 }
   };
 
-  for (llvm::GlobalVariable &global_var : m_module->globals()) {
+  for (llvm::GlobalVariable &global_var : m_module->getGlobalList()) {
 RegisterOneValue(global_var);
   }
 

diff  --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index 71298f4a87828..00d51a5a05b85 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -3429,14 +3429,17 @@ Important Public Members of the ``Module`` class
 
 * | ``Module::global_iterator`` - Typedef for global variable list iterator
   | ``Module::const_global_iterator`` - Typedef for const_iterator.
-  | ``Module::insertGlobalVariable()`` - Inserts a global variable to the list.
-  | ``Module::removeGlobalVariable()`` - Removes a global variable frome the 
list.
-  | ``Module::eraseGlobalVariable()`` - Removes a global variable frome the 
list and deletes it.
   | ``global_begin()``, ``global_end()``, ``global_size()``, ``global_empty()``
 
   These are forwarding methods that make it easy to access the contents of a
   ``Module`` object's GlobalVariable_ list.
 
+* ``Module::GlobalListType &getGlobalList()``
+
+  Returns the list of GlobalVariable_\ s.  This is necessary to use when you
+  need to update the list or perform a complex action that doesn't have a
+  forwarding method.
+
 
 
 * ``SymbolTable *getSymbolTable()``

diff  --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index aacdbbf08b945..dbd3eae0f134c 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -542,24 +542,6 @@ class LLVM_EXTERNAL_VISIBILITY Module {
 
   llvm::Error materializeMetadata();
 
-  /// Detach global variable \p GV from the list but don't delete it.
-  void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); }
-  /// Remove global variable \p GV from the list and delete it.
-  void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); }
-  /// Insert global variable \p GV at the end of the global variable list and
-  /// take ownership.
-  void insertGlobalVariable(GlobalVariable *GV) {
-insertGlobalVariable(GlobalList.end(), GV);
-  }
-  /// Insert global variable \p GV into the global variable list before \p
-  /// Where and take ownership.
-  void insertGlobalVariable(GlobalListType::iterator Where, GlobalVariable 
*GV) {
-GlobalList.insert(Where,

[clang] 823186b - Recommit: [NFC][IR] Make Module::getGlobalList() private

2023-02-14 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2023-02-14T15:12:51-08:00
New Revision: 823186b14dc97c950a808f6f4b434d399da9a220

URL: 
https://github.com/llvm/llvm-project/commit/823186b14dc97c950a808f6f4b434d399da9a220
DIFF: 
https://github.com/llvm/llvm-project/commit/823186b14dc97c950a808f6f4b434d399da9a220.diff

LOG: Recommit: [NFC][IR] Make Module::getGlobalList() private

This reverts commit cb5f239363a3c94db5425c105fcd45e77d2a16a9.

Added: 


Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGObjCMac.cpp
lldb/source/Expression/IRExecutionUnit.cpp
llvm/docs/ProgrammersManual.rst
llvm/include/llvm/IR/Module.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/Linker/IRMover.cpp
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/lib/Transforms/IPO/SCCP.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Utils/CtorUtils.cpp
llvm/unittests/IR/ModuleTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 5882f491d5972..e9fa273f21cc8 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -175,7 +175,7 @@ void CGHLSLRuntime::finishCodeGen() {
   for (auto &Buf : Buffers) {
 layoutBuffer(Buf, DL);
 GlobalVariable *GV = replaceBuffer(Buf);
-M.getGlobalList().push_back(GV);
+M.insertGlobalVariable(GV);
 llvm::hlsl::ResourceClass RC = Buf.IsCBuffer
? llvm::hlsl::ResourceClass::CBuffer
: llvm::hlsl::ResourceClass::SRV;

diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index c739d3742f801..5f4cdc6d91f1d 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -7431,7 +7431,7 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name,
   GV->eraseFromParent();
 }
 GV = NewGV;
-CGM.getModule().getGlobalList().push_back(GV);
+CGM.getModule().insertGlobalVariable(GV);
   }
 
   assert(GV->getLinkage() == L);

diff  --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index 73a49e552e3d2..f3cf0f623d24f 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -406,7 +406,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, 
lldb::addr_t &func_addr,
 }
   };
 
-  for (llvm::GlobalVariable &global_var : m_module->getGlobalList()) {
+  for (llvm::GlobalVariable &global_var : m_module->globals()) {
 RegisterOneValue(global_var);
   }
 

diff  --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index 00d51a5a05b85..71298f4a87828 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -3429,17 +3429,14 @@ Important Public Members of the ``Module`` class
 
 * | ``Module::global_iterator`` - Typedef for global variable list iterator
   | ``Module::const_global_iterator`` - Typedef for const_iterator.
+  | ``Module::insertGlobalVariable()`` - Inserts a global variable to the list.
+  | ``Module::removeGlobalVariable()`` - Removes a global variable frome the 
list.
+  | ``Module::eraseGlobalVariable()`` - Removes a global variable frome the 
list and deletes it.
   | ``global_begin()``, ``global_end()``, ``global_size()``, ``global_empty()``
 
   These are forwarding methods that make it easy to access the contents of a
   ``Module`` object's GlobalVariable_ list.
 
-* ``Module::GlobalListType &getGlobalList()``
-
-  Returns the list of GlobalVariable_\ s.  This is necessary to use when you
-  need to update the list or perform a complex action that doesn't have a
-  forwarding method.
-
 
 
 * ``SymbolTable *getSymbolTable()``

diff  --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index dbd3eae0f134c..aacdbbf08b945 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -542,6 +542,24 @@ class LLVM_EXTERNAL_VISIBILITY Module {
 
   llvm::Error materializeMetadata();
 
+  /// Detach global variable \p GV from the list but don't delete it.
+  void removeGlobalVariable(GlobalVariable *GV) { GlobalList.remove(GV); }
+  /// Remove global variable \p GV from the list and delete it.
+  void eraseGlobalVariable(GlobalVariable *GV) { GlobalList.erase(GV); }
+  /// Insert global variable \p GV at the end of the global variable list and
+  /// take ownership.
+  void insertGlobalVariable(GlobalVariable *GV) {
+insertGlobalVariable(GlobalList.end(), GV);
+  }
+  /// Insert global variable \p GV into the global variable list before \p
+  /// Where and take ownership.
+  void insertGlobalVariable(GlobalListType::iterator Where, GlobalVariable 
*GV) {
+GlobalList.insert(Where

[clang] 06911ba - [NFC] Cleanup: Replaces BB->getInstList().insert() with I->insertAt().

2022-12-12 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2022-12-12T13:33:05-08:00
New Revision: 06911ba6ea1e552d3bcaed2728c92a9aa6cbf4d2

URL: 
https://github.com/llvm/llvm-project/commit/06911ba6ea1e552d3bcaed2728c92a9aa6cbf4d2
DIFF: 
https://github.com/llvm/llvm-project/commit/06911ba6ea1e552d3bcaed2728c92a9aa6cbf4d2.diff

LOG: [NFC] Cleanup: Replaces BB->getInstList().insert() with I->insertAt().

This is part of a series of cleanup patches towards making 
BasicBlock::getInstList() private.

Differential Revision: https://reviews.llvm.org/D138877

Added: 


Modified: 
clang/lib/CodeGen/CGCleanup.cpp
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
llvm/lib/Transforms/Utils/LowerSwitch.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
llvm/unittests/Analysis/MemorySSATest.cpp
llvm/unittests/Analysis/ValueTrackingTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index a1ba1a9a50d13..94e25ae8f4476 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -942,7 +942,7 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough) {
   // Append the prepared cleanup prologue from above.
   llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
   for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
-NormalExit->getInstList().push_back(InstsToAppend[I]);
+InstsToAppend[I]->insertAt(NormalExit, NormalExit->end());
 
   // Optimistically hope that any fixups will continue falling through.
   for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 592d608fea7bc..6da83e99130af 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -65,7 +65,8 @@ class IRBuilderDefaultInserter {
   virtual void InsertHelper(Instruction *I, const Twine &Name,
 BasicBlock *BB,
 BasicBlock::iterator InsertPt) const {
-if (BB) BB->getInstList().insert(InsertPt, I);
+if (BB)
+  I->insertAt(BB, InsertPt);
 I->setName(Name);
   }
 };

diff  --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h 
b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
index 54d221053e668..81b982a23da26 100644
--- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
+++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
@@ -397,7 +397,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
 assert(New && !New->getParent() &&
"New instruction already inserted into a basic block!");
 BasicBlock *BB = Old.getParent();
-BB->getInstList().insert(Old.getIterator(), New); // Insert inst
+New->insertAt(BB, Old.getIterator()); // Insert inst
 Worklist.push(New);
 return New;
   }

diff  --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h 
b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
index 3b2fe817c04cf..0464474c829ba 100644
--- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -121,8 +121,8 @@ void ReplaceInstWithValue(BasicBlock::InstListType &BIL,
 /// Copies DebugLoc from BI to I, if I doesn't already have a DebugLoc. The
 /// original instruction is deleted and BI is updated to point to the new
 /// instruction.
-void ReplaceInstWithInst(BasicBlock::InstListType &BIL,
- BasicBlock::iterator &BI, Instruction *I);
+void ReplaceInstWithInst(BasicBlock *BB, BasicBlock::iterator &BI,
+ Instruction *I);
 
 /// Replace the instruction specified by From with the instruction specified by
 /// To. Copie

[clang] a19ae77 - [IR][NFC] Adds Function::insertBasicBlockAt() to replace things like F->getBasicBlockList().insert()

2022-12-12 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2022-12-12T20:22:55-08:00
New Revision: a19ae77d2a9016428fee7cd5af03fd20ad6d4464

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

LOG: [IR][NFC] Adds Function::insertBasicBlockAt() to replace things like 
F->getBasicBlockList().insert()

This is part of a series of patches that aim at making 
Function::getBasicBlockList() private.

Differential Revision: https://reviews.llvm.org/D139906

Added: 


Modified: 
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp
llvm/examples/Kaleidoscope/Chapter5/toy.cpp
llvm/examples/Kaleidoscope/Chapter6/toy.cpp
llvm/examples/Kaleidoscope/Chapter7/toy.cpp
llvm/examples/Kaleidoscope/Chapter8/toy.cpp
llvm/examples/Kaleidoscope/Chapter9/toy.cpp
llvm/include/llvm/IR/Function.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/BasicBlock.cpp
llvm/lib/IR/Core.cpp
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/LoopUnroll.cpp
llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
llvm/lib/Transforms/Utils/LowerSwitch.cpp
llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
llvm/unittests/IR/FunctionTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index c27254d6d3d62..f3264cf87552f 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -574,9 +574,9 @@ void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool 
IsFinished) {
   // Place the block after the current block, if possible, or else at
   // the end of the function.
   if (CurBB && CurBB->getParent())
-CurFn->getBasicBlockList().insertAfter(CurBB->getIterator(), BB);
+CurFn->insertBasicBlockAt(std::next(CurBB->getIterator()), BB);
   else
-CurFn->getBasicBlockList().push_back(BB);
+CurFn->insertBasicBlockAt(CurFn->end(), BB);
   Builder.SetInsertPoint(BB);
 }
 
@@ -601,15 +601,15 @@ void CodeGenFunction::EmitBlockAfterUses(llvm::BasicBlock 
*block) {
   bool inserted = false;
   for (llvm::User *u : block->users()) {
 if (llvm::Instruction *insn = dyn_cast(u)) {
-  CurFn->getBasicBlockList().insertAfter(insn->getParent()->getIterator(),
- block);
+  CurFn->insertBasicBlockAt(std::next(insn->getParent()->getIterator()),
+block);
   inserted = true;
   break;
 }
   }
 
   if (!inserted)
-CurFn->getBasicBlockList().push_back(block);
+CurFn->insertBasicBlockAt(CurFn->end(), block);
 
   Builder.SetInsertPoint(block);
 }
@@ -1469,7 +1469,7 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S,
   llvm::BasicBlock *FalseDest = CaseRangeBlock;
   CaseRangeBlock = createBasicBlock("sw.caserange");
 
-  CurFn->getBasicBlockList().push_back(CaseRangeBlock);
+  CurFn->insertBasicBlockAt(CurFn->end(), CaseRangeBlock);
   Builder.SetInsertPoint(CaseRangeBlock);
 
   // Emit range check.

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index a84f12938bc0c..09dc638a2ac32 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -319,8 +319,10 @@ llvm::DebugLoc CodeGenFunction::EmitReturnBlock() {
 
 static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB) {
   if (!BB) return;
-  if (!BB->use_empty())
-return CGF.CurFn->getBasicBlockList().push_back(BB);
+  if (!BB->use_empty()) {
+CGF.CurFn->insertBasicBlockAt(CGF.CurFn->end(), BB);
+return;
+  }
   delete BB;
 }
 

diff  --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp 
b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
index 440d1b8dbd716..1f0036922b67d 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
@@ -863,7 +863,7 @@ Value *IfExprAST::codegen() {
   ThenBB = Builder->GetInsertBlock();
 
   // Emit else block.
-  TheFunction->getBasicBlockList().push_back(ElseBB);
+  TheFunction->insertBasicBlockAt(TheFunction->end(), ElseBB);
   Builder->SetInsertPoint(ElseBB);
 
   Value *ElseV = Else->codegen();
@@ -875,7 +875,7 @@ Value *IfExprAST::codegen() {
   ElseBB = Builder->GetInsertBlock();
 
   // Emit merge block.
-  TheFunction->getBasicBlockList().push_back(MergeBB);
+  TheFunction->insertBasicBlockAt(TheFunction->end(), MergeBB);
   Builder->SetInsertPoint(MergeBB);
 

[clang] adfb23c - [NFC] Cleanup: Remove Function::getBasicBlockList() when not required.

2022-12-13 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2022-12-13T11:46:29-08:00
New Revision: adfb23c607ce35f090cf3e29fba9d382b22c3a50

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

LOG: [NFC] Cleanup: Remove Function::getBasicBlockList() when not required.

This is part of a series of patches that aim at making 
Function::getBasicBlockList() private.

Differential Revision: https://reviews.llvm.org/D139910

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
llvm/lib/Target/AArch64/SMEABIPass.cpp
llvm/lib/Transforms/CFGuard/CFGuard.cpp
llvm/lib/Transforms/IPO/InlineSimple.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Utils/FunctionComparator.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/unittests/FuzzMutate/StrategiesTest.cpp
llvm/unittests/IR/InstructionsTest.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 85acebeeaec9b..354a3f901ff1e 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -128,7 +128,7 @@ static void resolveTopLevelMetadata(llvm::Function *Fn,
 
   // Find all llvm.dbg.declare intrinsics and resolve the DILocalVariable nodes
   // they are referencing.
-  for (auto &BB : Fn->getBasicBlockList()) {
+  for (auto &BB : *Fn) {
 for (auto &I : BB) {
   if (auto *DII = dyn_cast(&I)) {
 auto *DILocal = DII->getVariable();

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
index ec8f8d83c4b37..917242e9b287b 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -122,7 +122,7 @@ findRSCallSites(llvm::Module &module, 
std::set &rs_callsites,
   bool found = false;
 
   for (auto &func : module.getFunctionList())
-for (auto &block : func.getBasicBlockList())
+for (auto &block : func)
   for (auto &inst : block) {
 llvm::CallInst *call_inst =
 llvm::dyn_cast_or_null(&inst);

diff  --git a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp 
b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
index 0076267f933e7..42e2a24940127 100644
--- a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp
@@ -136,7 +136,7 @@ SequenceBBQuery::BlockListTy
 SequenceBBQuery::rearrangeBB(const Function &F, const BlockListTy &BBList) {
   BlockListTy RearrangedBBSet;
 
-  for (auto &Block : F.getBasicBlockList())
+  for (auto &Block : F)
 if (llvm::is_contained(BBList, &Block))
   RearrangedBBSet.push_back(&Block);
 

diff  --git a/llvm/lib/Target/AArch64/SMEABIPass.cpp 
b/llvm/lib/Target/AArch64/SMEABIPass.cpp
index a56f8e052d1c9..83010017c761f 100644
--- a/llvm/lib/Target/AArch64/SMEABIPass.cpp
+++ b/llvm/lib/Target/AArch64/SMEABIPass.cpp
@@ -113,7 +113,7 @@ bool SMEABI::updateNewZAFunctions(Module *M, Function *F,
   Builder.CreateCall(EnableZAIntr->getFunctionType(), EnableZAIntr);
 
   // Before returning, disable pstate.za
-  for (BasicBlock &BB : F->getBasicBlockList()) {
+  for (BasicBlock &BB : *F) {
 Instruction *T = BB.getTerminator();
 if (!T || !isa(T))
   continue;

diff  --git a/llvm/lib/Transforms/CFGuard/CFGuard.cpp 
b/llvm/lib/Transforms/CFGuard/CFGuard.cpp
index 55ef7c214fc84..bebaa6cb59699 100644
--- a/llvm/lib/Transforms/CFGuard/CFGuard.cpp
+++ b/llvm/lib/Transforms/CFGuard/CFGuard.cpp
@@ -272,7 +272,7 @@ bool CFGuard::runOnFunction(Function &F) {
   // instructions. Make a separate list of pointers to indirect
   // call/invoke/callbr instructions because the original instructions will be
   // deleted as the checks are added.
-  for (BasicBlock &BB : F.getBasicBlockList()) {
+  for (BasicBlock &BB : F) {
 for (Instruction &I : BB) {
   auto *CB = dyn_cast(&I);
   if (CB && CB->isIndirectCall() && !CB->hasFnAttr("guard_nocf")) {

diff  --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp 
b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index 2143e39d488dc..eba0d6636d6c0 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/lib/Transforms/IPO/InlineSimple.cpp
@@ -50,7 +50,7 @@ class SimpleInliner : public LegacyInlinerBase {
 TargetTransformInfo &TTI = TTIWP->getTTI(*Callee);
 
 bool RemarksEnabled = false;
-

[clang] 80f2f1e - [NFC] Rename Function::insertBasicBlockAt() to Function::insert().

2022-12-15 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2022-12-15T10:03:37-08:00
New Revision: 80f2f1eabc491cde39d543e4ebda93e2d2974d1f

URL: 
https://github.com/llvm/llvm-project/commit/80f2f1eabc491cde39d543e4ebda93e2d2974d1f
DIFF: 
https://github.com/llvm/llvm-project/commit/80f2f1eabc491cde39d543e4ebda93e2d2974d1f.diff

LOG: [NFC] Rename Function::insertBasicBlockAt() to Function::insert().

I think this is a better name because it is what STL uses.

Differential Revision: https://reviews.llvm.org/D140068

Added: 


Modified: 
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp
llvm/examples/Kaleidoscope/Chapter5/toy.cpp
llvm/examples/Kaleidoscope/Chapter6/toy.cpp
llvm/examples/Kaleidoscope/Chapter7/toy.cpp
llvm/examples/Kaleidoscope/Chapter8/toy.cpp
llvm/examples/Kaleidoscope/Chapter9/toy.cpp
llvm/include/llvm/IR/Function.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/BasicBlock.cpp
llvm/lib/IR/Core.cpp
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/LoopUnroll.cpp
llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
llvm/lib/Transforms/Utils/LowerSwitch.cpp
llvm/unittests/IR/FunctionTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index f3264cf87552f..f0e1d97b2676d 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -574,9 +574,9 @@ void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool 
IsFinished) {
   // Place the block after the current block, if possible, or else at
   // the end of the function.
   if (CurBB && CurBB->getParent())
-CurFn->insertBasicBlockAt(std::next(CurBB->getIterator()), BB);
+CurFn->insert(std::next(CurBB->getIterator()), BB);
   else
-CurFn->insertBasicBlockAt(CurFn->end(), BB);
+CurFn->insert(CurFn->end(), BB);
   Builder.SetInsertPoint(BB);
 }
 
@@ -601,15 +601,14 @@ void CodeGenFunction::EmitBlockAfterUses(llvm::BasicBlock 
*block) {
   bool inserted = false;
   for (llvm::User *u : block->users()) {
 if (llvm::Instruction *insn = dyn_cast(u)) {
-  CurFn->insertBasicBlockAt(std::next(insn->getParent()->getIterator()),
-block);
+  CurFn->insert(std::next(insn->getParent()->getIterator()), block);
   inserted = true;
   break;
 }
   }
 
   if (!inserted)
-CurFn->insertBasicBlockAt(CurFn->end(), block);
+CurFn->insert(CurFn->end(), block);
 
   Builder.SetInsertPoint(block);
 }
@@ -1469,7 +1468,7 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S,
   llvm::BasicBlock *FalseDest = CaseRangeBlock;
   CaseRangeBlock = createBasicBlock("sw.caserange");
 
-  CurFn->insertBasicBlockAt(CurFn->end(), CaseRangeBlock);
+  CurFn->insert(CurFn->end(), CaseRangeBlock);
   Builder.SetInsertPoint(CaseRangeBlock);
 
   // Emit range check.

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 09dc638a2ac32..ad5ffece8cae3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -320,7 +320,7 @@ llvm::DebugLoc CodeGenFunction::EmitReturnBlock() {
 static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB) {
   if (!BB) return;
   if (!BB->use_empty()) {
-CGF.CurFn->insertBasicBlockAt(CGF.CurFn->end(), BB);
+CGF.CurFn->insert(CGF.CurFn->end(), BB);
 return;
   }
   delete BB;

diff  --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp 
b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
index 1f0036922b67d..e29de191515ae 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp
@@ -863,7 +863,7 @@ Value *IfExprAST::codegen() {
   ThenBB = Builder->GetInsertBlock();
 
   // Emit else block.
-  TheFunction->insertBasicBlockAt(TheFunction->end(), ElseBB);
+  TheFunction->insert(TheFunction->end(), ElseBB);
   Builder->SetInsertPoint(ElseBB);
 
   Value *ElseV = Else->codegen();
@@ -875,7 +875,7 @@ Value *IfExprAST::codegen() {
   ElseBB = Builder->GetInsertBlock();
 
   // Emit merge block.
-  TheFunction->insertBasicBlockAt(TheFunction->end(), MergeBB);
+  TheFunction->insert(TheFunction->end(), MergeBB);
   Builder->SetInsertPoint(MergeBB);
   PHINode *PN = Builder->CreatePHI(Type::getDoubleTy(*TheContext), 2, "iftmp");
 

diff  --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp 
b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp
index 1f0036922b67d..e29de191515ae 100644
--- a/llvm/examples/Kaleidosco

[clang] 32b38d2 - [NFC] Rename Instruction::insertAt() to Instruction::insertInto(), to be consistent with BasicBlock::insertInto()

2022-12-15 Thread Vasileios Porpodas via cfe-commits

Author: Vasileios Porpodas
Date: 2022-12-15T12:27:45-08:00
New Revision: 32b38d248fd3c75abc5c86ab6677b6cb08a703cc

URL: 
https://github.com/llvm/llvm-project/commit/32b38d248fd3c75abc5c86ab6677b6cb08a703cc
DIFF: 
https://github.com/llvm/llvm-project/commit/32b38d248fd3c75abc5c86ab6677b6cb08a703cc.diff

LOG: [NFC] Rename Instruction::insertAt() to Instruction::insertInto(), to be 
consistent with BasicBlock::insertInto()

Differential Revision: https://reviews.llvm.org/D140085

Added: 


Modified: 
clang/lib/CodeGen/CGCleanup.cpp
llvm/docs/ProgrammersManual.rst
llvm/examples/BrainF/BrainF.cpp
llvm/examples/ModuleMaker/ModuleMaker.cpp
llvm/include/llvm/IR/BasicBlock.h
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/lib/IR/Instruction.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
llvm/lib/Transforms/Scalar/JumpThreading.cpp
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
llvm/lib/Transforms/Scalar/TLSVariableHoist.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
llvm/lib/Transforms/Utils/LowerSwitch.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
llvm/unittests/Analysis/MemorySSATest.cpp
llvm/unittests/Analysis/ValueTrackingTest.cpp
llvm/unittests/IR/InstructionsTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 94e25ae8f4476..43758ac27e439 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -942,7 +942,7 @@ void CodeGenFunction::PopCleanupBlock(bool 
FallthroughIsBranchThrough) {
   // Append the prepared cleanup prologue from above.
   llvm::BasicBlock *NormalExit = Builder.GetInsertBlock();
   for (unsigned I = 0, E = InstsToAppend.size(); I != E; ++I)
-InstsToAppend[I]->insertAt(NormalExit, NormalExit->end());
+InstsToAppend[I]->insertInto(NormalExit, NormalExit->end());
 
   // Optimistically hope that any fixups will continue falling through.
   for (unsigned I = FixupDepth, E = EHStack.getNumBranchFixups();

diff  --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index 242b87e3dbe32..868e6851944b1 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -2861,7 +2861,7 @@ sequence of instructions that form a ``BasicBlock``:
 BasicBlock *pb = ...;
 auto *newInst = new Instruction(...);
 
-newInst->insertAt(pb, pb->end()); // Appends newInst to pb
+newInst->insertInto(pb, pb->end()); // Appends newInst to pb
 
   becomes:
 

diff  --git a/llvm/examples/BrainF/BrainF.cpp b/llvm/examples/BrainF/BrainF.cpp
index 5d0cbd8d8f87e..b3ff5574d3fc7 100644
--- a/llvm/examples/BrainF/BrainF.cpp
+++ b/llvm/examples/BrainF/BrainF.cpp
@@ -96,7 +96,7 @@ void BrainF::header(LLVMContext& C) {
   allocsize = ConstantExpr::getTruncOrBitCast(allocsize, IntPtrTy);
   ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, Int8Ty, allocsize, val_mem, 
nullptr, "arr");
-  cast(ptr_arr)->insertAt(BB, BB->end());
+  cast(ptr_arr)->insertInto(BB, BB->end());
 
   //call void @llvm.memset.p0i8.i32(i8 *%arr, i8 0, i32 %d, i1 0)
   {
@@ -128,7 +128,7 @@ void BrainF::header(LLVMContext& C) {
   endbb = BasicBlock::Create(C, label, brainf_func);
 
   //call free(i8 *%arr)
-  CallInst::CreateFree(ptr_arr, endbb)->insertAt(endbb, endbb->end());
+  CallInst::CreateFree(ptr_arr, endbb)->insertInto(endbb, endbb->end());
 
   //ret void
   ReturnInst::Create(C, endbb);

diff  --git a/llvm/examples/ModuleMaker/ModuleMaker.cpp 
b/llvm/examples/ModuleMaker/ModuleMaker.cpp
index 033f91d0830f2..a43b344a79335 100644
--- a/llvm/examples/ModuleMaker/ModuleMaker.cpp
+++ b/llvm/examples/ModuleMaker/ModuleMaker.cpp
@@ -55,10 +55,10 @@ int main() {
 "addresult");
 
   // explicitly insert it into the basic block...
-  Add->insertAt(BB,