[NFC] Use SmallVector/ArrayRef in MachineOutliner/SuffixTree for small types
The MachineOutliner + SuffixTree both used `std::vector` everywhere because I didn't know any better at the time. At least for small types, such as `unsigned` and iterators, I can't see any particular reason to use std::vector over `SmallVector` here.
This commit is contained in:
parent
a772f0bb92
commit
ec37ebf59b
|
@ -145,7 +145,7 @@ public:
|
|||
unsigned Length;
|
||||
|
||||
/// The start indices of each occurrence.
|
||||
std::vector<unsigned> StartIndices;
|
||||
SmallVector<unsigned> StartIndices;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -232,7 +232,7 @@ public:
|
|||
/// Construct a suffix tree from a sequence of unsigned integers.
|
||||
///
|
||||
/// \param Str The string to construct the suffix tree for.
|
||||
SuffixTree(const std::vector<unsigned> &Str);
|
||||
SuffixTree(const ArrayRef<unsigned> &Str);
|
||||
|
||||
/// Iterator for finding all repeated substrings in the suffix tree.
|
||||
struct RepeatedSubstringIterator {
|
||||
|
@ -244,7 +244,7 @@ public:
|
|||
RepeatedSubstring RS;
|
||||
|
||||
/// The nodes left to visit.
|
||||
std::vector<SuffixTreeNode *> ToVisit;
|
||||
SmallVector<SuffixTreeNode *> ToVisit;
|
||||
|
||||
/// The minimum length of a repeated substring to find.
|
||||
/// Since we're outlining, we want at least two instructions in the range.
|
||||
|
@ -260,7 +260,7 @@ public:
|
|||
N = nullptr;
|
||||
|
||||
// Each leaf node represents a repeat of a string.
|
||||
std::vector<SuffixTreeNode *> LeafChildren;
|
||||
SmallVector<SuffixTreeNode *> LeafChildren;
|
||||
|
||||
// Continue visiting nodes until we find one which repeats more than once.
|
||||
while (!ToVisit.empty()) {
|
||||
|
|
|
@ -136,11 +136,11 @@ struct InstructionMapper {
|
|||
DenseMap<MachineBasicBlock *, unsigned> MBBFlagsMap;
|
||||
|
||||
/// The vector of unsigned integers that the module is mapped to.
|
||||
std::vector<unsigned> UnsignedVec;
|
||||
SmallVector<unsigned> UnsignedVec;
|
||||
|
||||
/// Stores the location of the instruction associated with the integer
|
||||
/// at index i in \p UnsignedVec for each index i.
|
||||
std::vector<MachineBasicBlock::iterator> InstrList;
|
||||
SmallVector<MachineBasicBlock::iterator> InstrList;
|
||||
|
||||
// Set if we added an illegal number in the previous step.
|
||||
// Since each illegal number is unique, we only need one of them between
|
||||
|
@ -157,8 +157,8 @@ struct InstructionMapper {
|
|||
unsigned mapToLegalUnsigned(
|
||||
MachineBasicBlock::iterator &It, bool &CanOutlineWithPrevInstr,
|
||||
bool &HaveLegalRange, unsigned &NumLegalInBlock,
|
||||
std::vector<unsigned> &UnsignedVecForMBB,
|
||||
std::vector<MachineBasicBlock::iterator> &InstrListForMBB) {
|
||||
SmallVector<unsigned> &UnsignedVecForMBB,
|
||||
SmallVector<MachineBasicBlock::iterator> &InstrListForMBB) {
|
||||
// We added something legal, so we should unset the AddedLegalLastTime
|
||||
// flag.
|
||||
AddedIllegalLastTime = false;
|
||||
|
@ -211,8 +211,8 @@ struct InstructionMapper {
|
|||
/// \returns The integer that \p *It was mapped to.
|
||||
unsigned mapToIllegalUnsigned(
|
||||
MachineBasicBlock::iterator &It, bool &CanOutlineWithPrevInstr,
|
||||
std::vector<unsigned> &UnsignedVecForMBB,
|
||||
std::vector<MachineBasicBlock::iterator> &InstrListForMBB) {
|
||||
SmallVector<unsigned> &UnsignedVecForMBB,
|
||||
SmallVector<MachineBasicBlock::iterator> &InstrListForMBB) {
|
||||
// Can't outline an illegal instruction. Set the flag.
|
||||
CanOutlineWithPrevInstr = false;
|
||||
|
||||
|
@ -287,8 +287,8 @@ struct InstructionMapper {
|
|||
|
||||
// FIXME: Should this all just be handled in the target, rather than using
|
||||
// repeated calls to getOutliningType?
|
||||
std::vector<unsigned> UnsignedVecForMBB;
|
||||
std::vector<MachineBasicBlock::iterator> InstrListForMBB;
|
||||
SmallVector<unsigned> UnsignedVecForMBB;
|
||||
SmallVector<MachineBasicBlock::iterator> InstrListForMBB;
|
||||
|
||||
LLVM_DEBUG(dbgs() << "*** Mapping outlinable ranges ***\n");
|
||||
for (auto &OutlinableRange : OutlinableRanges) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
SuffixTree::SuffixTree(const std::vector<unsigned> &Str) : Str(Str) {
|
||||
SuffixTree::SuffixTree(const ArrayRef<unsigned> &Str) : Str(Str) {
|
||||
Root = insertInternalNode(nullptr, EmptyIdx, EmptyIdx, 0);
|
||||
Active.Node = Root;
|
||||
|
||||
|
@ -70,7 +70,7 @@ SuffixTreeNode *SuffixTree::insertInternalNode(SuffixTreeNode *Parent,
|
|||
void SuffixTree::setSuffixIndices() {
|
||||
// List of nodes we need to visit along with the current length of the
|
||||
// string.
|
||||
std::vector<std::pair<SuffixTreeNode *, unsigned>> ToVisit;
|
||||
SmallVector<std::pair<SuffixTreeNode *, unsigned>> ToVisit;
|
||||
|
||||
// Current node being visited.
|
||||
SuffixTreeNode *CurrNode = Root;
|
||||
|
|
Loading…
Reference in New Issue
Block a user