[llvm] 9606608 - [llvm] Use x.empty() instead of llvm::empty(x) (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 12 13:34:45 PDT 2022
Author: Kazu Hirata
Date: 2022-09-12T13:34:35-07:00
New Revision: 9606608474873da64a870ff40ef042869051feb3
URL: https://github.com/llvm/llvm-project/commit/9606608474873da64a870ff40ef042869051feb3
DIFF: https://github.com/llvm/llvm-project/commit/9606608474873da64a870ff40ef042869051feb3.diff
LOG: [llvm] Use x.empty() instead of llvm::empty(x) (NFC)
I'm planning to deprecate and eventually remove llvm::empty.
I thought about replacing llvm::empty(x) with std::empty(x), but it
turns out that all uses can be converted to x.empty(). That is, no
use requires the ability of std::empty to accept C arrays and
std::initializer_list.
Differential Revision: https://reviews.llvm.org/D133677
Added:
Modified:
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
llvm/lib/ExecutionEngine/Orc/Layer.cpp
llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/lib/Target/X86/X86FastISel.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index 7ea10510d7a73..3b759f18c5d40 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -774,7 +774,7 @@ class SectionRange {
public:
SectionRange() = default;
SectionRange(const Section &Sec) {
- if (llvm::empty(Sec.blocks()))
+ if (Sec.blocks().empty())
return;
First = Last = *Sec.blocks().begin();
for (auto *B : Sec.blocks()) {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
index a497aa07284e7..3fe437a07c920 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -42,7 +42,7 @@ void DwarfFile::emitUnit(DwarfUnit *TheU, bool UseOffsets) {
// Skip CUs that ended up not being needed (split CUs that were abandoned
// because they added no information beyond the non-split CU)
- if (llvm::empty(TheU->getUnitDie().values()))
+ if (TheU->getUnitDie().values().empty())
return;
Asm->OutStreamer->switchSection(S);
@@ -66,7 +66,7 @@ void DwarfFile::computeSizeAndOffsets() {
// Skip CUs that ended up not being needed (split CUs that were abandoned
// because they added no information beyond the non-split CU)
- if (llvm::empty(TheU->getUnitDie().values()))
+ if (TheU->getUnitDie().values().empty())
return;
TheU->setDebugSectionOffset(SecOffset);
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
index 08fdc7c9e6b10..24cc91b065c56 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
@@ -309,14 +309,14 @@ void LinkGraph::dump(raw_ostream &OS) {
}
OS << "Absolute symbols:\n";
- if (!llvm::empty(absolute_symbols())) {
+ if (!absolute_symbols().empty()) {
for (auto *Sym : absolute_symbols())
OS << " " << Sym->getAddress() << ": " << *Sym << "\n";
} else
OS << " none\n";
OS << "\nExternal symbols:\n";
- if (!llvm::empty(external_symbols())) {
+ if (!external_symbols().empty()) {
for (auto *Sym : external_symbols())
OS << " " << Sym->getAddress() << ": " << *Sym << "\n";
} else
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
index acb759d6ce793..6bf2381fd571d 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
@@ -25,7 +25,7 @@ BasicLayout::BasicLayout(LinkGraph &G) : G(G) {
for (auto &Sec : G.sections()) {
// Skip empty sections.
- if (empty(Sec.blocks()))
+ if (Sec.blocks().empty())
continue;
auto &Seg = Segments[{Sec.getMemProt(), Sec.getMemDeallocPolicy()}];
diff --git a/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
index 3c44fe81b4a99..009e2d7fd5f93 100644
--- a/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
@@ -137,7 +137,7 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
SmallVector<DebugSectionInfo, 12> DebugSecInfos;
size_t NumSections = 0;
for (auto &Sec : G.sections()) {
- if (llvm::empty(Sec.blocks()))
+ if (Sec.blocks().empty())
continue;
++NumSections;
@@ -189,7 +189,7 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
// Copy debug section blocks and symbols.
orc::ExecutorAddr NextBlockAddr(MachOContainerBlock->getSize());
for (auto &SI : DebugSecInfos) {
- assert(!llvm::empty(SI.Sec->blocks()) && "Empty debug info section?");
+ assert(!SI.Sec->blocks().empty() && "Empty debug info section?");
// Update addresses in debug section.
LLVM_DEBUG({
diff --git a/llvm/lib/ExecutionEngine/Orc/Layer.cpp b/llvm/lib/ExecutionEngine/Orc/Layer.cpp
index 4a50f2d7a1538..b0acab0137bc5 100644
--- a/llvm/lib/ExecutionEngine/Orc/Layer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Layer.cpp
@@ -81,7 +81,7 @@ IRMaterializationUnit::IRMaterializationUnit(
}
// If we need an init symbol for this module then create one.
- if (!llvm::empty(getStaticInitGVs(M))) {
+ if (!getStaticInitGVs(M).empty()) {
size_t Counter = 0;
do {
diff --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
index b9c064dd4b34a..8338d42f92a0b 100644
--- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
@@ -744,7 +744,7 @@ Error MachOPlatform::MachOPlatformPlugin::processObjCImageInfo(
auto ObjCImageInfoBlocks = ObjCImageInfo->blocks();
// Check that the section is not empty if present.
- if (llvm::empty(ObjCImageInfoBlocks))
+ if (ObjCImageInfoBlocks.empty())
return make_error<StringError>("Empty " + ObjCImageInfoSectionName +
" section in " + G.getName(),
inconvertibleErrorCode());
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index ba94c597d33dc..ca78c4a64d44b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -2539,7 +2539,7 @@ void AMDGPURegisterBankInfo::applyMappingImpl(
LLT SrcTy = MRI.getType(SrcReg);
const bool Signed = Opc == AMDGPU::G_SEXT;
- assert(empty(OpdMapper.getVRegs(1)));
+ assert(OpdMapper.getVRegs(1).empty());
MachineIRBuilder B(MI);
const RegisterBank *SrcBank =
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index ba3674e2deb90..6597e316cd9a6 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -274,9 +274,7 @@ bool X86FastISel::foldX86XALUIntrinsic(X86::CondCode &CC, const Instruction *I,
// Make sure no potentially eflags clobbering phi moves can be inserted in
// between.
- auto HasPhis = [](const BasicBlock *Succ) {
- return !llvm::empty(Succ->phis());
- };
+ auto HasPhis = [](const BasicBlock *Succ) { return !Succ->phis().empty(); };
if (I->isTerminator() && llvm::any_of(successors(I), HasPhis))
return false;
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 1287c3aa0a9e0..09e1d0829fbf3 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1843,7 +1843,7 @@ Optional<IVConditionInfo> llvm::hasPartialIVCondition(Loop &L,
if (L.contains(Succ))
continue;
- Info.PathIsNoop &= llvm::empty(Succ->phis()) &&
+ Info.PathIsNoop &= Succ->phis().empty() &&
(!Info.ExitForPath || Info.ExitForPath == Succ);
if (!Info.PathIsNoop)
break;
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
index 06d555aa80741..415aee76b1863 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-coff.cpp
@@ -80,13 +80,12 @@ Error registerCOFFGraphInfo(Session &S, LinkGraph &G) {
for (auto &Sec : G.sections()) {
LLVM_DEBUG({
dbgs() << " Section \"" << Sec.getName() << "\": "
- << (llvm::empty(Sec.symbols()) ? "empty. skipping."
- : "processing...")
+ << (Sec.symbols().empty() ? "empty. skipping." : "processing...")
<< "\n";
});
// Skip empty sections.
- if (llvm::empty(Sec.symbols()))
+ if (Sec.symbols().empty())
continue;
if (FileInfo.SectionInfos.count(Sec.getName()))
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
index b810646c28c8d..2b798f95edb25 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-elf.cpp
@@ -82,13 +82,12 @@ Error registerELFGraphInfo(Session &S, LinkGraph &G) {
for (auto &Sec : G.sections()) {
LLVM_DEBUG({
dbgs() << " Section \"" << Sec.getName() << "\": "
- << (llvm::empty(Sec.symbols()) ? "empty. skipping."
- : "processing...")
+ << (Sec.symbols().empty() ? "empty. skipping." : "processing...")
<< "\n";
});
// Skip empty sections.
- if (llvm::empty(Sec.symbols()))
+ if (Sec.symbols().empty())
continue;
if (FileInfo.SectionInfos.count(Sec.getName()))
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
index bb43e3a476466..bcb2f251ece1c 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink-macho.cpp
@@ -84,13 +84,12 @@ Error registerMachOGraphInfo(Session &S, LinkGraph &G) {
for (auto &Sec : G.sections()) {
LLVM_DEBUG({
dbgs() << " Section \"" << Sec.getName() << "\": "
- << (llvm::empty(Sec.symbols()) ? "empty. skipping."
- : "processing...")
+ << (Sec.symbols().empty() ? "empty. skipping." : "processing...")
<< "\n";
});
// Skip empty sections.
- if (llvm::empty(Sec.symbols()))
+ if (Sec.symbols().empty())
continue;
if (FileInfo.SectionInfos.count(Sec.getName()))
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 13503bbc1b3cc..eb2e19ecbcee0 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -403,11 +403,11 @@ static void dumpSectionContents(raw_ostream &OS, LinkGraph &G) {
Sections.push_back(&S);
llvm::sort(Sections, [](const Section *LHS, const Section *RHS) {
- if (llvm::empty(LHS->symbols()) && llvm::empty(RHS->symbols()))
+ if (LHS->symbols().empty() && RHS->symbols().empty())
return false;
- if (llvm::empty(LHS->symbols()))
+ if (LHS->symbols().empty())
return false;
- if (llvm::empty(RHS->symbols()))
+ if (RHS->symbols().empty())
return true;
SectionRange LHSRange(*LHS);
SectionRange RHSRange(*RHS);
@@ -416,7 +416,7 @@ static void dumpSectionContents(raw_ostream &OS, LinkGraph &G) {
for (auto *S : Sections) {
OS << S->getName() << " content:";
- if (llvm::empty(S->symbols())) {
+ if (S->symbols().empty()) {
OS << "\n section empty\n";
continue;
}
More information about the llvm-commits
mailing list