From 33988ee4cac27c1512bd69cc060762cb47852ff6 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 6 Feb 2015 14:43:49 +0000 Subject: [PATCH] IRCE: Demote template to ArrayRef and SmallVector to array. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228398 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Scalar/InductiveRangeCheckElimination.cpp | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp index 327d4fea25d..e9b5f7023c3 100644 --- a/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ b/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -569,10 +569,8 @@ class LoopConstrainer { // Even though we do not preserve any passes at this time, we at least need to // keep the parent loop structure consistent. The `LPPassManager' seems to // verify this after running a loop pass. This function adds the list of - // blocks denoted by the iterator range [BlocksBegin, BlocksEnd) to this loops - // parent loop if required. - template - void addToParentLoopIfNeeded(IteratorTy BlocksBegin, IteratorTy BlocksEnd); + // blocks denoted by BBs to this loops parent loop if required. + void addToParentLoopIfNeeded(ArrayRef BBs); // Some global state. Function &F; @@ -1009,15 +1007,13 @@ LoopConstrainer::createPreheader(const LoopConstrainer::LoopStructure &LS, return Preheader; } -template -void LoopConstrainer::addToParentLoopIfNeeded(IteratorTy Begin, - IteratorTy End) { +void LoopConstrainer::addToParentLoopIfNeeded(ArrayRef BBs) { Loop *ParentLoop = OriginalLoop.getParentLoop(); if (!ParentLoop) return; - for (; Begin != End; Begin++) - ParentLoop->addBasicBlockToLoop(*Begin, OriginalLoopInfo); + for (BasicBlock *BB : BBs) + ParentLoop->addBasicBlockToLoop(BB, OriginalLoopInfo); } bool LoopConstrainer::run() { @@ -1082,27 +1078,20 @@ bool LoopConstrainer::run() { PostLoopRRI); } - SmallVector NewBlocks; - NewBlocks.push_back(PostLoopPreheader); - NewBlocks.push_back(PreLoopRRI.PseudoExit); - NewBlocks.push_back(PreLoopRRI.ExitSelector); - NewBlocks.push_back(PostLoopRRI.PseudoExit); - NewBlocks.push_back(PostLoopRRI.ExitSelector); - if (MainLoopPreheader != Preheader) - NewBlocks.push_back(MainLoopPreheader); + BasicBlock *NewMainLoopPreheader = + MainLoopPreheader != Preheader ? MainLoopPreheader : nullptr; + BasicBlock *NewBlocks[] = {PostLoopPreheader, PreLoopRRI.PseudoExit, + PreLoopRRI.ExitSelector, PostLoopRRI.PseudoExit, + PostLoopRRI.ExitSelector, NewMainLoopPreheader}; // Some of the above may be nullptr, filter them out before passing to // addToParentLoopIfNeeded. - auto NewBlocksEnd = std::remove(NewBlocks.begin(), NewBlocks.end(), nullptr); + auto NewBlocksEnd = + std::remove(std::begin(NewBlocks), std::end(NewBlocks), nullptr); - typedef SmallVector::iterator SmallVectItTy; - typedef std::vector::iterator StdVectItTy; - - addToParentLoopIfNeeded(NewBlocks.begin(), NewBlocksEnd); - addToParentLoopIfNeeded(PreLoop.Blocks.begin(), - PreLoop.Blocks.end()); - addToParentLoopIfNeeded(PostLoop.Blocks.begin(), - PostLoop.Blocks.end()); + addToParentLoopIfNeeded(makeArrayRef(std::begin(NewBlocks), NewBlocksEnd)); + addToParentLoopIfNeeded(PreLoop.Blocks); + addToParentLoopIfNeeded(PostLoop.Blocks); return true; } -- 2.34.1