diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -585,6 +585,16 @@ EarlyIncIteratorT(std::end(std::forward(Range)))); } +/// Make a range that does early increment given the start and end iterators. +/// This is a convenience form of make_early_inc_range(Range) which allows +/// make_early_inc_range to be used as a direct replacement for make_range. +template +iterator_range< + early_inc_iterator_impl>>> +make_early_inc_range(IteratorT X, IteratorT Y) { + return make_early_inc_range(make_range(X, Y)); +} + // forward declarations required by zip_shortest/zip_first/zip_longest template bool all_of(R &&range, UnaryPredicate P); diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -1060,8 +1060,8 @@ if (FirstTerm != InsertBB->end()) { assert(!FirstTerm->isDebugValue() && "first terminator cannot be a debug value"); - for (MachineInstr &MI : make_early_inc_range( - make_range(std::next(FirstTerm), InsertBB->end()))) { + for (MachineInstr &MI : + make_early_inc_range(std::next(FirstTerm), InsertBB->end())) { if (!MI.isDebugValue()) continue; diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp --- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp +++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp @@ -1325,9 +1325,8 @@ BasicBlock *OuterLoopHeader = OuterLoop->getHeader(); if (InnerLoopPreHeader != OuterLoopHeader) { SmallPtrSet NeedsMoving; - for (Instruction &I : - make_early_inc_range(make_range(InnerLoopPreHeader->begin(), - std::prev(InnerLoopPreHeader->end())))) + for (Instruction &I : make_early_inc_range( + InnerLoopPreHeader->begin(), std::prev(InnerLoopPreHeader->end()))) I.moveBefore(OuterLoopHeader->getTerminator()); }