[Mlir-commits] [mlir] adfb23c - [NFC] Cleanup: Remove Function::getBasicBlockList() when not required.
Vasileios Porpodas
llvmlistbot at llvm.org
Tue Dec 13 11:47:07 PST 2022
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<llvm::DbgVariableIntrinsic>(&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<llvm::CallInst *> &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<llvm::CallInst>(&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<ReturnInst>(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<CallBase>(&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;
- const auto &BBs = CB.getCaller()->getBasicBlockList();
+ const auto &BBs = *CB.getCaller();
if (!BBs.empty()) {
auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &BBs.front());
if (DI.isEnabled())
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 9b7af3b077b28..775982c0812c7 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1836,10 +1836,9 @@ void DevirtModule::rebuildGlobal(VTableBits &B) {
bool DevirtModule::areRemarksEnabled() {
const auto &FL = M.getFunctionList();
for (const Function &Fn : FL) {
- const auto &BBL = Fn.getBasicBlockList();
- if (BBL.empty())
+ if (Fn.empty())
continue;
- auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &BBL.front());
+ auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &Fn.front());
return DI.isEnabled();
}
return false;
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 7f5826bb8a2b2..c5f05b0b9dea7 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1692,7 +1692,7 @@ void ModuleAddressSanitizer::poisonOneInitializer(Function &GlobalInit,
IRB.CreateCall(AsanPoisonGlobals, ModuleNameAddr);
// Add calls to unpoison all globals before each return instruction.
- for (auto &BB : GlobalInit.getBasicBlockList())
+ for (auto &BB : GlobalInit)
if (ReturnInst *RI = dyn_cast<ReturnInst>(BB.getTerminator()))
CallInst::Create(AsanUnpoisonGlobals, "", RI);
}
diff --git a/llvm/lib/Transforms/Utils/FunctionComparator.cpp b/llvm/lib/Transforms/Utils/FunctionComparator.cpp
index b38e9c5731814..53bac207251eb 100644
--- a/llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -381,7 +381,7 @@ int FunctionComparator::cmpConstants(const Constant *L,
BasicBlock *RBB = RBA->getBasicBlock();
if (LBB == RBB)
return 0;
- for (BasicBlock &BB : F->getBasicBlockList()) {
+ for (BasicBlock &BB : *F) {
if (&BB == LBB) {
assert(&BB != RBB);
return -1;
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 411ccc2c9b823..dfbcac71859ac 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2758,7 +2758,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
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 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
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
diff --git a/llvm/unittests/FuzzMutate/StrategiesTest.cpp b/llvm/unittests/FuzzMutate/StrategiesTest.cpp
index 9208a9b45fb1c..688280f70f22b 100644
--- a/llvm/unittests/FuzzMutate/StrategiesTest.cpp
+++ b/llvm/unittests/FuzzMutate/StrategiesTest.cpp
@@ -505,14 +505,14 @@ static void VerifyBlockShuffle(StringRef Source) {
std::unique_ptr<Module> M = parseAssembly(Source.data(), Ctx);
Function *F = &*M->begin();
DenseMap<BasicBlock *, int> PreShuffleInstCnt;
- for (BasicBlock &BB : F->getBasicBlockList()) {
+ for (BasicBlock &BB : *F) {
PreShuffleInstCnt.insert({&BB, BB.size()});
}
std::mt19937 mt(Seed);
std::uniform_int_distribution<int> RandInt(INT_MIN, INT_MAX);
for (int i = 0; i < 100; i++) {
Mutator->mutateModule(*M, RandInt(mt), Source.size(), Source.size() + 1024);
- for (BasicBlock &BB : F->getBasicBlockList()) {
+ for (BasicBlock &BB : *F) {
int PostShuffleIntCnt = BB.size();
EXPECT_EQ(PostShuffleIntCnt, PreShuffleInstCnt[&BB]);
}
diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp
index cd9fb0385bc29..4718aa854f1e1 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -1516,7 +1516,7 @@ if.end:
}
)");
Function *Foo = M->getFunction("foo");
- auto BBs = Foo->getBasicBlockList().begin();
+ auto BBs = Foo->begin();
CallBrInst &CBI = cast<CallBrInst>(BBs->front());
++BBs;
++BBs;
diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 55fe88f25a7d5..c8f9dab94ef9f 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -321,8 +321,7 @@ getTopologicallySortedBlocks(llvm::Function *func) {
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;
}
More information about the Mlir-commits
mailing list