IRCE: Demote template to ArrayRef and SmallVector to array.

NFC.

llvm-svn: 228398
This commit is contained in:
Benjamin Kramer 2015-02-06 14:43:49 +00:00
parent 92c1f363f4
commit 39f76acb5c
1 changed files with 15 additions and 26 deletions

View File

@ -569,10 +569,8 @@ class LoopConstrainer {
// Even though we do not preserve any passes at this time, we at least need to // 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 // keep the parent loop structure consistent. The `LPPassManager' seems to
// verify this after running a loop pass. This function adds the list of // verify this after running a loop pass. This function adds the list of
// blocks denoted by the iterator range [BlocksBegin, BlocksEnd) to this loops // blocks denoted by BBs to this loops parent loop if required.
// parent loop if required. void addToParentLoopIfNeeded(ArrayRef<BasicBlock *> BBs);
template<typename IteratorTy>
void addToParentLoopIfNeeded(IteratorTy BlocksBegin, IteratorTy BlocksEnd);
// Some global state. // Some global state.
Function &F; Function &F;
@ -1009,15 +1007,13 @@ LoopConstrainer::createPreheader(const LoopConstrainer::LoopStructure &LS,
return Preheader; return Preheader;
} }
template<typename IteratorTy> void LoopConstrainer::addToParentLoopIfNeeded(ArrayRef<BasicBlock *> BBs) {
void LoopConstrainer::addToParentLoopIfNeeded(IteratorTy Begin,
IteratorTy End) {
Loop *ParentLoop = OriginalLoop.getParentLoop(); Loop *ParentLoop = OriginalLoop.getParentLoop();
if (!ParentLoop) if (!ParentLoop)
return; return;
for (; Begin != End; Begin++) for (BasicBlock *BB : BBs)
ParentLoop->addBasicBlockToLoop(*Begin, OriginalLoopInfo); ParentLoop->addBasicBlockToLoop(BB, OriginalLoopInfo);
} }
bool LoopConstrainer::run() { bool LoopConstrainer::run() {
@ -1082,27 +1078,20 @@ bool LoopConstrainer::run() {
PostLoopRRI); PostLoopRRI);
} }
SmallVector<BasicBlock *, 6> NewBlocks; BasicBlock *NewMainLoopPreheader =
NewBlocks.push_back(PostLoopPreheader); MainLoopPreheader != Preheader ? MainLoopPreheader : nullptr;
NewBlocks.push_back(PreLoopRRI.PseudoExit); BasicBlock *NewBlocks[] = {PostLoopPreheader, PreLoopRRI.PseudoExit,
NewBlocks.push_back(PreLoopRRI.ExitSelector); PreLoopRRI.ExitSelector, PostLoopRRI.PseudoExit,
NewBlocks.push_back(PostLoopRRI.PseudoExit); PostLoopRRI.ExitSelector, NewMainLoopPreheader};
NewBlocks.push_back(PostLoopRRI.ExitSelector);
if (MainLoopPreheader != Preheader)
NewBlocks.push_back(MainLoopPreheader);
// Some of the above may be nullptr, filter them out before passing to // Some of the above may be nullptr, filter them out before passing to
// addToParentLoopIfNeeded. // addToParentLoopIfNeeded.
auto NewBlocksEnd = std::remove(NewBlocks.begin(), NewBlocks.end(), nullptr); auto NewBlocksEnd =
std::remove(std::begin(NewBlocks), std::end(NewBlocks), nullptr);
typedef SmallVector<BasicBlock *, 6>::iterator SmallVectItTy; addToParentLoopIfNeeded(makeArrayRef(std::begin(NewBlocks), NewBlocksEnd));
typedef std::vector<BasicBlock *>::iterator StdVectItTy; addToParentLoopIfNeeded(PreLoop.Blocks);
addToParentLoopIfNeeded(PostLoop.Blocks);
addToParentLoopIfNeeded<SmallVectItTy>(NewBlocks.begin(), NewBlocksEnd);
addToParentLoopIfNeeded<StdVectItTy>(PreLoop.Blocks.begin(),
PreLoop.Blocks.end());
addToParentLoopIfNeeded<StdVectItTy>(PostLoop.Blocks.begin(),
PostLoop.Blocks.end());
return true; return true;
} }