mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-13 08:26:02 +00:00
Use SmallVector instead of std::vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41207 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/ADT/GraphTraits.h"
|
#include "llvm/ADT/GraphTraits.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
@@ -111,18 +112,18 @@ public:
|
|||||||
/// outside of the loop. These are the blocks _inside of the current loop_
|
/// outside of the loop. These are the blocks _inside of the current loop_
|
||||||
/// which branch out. The returned list is always unique.
|
/// which branch out. The returned list is always unique.
|
||||||
///
|
///
|
||||||
void getExitingBlocks(std::vector<BasicBlock*> &Blocks) const;
|
void getExitingBlocks(SmallVector<BasicBlock *, 8> &Blocks) const;
|
||||||
|
|
||||||
/// getExitBlocks - Return all of the successor blocks of this loop. These
|
/// getExitBlocks - Return all of the successor blocks of this loop. These
|
||||||
/// are the blocks _outside of the current loop_ which are branched to.
|
/// are the blocks _outside of the current loop_ which are branched to.
|
||||||
///
|
///
|
||||||
void getExitBlocks(std::vector<BasicBlock*> &Blocks) const;
|
void getExitBlocks(SmallVector<BasicBlock*, 8> &Blocks) const;
|
||||||
|
|
||||||
/// getUniqueExitBlocks - Return all unique successor blocks of this loop.
|
/// getUniqueExitBlocks - Return all unique successor blocks of this loop.
|
||||||
/// These are the blocks _outside of the current loop_ which are branched to.
|
/// These are the blocks _outside of the current loop_ which are branched to.
|
||||||
/// This assumes that loop is in canonical form.
|
/// This assumes that loop is in canonical form.
|
||||||
///
|
///
|
||||||
void getUniqueExitBlocks(std::vector<BasicBlock*> &ExitBlocks) const;
|
void getUniqueExitBlocks(SmallVector<BasicBlock*, 8> &ExitBlocks) const;
|
||||||
|
|
||||||
/// getLoopPreheader - If there is a preheader for this loop, return it. A
|
/// getLoopPreheader - If there is a preheader for this loop, return it. A
|
||||||
/// loop has a preheader if there is only one edge to the header of the loop
|
/// loop has a preheader if there is only one edge to the header of the loop
|
||||||
|
@@ -350,7 +350,7 @@ void LoopInfo::removeBlock(BasicBlock *BB) {
|
|||||||
/// outside of the loop. These are the blocks _inside of the current loop_
|
/// outside of the loop. These are the blocks _inside of the current loop_
|
||||||
/// which branch out. The returned list is always unique.
|
/// which branch out. The returned list is always unique.
|
||||||
///
|
///
|
||||||
void Loop::getExitingBlocks(std::vector<BasicBlock*> &ExitingBlocks) const {
|
void Loop::getExitingBlocks(SmallVector<BasicBlock*, 8> &ExitingBlocks) const {
|
||||||
// Sort the blocks vector so that we can use binary search to do quick
|
// Sort the blocks vector so that we can use binary search to do quick
|
||||||
// lookups.
|
// lookups.
|
||||||
std::vector<BasicBlock*> LoopBBs(block_begin(), block_end());
|
std::vector<BasicBlock*> LoopBBs(block_begin(), block_end());
|
||||||
@@ -369,7 +369,7 @@ void Loop::getExitingBlocks(std::vector<BasicBlock*> &ExitingBlocks) const {
|
|||||||
/// getExitBlocks - Return all of the successor blocks of this loop. These
|
/// getExitBlocks - Return all of the successor blocks of this loop. These
|
||||||
/// are the blocks _outside of the current loop_ which are branched to.
|
/// are the blocks _outside of the current loop_ which are branched to.
|
||||||
///
|
///
|
||||||
void Loop::getExitBlocks(std::vector<BasicBlock*> &ExitBlocks) const {
|
void Loop::getExitBlocks(SmallVector<BasicBlock*, 8> &ExitBlocks) const {
|
||||||
// Sort the blocks vector so that we can use binary search to do quick
|
// Sort the blocks vector so that we can use binary search to do quick
|
||||||
// lookups.
|
// lookups.
|
||||||
std::vector<BasicBlock*> LoopBBs(block_begin(), block_end());
|
std::vector<BasicBlock*> LoopBBs(block_begin(), block_end());
|
||||||
@@ -387,7 +387,7 @@ void Loop::getExitBlocks(std::vector<BasicBlock*> &ExitBlocks) const {
|
|||||||
/// are the blocks _outside of the current loop_ which are branched to. This
|
/// are the blocks _outside of the current loop_ which are branched to. This
|
||||||
/// assumes that loop is in canonical form.
|
/// assumes that loop is in canonical form.
|
||||||
//
|
//
|
||||||
void Loop::getUniqueExitBlocks(std::vector<BasicBlock*> &ExitBlocks) const {
|
void Loop::getUniqueExitBlocks(SmallVector<BasicBlock*, 8> &ExitBlocks) const {
|
||||||
// Sort the blocks vector so that we can use binary search to do quick
|
// Sort the blocks vector so that we can use binary search to do quick
|
||||||
// lookups.
|
// lookups.
|
||||||
std::vector<BasicBlock*> LoopBBs(block_begin(), block_end());
|
std::vector<BasicBlock*> LoopBBs(block_begin(), block_end());
|
||||||
|
@@ -1569,7 +1569,7 @@ SCEVHandle ScalarEvolutionsImpl::getIterationCount(const Loop *L) {
|
|||||||
/// will iterate.
|
/// will iterate.
|
||||||
SCEVHandle ScalarEvolutionsImpl::ComputeIterationCount(const Loop *L) {
|
SCEVHandle ScalarEvolutionsImpl::ComputeIterationCount(const Loop *L) {
|
||||||
// If the loop has a non-one exit block count, we can't analyze it.
|
// If the loop has a non-one exit block count, we can't analyze it.
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
L->getExitBlocks(ExitBlocks);
|
L->getExitBlocks(ExitBlocks);
|
||||||
if (ExitBlocks.size() != 1) return UnknownValue;
|
if (ExitBlocks.size() != 1) return UnknownValue;
|
||||||
|
|
||||||
@@ -2620,7 +2620,7 @@ static void PrintLoopInfo(std::ostream &OS, const ScalarEvolution *SE,
|
|||||||
|
|
||||||
cerr << "Loop " << L->getHeader()->getName() << ": ";
|
cerr << "Loop " << L->getHeader()->getName() << ": ";
|
||||||
|
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
L->getExitBlocks(ExitBlocks);
|
L->getExitBlocks(ExitBlocks);
|
||||||
if (ExitBlocks.size() != 1)
|
if (ExitBlocks.size() != 1)
|
||||||
cerr << "<multiple exits> ";
|
cerr << "<multiple exits> ";
|
||||||
|
@@ -104,7 +104,7 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
|||||||
else {
|
else {
|
||||||
// Check to see if any exits from the loop are more than just return
|
// Check to see if any exits from the loop are more than just return
|
||||||
// blocks.
|
// blocks.
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
TLL->getExitBlocks(ExitBlocks);
|
TLL->getExitBlocks(ExitBlocks);
|
||||||
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
|
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
|
||||||
if (!isa<ReturnInst>(ExitBlocks[i]->getTerminator())) {
|
if (!isa<ReturnInst>(ExitBlocks[i]->getTerminator())) {
|
||||||
|
@@ -224,7 +224,7 @@ Instruction *IndVarSimplify::LinearFunctionTestReplace(Loop *L,
|
|||||||
SCEVExpander &RW) {
|
SCEVExpander &RW) {
|
||||||
// Find the exit block for the loop. We can currently only handle loops with
|
// Find the exit block for the loop. We can currently only handle loops with
|
||||||
// a single exit.
|
// a single exit.
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
L->getExitBlocks(ExitBlocks);
|
L->getExitBlocks(ExitBlocks);
|
||||||
if (ExitBlocks.size() != 1) return 0;
|
if (ExitBlocks.size() != 1) return 0;
|
||||||
BasicBlock *ExitBlock = ExitBlocks[0];
|
BasicBlock *ExitBlock = ExitBlocks[0];
|
||||||
@@ -309,7 +309,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
|
|||||||
// We insert the code into the preheader of the loop if the loop contains
|
// We insert the code into the preheader of the loop if the loop contains
|
||||||
// multiple exit blocks, or in the exit block if there is exactly one.
|
// multiple exit blocks, or in the exit block if there is exactly one.
|
||||||
BasicBlock *BlockToInsertInto;
|
BasicBlock *BlockToInsertInto;
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
L->getUniqueExitBlocks(ExitBlocks);
|
L->getUniqueExitBlocks(ExitBlocks);
|
||||||
if (ExitBlocks.size() == 1)
|
if (ExitBlocks.size() == 1)
|
||||||
BlockToInsertInto = ExitBlocks[0];
|
BlockToInsertInto = ExitBlocks[0];
|
||||||
|
@@ -446,7 +446,7 @@ bool LICM::isLoopInvariantInst(Instruction &I) {
|
|||||||
void LICM::sink(Instruction &I) {
|
void LICM::sink(Instruction &I) {
|
||||||
DOUT << "LICM sinking instruction: " << I;
|
DOUT << "LICM sinking instruction: " << I;
|
||||||
|
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
CurLoop->getExitBlocks(ExitBlocks);
|
CurLoop->getExitBlocks(ExitBlocks);
|
||||||
|
|
||||||
if (isa<LoadInst>(I)) ++NumMovedLoads;
|
if (isa<LoadInst>(I)) ++NumMovedLoads;
|
||||||
@@ -623,7 +623,7 @@ bool LICM::isSafeToExecuteUnconditionally(Instruction &Inst) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Get the exit blocks for the current loop.
|
// Get the exit blocks for the current loop.
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
CurLoop->getExitBlocks(ExitBlocks);
|
CurLoop->getExitBlocks(ExitBlocks);
|
||||||
|
|
||||||
// For each exit block, get the DT node and walk up the DT until the
|
// For each exit block, get the DT node and walk up the DT until the
|
||||||
@@ -725,7 +725,7 @@ void LICM::PromoteValuesInLoop() {
|
|||||||
//
|
//
|
||||||
std::set<BasicBlock*> ProcessedBlocks;
|
std::set<BasicBlock*> ProcessedBlocks;
|
||||||
|
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
CurLoop->getExitBlocks(ExitBlocks);
|
CurLoop->getExitBlocks(ExitBlocks);
|
||||||
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
|
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
|
||||||
if (ProcessedBlocks.insert(ExitBlocks[i]).second) {
|
if (ProcessedBlocks.insert(ExitBlocks[i]).second) {
|
||||||
|
@@ -157,7 +157,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
|
|||||||
// Keep it simple, and restrict loop rotation to loops with one exit only.
|
// Keep it simple, and restrict loop rotation to loops with one exit only.
|
||||||
// In future, lift this restriction and support for multiple exits if
|
// In future, lift this restriction and support for multiple exits if
|
||||||
// required.
|
// required.
|
||||||
std::vector<BasicBlock *> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
L->getExitBlocks(ExitBlocks);
|
L->getExitBlocks(ExitBlocks);
|
||||||
if (ExitBlocks.size() > 1)
|
if (ExitBlocks.size() > 1)
|
||||||
return false;
|
return false;
|
||||||
|
@@ -622,7 +622,7 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
|
|||||||
// We want the loop to come after the preheader, but before the exit blocks.
|
// We want the loop to come after the preheader, but before the exit blocks.
|
||||||
LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end());
|
LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end());
|
||||||
|
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
L->getUniqueExitBlocks(ExitBlocks);
|
L->getUniqueExitBlocks(ExitBlocks);
|
||||||
|
|
||||||
// Split all of the edges from inside the loop to their exit blocks. Update
|
// Split all of the edges from inside the loop to their exit blocks. Update
|
||||||
|
@@ -59,7 +59,7 @@ namespace {
|
|||||||
virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
|
virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
|
||||||
|
|
||||||
void ProcessInstruction(Instruction* Instr,
|
void ProcessInstruction(Instruction* Instr,
|
||||||
const std::vector<BasicBlock*>& exitBlocks);
|
const SmallVector<BasicBlock*, 8>& exitBlocks);
|
||||||
|
|
||||||
/// This transformation requires natural loop information & requires that
|
/// This transformation requires natural loop information & requires that
|
||||||
/// loop preheaders be inserted into the CFG. It maintains both of these,
|
/// loop preheaders be inserted into the CFG. It maintains both of these,
|
||||||
@@ -107,7 +107,6 @@ bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) {
|
|||||||
|
|
||||||
LI = &LPM.getAnalysis<LoopInfo>();
|
LI = &LPM.getAnalysis<LoopInfo>();
|
||||||
DT = &getAnalysis<DominatorTree>();
|
DT = &getAnalysis<DominatorTree>();
|
||||||
DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>();
|
|
||||||
|
|
||||||
// Speed up queries by creating a sorted list of blocks
|
// Speed up queries by creating a sorted list of blocks
|
||||||
LoopBlocks.clear();
|
LoopBlocks.clear();
|
||||||
@@ -122,10 +121,9 @@ bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) {
|
|||||||
if (AffectedValues.empty())
|
if (AffectedValues.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::vector<BasicBlock*> exitBlocks;
|
SmallVector<BasicBlock*, 8> exitBlocks;
|
||||||
L->getExitBlocks(exitBlocks);
|
L->getExitBlocks(exitBlocks);
|
||||||
|
|
||||||
|
|
||||||
// Iterate over all affected values for this loop and insert Phi nodes
|
// Iterate over all affected values for this loop and insert Phi nodes
|
||||||
// for them in the appropriate exit blocks
|
// for them in the appropriate exit blocks
|
||||||
|
|
||||||
@@ -141,7 +139,7 @@ bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) {
|
|||||||
/// processInstruction - Given a live-out instruction, insert LCSSA Phi nodes,
|
/// processInstruction - Given a live-out instruction, insert LCSSA Phi nodes,
|
||||||
/// eliminate all out-of-loop uses.
|
/// eliminate all out-of-loop uses.
|
||||||
void LCSSA::ProcessInstruction(Instruction *Instr,
|
void LCSSA::ProcessInstruction(Instruction *Instr,
|
||||||
const std::vector<BasicBlock*>& exitBlocks) {
|
const SmallVector<BasicBlock*, 8>& exitBlocks) {
|
||||||
++NumLCSSA; // We are applying the transformation
|
++NumLCSSA; // We are applying the transformation
|
||||||
|
|
||||||
// Keep track of the blocks that have the value available already.
|
// Keep track of the blocks that have the value available already.
|
||||||
@@ -151,7 +149,7 @@ void LCSSA::ProcessInstruction(Instruction *Instr,
|
|||||||
|
|
||||||
// Insert the LCSSA phi's into the exit blocks (dominated by the value), and
|
// Insert the LCSSA phi's into the exit blocks (dominated by the value), and
|
||||||
// add them to the Phi's map.
|
// add them to the Phi's map.
|
||||||
for (std::vector<BasicBlock*>::const_iterator BBI = exitBlocks.begin(),
|
for (SmallVector<BasicBlock*, 8>::const_iterator BBI = exitBlocks.begin(),
|
||||||
BBE = exitBlocks.end(); BBI != BBE; ++BBI) {
|
BBE = exitBlocks.end(); BBI != BBE; ++BBI) {
|
||||||
BasicBlock *BB = *BBI;
|
BasicBlock *BB = *BBI;
|
||||||
DomTreeNode *ExitBBNode = DT->getNode(BB);
|
DomTreeNode *ExitBBNode = DT->getNode(BB);
|
||||||
|
@@ -199,7 +199,7 @@ ReprocessLoop:
|
|||||||
// predecessors that are inside of the loop. This check guarantees that the
|
// predecessors that are inside of the loop. This check guarantees that the
|
||||||
// loop preheader/header will dominate the exit blocks. If the exit block has
|
// loop preheader/header will dominate the exit blocks. If the exit block has
|
||||||
// predecessors from outside of the loop, split the edge now.
|
// predecessors from outside of the loop, split the edge now.
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
L->getExitBlocks(ExitBlocks);
|
L->getExitBlocks(ExitBlocks);
|
||||||
|
|
||||||
SetVector<BasicBlock*> ExitBlockSet(ExitBlocks.begin(), ExitBlocks.end());
|
SetVector<BasicBlock*> ExitBlockSet(ExitBlocks.begin(), ExitBlocks.end());
|
||||||
|
Reference in New Issue
Block a user