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

2022-12-13 Thread Vasileios Porpodas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGadfb23c607ce: [NFC] Cleanup: Remove 
Function::getBasicBlockList() when not required. (authored by vporpo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139910/new/

https://reviews.llvm.org/D139910

Files:
  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

Index: mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
===
--- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -321,8 +321,7 @@
   blocks.insert(traversal.begin(), traversal.end());
 }
   }
-  assert(blocks.size() == func->getBasicBlockList().size() &&
- "some blocks are not sorted");
+  assert(blocks.size() == func->size() && "some blocks are not sorted");
 
   return blocks;
 }
Index: llvm/unittests/IR/InstructionsTest.cpp
===
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -1516,7 +1516,7 @@
 }
 )");
   Function *Foo = M->getFunction("foo");
-  auto BBs = Foo->getBasicBlockList().begin();
+  auto BBs = Foo->begin();
   CallBrInst  = cast(BBs->front());
   ++BBs;
   ++BBs;
Index: llvm/unittests/FuzzMutate/StrategiesTest.cpp
===
--- llvm/unittests/FuzzMutate/StrategiesTest.cpp
+++ llvm/unittests/FuzzMutate/StrategiesTest.cpp
@@ -505,14 +505,14 @@
   std::unique_ptr M = parseAssembly(Source.data(), Ctx);
   Function *F = &*M->begin();
   DenseMap PreShuffleInstCnt;
-  for (BasicBlock  : F->getBasicBlockList()) {
+  for (BasicBlock  : *F) {
 PreShuffleInstCnt.insert({, BB.size()});
   }
   std::mt19937 mt(Seed);
   std::uniform_int_distribution RandInt(INT_MIN, INT_MAX);
   for (int i = 0; i < 100; i++) {
 Mutator->mutateModule(*M, RandInt(mt), Source.size(), Source.size() + 1024);
-for (BasicBlock  : F->getBasicBlockList()) {
+for (BasicBlock  : *F) {
   int PostShuffleIntCnt = BB.size();
   EXPECT_EQ(PostShuffleIntCnt, PreShuffleInstCnt[]);
 }
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2758,7 +2758,7 @@
 OrigBB->splice(CB.getIterator(), &*FirstNewBlock, FirstNewBlock->begin(),
FirstNewBlock->end());
 // Remove the cloned basic block.
-Caller->getBasicBlockList().pop_back();
+Caller->back().eraseFromParent();
 
 // If the call site was an invoke instruction, add a branch to the normal
 // destination.
@@ -2932,7 +2932,7 @@
   Br->eraseFromParent();
 
   // Now we can remove the CalleeEntry block, which is now empty.
-  Caller->getBasicBlockList().erase(CalleeEntry);
+  CalleeEntry->eraseFromParent();
 
   // If we inserted a phi node, check to see if it has a single value (e.g. all
   // the entries are the same or undef).  If so, remove the PHI so it doesn't
Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -381,7 +381,7 @@
   BasicBlock *RBB = RBA->getBasicBlock();
   if (LBB == RBB)
 return 0;
-  for (BasicBlock  : F->getBasicBlockList()) {
+  for (BasicBlock  : *F) {
 if ( == LBB) {
   assert( != RBB);
   return -1;
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1692,7 +1692,7 @@
   IRB.CreateCall(AsanPoisonGlobals, ModuleNameAddr);
 
   // Add calls to unpoison all globals before each return instruction.
-  for (auto  : GlobalInit.getBasicBlockList())
+  for (auto  : GlobalInit)
 if (ReturnInst *RI = dyn_cast(BB.getTerminator()))
   CallInst::Create(AsanUnpoisonGlobals, "", RI);
 }
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp

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

2022-12-12 Thread Vasileios Porpodas via Phabricator via cfe-commits
vporpo created this revision.
vporpo added reviewers: aeubanks, asbirlea.
Herald added subscribers: Moerafaat, zero9178, Enna1, bzcheeseman, mattd, 
awarzynski, sdasgup3, wenzhicui, wrengr, ormris, cota, teijeong, rdzhabarov, 
tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, 
mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, hiraditya.
Herald added a reviewer: ftynse.
Herald added a project: All.
vporpo requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, 
stephenneuendorffer, nicolasvasilache.
Herald added a reviewer: dcaballe.
Herald added projects: clang, LLDB, MLIR, LLVM.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139910

Files:
  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

Index: mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
===
--- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -321,8 +321,7 @@
   blocks.insert(traversal.begin(), traversal.end());
 }
   }
-  assert(blocks.size() == func->getBasicBlockList().size() &&
- "some blocks are not sorted");
+  assert(blocks.size() == func->size() && "some blocks are not sorted");
 
   return blocks;
 }
Index: llvm/unittests/IR/InstructionsTest.cpp
===
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -1516,7 +1516,7 @@
 }
 )");
   Function *Foo = M->getFunction("foo");
-  auto BBs = Foo->getBasicBlockList().begin();
+  auto BBs = Foo->begin();
   CallBrInst  = cast(BBs->front());
   ++BBs;
   ++BBs;
Index: llvm/unittests/FuzzMutate/StrategiesTest.cpp
===
--- llvm/unittests/FuzzMutate/StrategiesTest.cpp
+++ llvm/unittests/FuzzMutate/StrategiesTest.cpp
@@ -505,14 +505,14 @@
   std::unique_ptr M = parseAssembly(Source.data(), Ctx);
   Function *F = &*M->begin();
   DenseMap PreShuffleInstCnt;
-  for (BasicBlock  : F->getBasicBlockList()) {
+  for (BasicBlock  : *F) {
 PreShuffleInstCnt.insert({, BB.size()});
   }
   std::mt19937 mt(Seed);
   std::uniform_int_distribution RandInt(INT_MIN, INT_MAX);
   for (int i = 0; i < 100; i++) {
 Mutator->mutateModule(*M, RandInt(mt), Source.size(), Source.size() + 1024);
-for (BasicBlock  : F->getBasicBlockList()) {
+for (BasicBlock  : *F) {
   int PostShuffleIntCnt = BB.size();
   EXPECT_EQ(PostShuffleIntCnt, PreShuffleInstCnt[]);
 }
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2758,7 +2758,7 @@
 OrigBB->splice(CB.getIterator(), &*FirstNewBlock, FirstNewBlock->begin(),
FirstNewBlock->end());
 // Remove the cloned basic block.
-Caller->getBasicBlockList().pop_back();
+Caller->back().eraseFromParent();
 
 // If the call site was an invoke instruction, add a branch to the normal
 // destination.
@@ -2932,7 +2932,7 @@
   Br->eraseFromParent();
 
   // Now we can remove the CalleeEntry block, which is now empty.
-  Caller->getBasicBlockList().erase(CalleeEntry);
+  CalleeEntry->eraseFromParent();
 
   // If we inserted a phi node, check to see if it has a single value (e.g. all
   // the entries are the same or undef).  If so, remove the PHI so it doesn't
Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -381,7 +381,7 @@
   BasicBlock *RBB = RBA->getBasicBlock();
   if (LBB == RBB)
 return 0;
-  for (BasicBlock  : F->getBasicBlockList()) {
+  for (BasicBlock  : *F) {
 if ( == LBB) {
   assert( != RBB);
   return -1;
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++