[llvm] r373935 - Second attempt to add iterator_range::empty()
Jordan Rose via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 11:14:24 PDT 2019
Author: jrose
Date: Mon Oct 7 11:14:24 2019
New Revision: 373935
URL: http://llvm.org/viewvc/llvm-project?rev=373935&view=rev
Log:
Second attempt to add iterator_range::empty()
Doing this makes MSVC complain that `empty(someRange)` could refer to
either C++17's std::empty or LLVM's llvm::empty, which previously we
avoided via SFINAE because std::empty is defined in terms of an empty
member rather than begin and end. So, switch callers over to the new
method as it is added.
https://reviews.llvm.org/D68439
Modified:
llvm/trunk/include/llvm/ADT/iterator_range.h
llvm/trunk/lib/Analysis/LazyCallGraph.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp
llvm/trunk/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp
llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
llvm/trunk/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/trunk/lib/Target/BPF/BPFAbstractMemberAccess.cpp
llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp
llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/include/llvm/ADT/iterator_range.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/iterator_range.h?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/iterator_range.h (original)
+++ llvm/trunk/include/llvm/ADT/iterator_range.h Mon Oct 7 11:14:24 2019
@@ -44,6 +44,7 @@ public:
IteratorT begin() const { return begin_iterator; }
IteratorT end() const { return end_iterator; }
+ bool empty() const { return begin_iterator == end_iterator; }
};
/// Convenience function for iterating over sub-ranges.
Modified: llvm/trunk/lib/Analysis/LazyCallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyCallGraph.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyCallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyCallGraph.cpp Mon Oct 7 11:14:24 2019
@@ -632,7 +632,7 @@ LazyCallGraph::RefSCC::switchInternalEdg
// If the merge range is empty, then adding the edge didn't actually form any
// new cycles. We're done.
- if (empty(MergeRange)) {
+ if (MergeRange.empty()) {
// Now that the SCC structure is finalized, flip the kind to call.
SourceN->setEdgeKind(TargetN, Edge::Call);
return false; // No new cycle.
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Oct 7 11:14:24 2019
@@ -1054,7 +1054,7 @@ void DwarfDebug::finalizeModuleInfo() {
// If we're splitting the dwarf out now that we've got the entire
// CU then add the dwo id to it.
auto *SkCU = TheCU.getSkeleton();
- if (useSplitDwarf() && !empty(TheCU.getUnitDie().children())) {
+ if (useSplitDwarf() && !TheCU.getUnitDie().children().empty()) {
finishUnitAttributes(TheCU.getCUNode(), TheCU);
TheCU.addString(TheCU.getUnitDie(), dwarf::DW_AT_GNU_dwo_name,
Asm->TM.Options.MCOptions.SplitDwarfFile);
@@ -1106,7 +1106,7 @@ void DwarfDebug::finalizeModuleInfo() {
// is a bit pessimistic under LTO.
if (!AddrPool.isEmpty() &&
(getDwarfVersion() >= 5 ||
- (SkCU && !empty(TheCU.getUnitDie().children()))))
+ (SkCU && !TheCU.getUnitDie().children().empty())))
U.addAddrTableBase();
if (getDwarfVersion() >= 5) {
Modified: llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp Mon Oct 7 11:14:24 2019
@@ -79,5 +79,5 @@ bool InstructionSelector::isObviouslySaf
return true;
return !MI.mayLoadOrStore() && !MI.mayRaiseFPException() &&
- !MI.hasUnmodeledSideEffects() && empty(MI.implicit_operands());
+ !MI.hasUnmodeledSideEffects() && MI.implicit_operands().empty();
}
Modified: llvm/trunk/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/LegalizerInfo.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/LegalizerInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/LegalizerInfo.cpp Mon Oct 7 11:14:24 2019
@@ -433,7 +433,7 @@ LegalizeRuleSet &LegalizerInfo::getActio
std::initializer_list<unsigned> Opcodes) {
unsigned Representative = *Opcodes.begin();
- assert(!empty(Opcodes) && Opcodes.begin() + 1 != Opcodes.end() &&
+ assert(!llvm::empty(Opcodes) && Opcodes.begin() + 1 != Opcodes.end() &&
"Initializer list must have at least two opcodes");
for (auto I = Opcodes.begin() + 1, E = Opcodes.end(); I != E; ++I)
Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp Mon Oct 7 11:14:24 2019
@@ -139,7 +139,7 @@ bool RegBankSelect::repairReg(
"need new vreg for each breakdown");
// An empty range of new register means no repairing.
- assert(!empty(NewVRegs) && "We should not have to repair");
+ assert(!NewVRegs.empty() && "We should not have to repair");
MachineInstr *MI;
if (ValMapping.NumBreakDowns == 1) {
Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp Mon Oct 7 11:14:24 2019
@@ -455,7 +455,7 @@ void RegisterBankInfo::applyDefaultMappi
"This mapping is too complex for this function");
iterator_range<SmallVectorImpl<Register>::const_iterator> NewRegs =
OpdMapper.getVRegs(OpIdx);
- if (empty(NewRegs)) {
+ if (NewRegs.empty()) {
LLVM_DEBUG(dbgs() << " has not been repaired, nothing to be done\n");
continue;
}
Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Mon Oct 7 11:14:24 2019
@@ -346,7 +346,7 @@ char MachineModuleInfoWrapperPass::ID =
bool MachineModuleInfoWrapperPass::doInitialization(Module &M) {
MMI.initialize();
MMI.TheModule = &M;
- MMI.DbgInfoAvailable = !empty(M.debug_compile_units());
+ MMI.DbgInfoAvailable = !M.debug_compile_units().empty();
return false;
}
@@ -361,6 +361,6 @@ MachineModuleInfo MachineModuleAnalysis:
ModuleAnalysisManager &) {
MachineModuleInfo MMI(TM);
MMI.TheModule = &M;
- MMI.DbgInfoAvailable = !empty(M.debug_compile_units());
+ MMI.DbgInfoAvailable = !M.debug_compile_units().empty();
return MMI;
}
Modified: llvm/trunk/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/ExecutionUtils.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/ExecutionUtils.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/ExecutionUtils.cpp Mon Oct 7 11:14:24 2019
@@ -88,7 +88,7 @@ iterator_range<CtorDtorIterator> getDest
}
void CtorDtorRunner::add(iterator_range<CtorDtorIterator> CtorDtors) {
- if (empty(CtorDtors))
+ if (CtorDtors.empty())
return;
MangleAndInterner Mangle(
Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Oct 7 11:14:24 2019
@@ -279,7 +279,7 @@ bool DebugInfoFinder::addScope(DIScope *
}
static MDNode *stripDebugLocFromLoopID(MDNode *N) {
- assert(!empty(N->operands()) && "Missing self reference?");
+ assert(!N->operands().empty() && "Missing self reference?");
// if there is no debug location, we do not have to rewrite this MDNode.
if (std::none_of(N->op_begin() + 1, N->op_end(), [](const MDOperand &Op) {
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp Mon Oct 7 11:14:24 2019
@@ -1588,7 +1588,7 @@ void AMDGPURegisterBankInfo::applyMappin
if (DstTy != LLT::vector(2, 16))
break;
- assert(MI.getNumOperands() == 3 && empty(OpdMapper.getVRegs(0)));
+ assert(MI.getNumOperands() == 3 && OpdMapper.getVRegs(0).empty());
substituteSimpleCopyRegs(OpdMapper, 1);
substituteSimpleCopyRegs(OpdMapper, 2);
@@ -1644,7 +1644,7 @@ void AMDGPURegisterBankInfo::applyMappin
case AMDGPU::G_EXTRACT_VECTOR_ELT: {
SmallVector<Register, 2> DstRegs(OpdMapper.getVRegs(0));
- assert(empty(OpdMapper.getVRegs(1)) && empty(OpdMapper.getVRegs(2)));
+ assert(OpdMapper.getVRegs(1).empty() && OpdMapper.getVRegs(2).empty());
if (DstRegs.empty()) {
applyDefaultMapping(OpdMapper);
@@ -1708,9 +1708,9 @@ void AMDGPURegisterBankInfo::applyMappin
case AMDGPU::G_INSERT_VECTOR_ELT: {
SmallVector<Register, 2> InsRegs(OpdMapper.getVRegs(2));
- assert(empty(OpdMapper.getVRegs(0)));
- assert(empty(OpdMapper.getVRegs(1)));
- assert(empty(OpdMapper.getVRegs(3)));
+ assert(OpdMapper.getVRegs(0).empty());
+ assert(OpdMapper.getVRegs(1).empty());
+ assert(OpdMapper.getVRegs(3).empty());
if (InsRegs.empty()) {
applyDefaultMapping(OpdMapper);
@@ -1785,8 +1785,8 @@ void AMDGPURegisterBankInfo::applyMappin
case Intrinsic::amdgcn_readlane: {
substituteSimpleCopyRegs(OpdMapper, 2);
- assert(empty(OpdMapper.getVRegs(0)));
- assert(empty(OpdMapper.getVRegs(3)));
+ assert(OpdMapper.getVRegs(0).empty());
+ assert(OpdMapper.getVRegs(3).empty());
// Make sure the index is an SGPR. It doesn't make sense to run this in a
// waterfall loop, so assume it's a uniform value.
@@ -1794,9 +1794,9 @@ void AMDGPURegisterBankInfo::applyMappin
return;
}
case Intrinsic::amdgcn_writelane: {
- assert(empty(OpdMapper.getVRegs(0)));
- assert(empty(OpdMapper.getVRegs(2)));
- assert(empty(OpdMapper.getVRegs(3)));
+ assert(OpdMapper.getVRegs(0).empty());
+ assert(OpdMapper.getVRegs(2).empty());
+ assert(OpdMapper.getVRegs(3).empty());
substituteSimpleCopyRegs(OpdMapper, 4); // VGPR input val
constrainOpWithReadfirstlane(MI, MRI, 2); // Source value
@@ -1818,7 +1818,7 @@ void AMDGPURegisterBankInfo::applyMappin
case Intrinsic::amdgcn_ds_ordered_add:
case Intrinsic::amdgcn_ds_ordered_swap: {
// This is only allowed to execute with 1 lane, so readfirstlane is safe.
- assert(empty(OpdMapper.getVRegs(0)));
+ assert(OpdMapper.getVRegs(0).empty());
substituteSimpleCopyRegs(OpdMapper, 3);
constrainOpWithReadfirstlane(MI, MRI, 2); // M0
return;
Modified: llvm/trunk/lib/Target/BPF/BPFAbstractMemberAccess.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFAbstractMemberAccess.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFAbstractMemberAccess.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFAbstractMemberAccess.cpp Mon Oct 7 11:14:24 2019
@@ -147,7 +147,7 @@ bool BPFAbstractMemberAccess::runOnModul
LLVM_DEBUG(dbgs() << "********** Abstract Member Accesses **********\n");
// Bail out if no debug info.
- if (empty(M.debug_compile_units()))
+ if (M.debug_compile_units().empty())
return false;
return doTransformation(M);
Modified: llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp Mon Oct 7 11:14:24 2019
@@ -59,7 +59,7 @@ bool BPFAsmPrinter::doInitialization(Mod
AsmPrinter::doInitialization(M);
// Only emit BTF when debuginfo available.
- if (MAI->doesSupportDebugInformation() && !empty(M.debug_compile_units())) {
+ if (MAI->doesSupportDebugInformation() && !M.debug_compile_units().empty()) {
BTF = new BTFDebug(this);
Handlers.push_back(HandlerInfo(std::unique_ptr<BTFDebug>(BTF), "emit",
"Debug Info Emission", "BTF",
Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp Mon Oct 7 11:14:24 2019
@@ -2273,7 +2273,7 @@ void PPCInstrInfo::replaceInstrOperandWi
Register InUseReg = MI.getOperand(OpNo).getReg();
MI.getOperand(OpNo).ChangeToImmediate(Imm);
- if (empty(MI.implicit_operands()))
+ if (MI.implicit_operands().empty())
return;
// We need to make sure that the MI didn't have any implicit use
Modified: llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp Mon Oct 7 11:14:24 2019
@@ -1264,7 +1264,7 @@ std::pair<bool, Function *> PartialInlin
if (PSI->isFunctionEntryCold(F))
return {false, nullptr};
- if (empty(F->users()))
+ if (F->users().empty())
return {false, nullptr};
OptimizationRemarkEmitter ORE(F);
@@ -1370,7 +1370,7 @@ bool PartialInlinerImpl::tryPartialInlin
return false;
}
- assert(empty(Cloner.OrigFunc->users()) &&
+ assert(Cloner.OrigFunc->users().empty() &&
"F's users should all be replaced!");
std::vector<User *> Users(Cloner.ClonedFunc->user_begin(),
Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon Oct 7 11:14:24 2019
@@ -2789,7 +2789,7 @@ bool IndVarSimplify::optimizeLoopExits(L
// have already been removed; TODO: generalize
BasicBlock *ExitBlock =
BI->getSuccessor(L->contains(BI->getSuccessor(0)) ? 1 : 0);
- if (!empty(ExitBlock->phis()))
+ if (!ExitBlock->phis().empty())
return true;
const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);
Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Mon Oct 7 11:14:24 2019
@@ -1754,7 +1754,7 @@ NewGVN::performSymbolicPHIEvaluation(Arr
return true;
});
// If we are left with no operands, it's dead.
- if (empty(Filtered)) {
+ if (Filtered.empty()) {
// If it has undef at this point, it means there are no-non-undef arguments,
// and thus, the value of the phi node must be undef.
if (HasUndef) {
Modified: llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp Mon Oct 7 11:14:24 2019
@@ -556,7 +556,7 @@ Value *PredicateInfo::materializeStack(u
if (isa<PredicateWithEdge>(ValInfo)) {
IRBuilder<> B(getBranchTerminator(ValInfo));
Function *IF = getCopyDeclaration(F.getParent(), Op->getType());
- if (empty(IF->users()))
+ if (IF->users().empty())
CreatedDeclarations.insert(IF);
CallInst *PIC =
B.CreateCall(IF, Op, Op->getName() + "." + Twine(Counter++));
@@ -568,7 +568,7 @@ Value *PredicateInfo::materializeStack(u
"Should not have gotten here without it being an assume");
IRBuilder<> B(PAssume->AssumeInst);
Function *IF = getCopyDeclaration(F.getParent(), Op->getType());
- if (empty(IF->users()))
+ if (IF->users().empty())
CreatedDeclarations.insert(IF);
CallInst *PIC = B.CreateCall(IF, Op);
PredicateMap.insert({PIC, ValInfo});
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=373935&r1=373934&r2=373935&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Oct 7 11:14:24 2019
@@ -5314,7 +5314,7 @@ static bool SwitchToLookupTable(SwitchIn
// Figure out the corresponding result for each case value and phi node in the
// common destination, as well as the min and max case values.
- assert(!empty(SI->cases()));
+ assert(!SI->cases().empty());
SwitchInst::CaseIt CI = SI->case_begin();
ConstantInt *MinCaseVal = CI->getCaseValue();
ConstantInt *MaxCaseVal = CI->getCaseValue();
More information about the llvm-commits
mailing list