Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit a229846

Browse files
committed
Reverting r243386 because it has serious post-commit concerns that have not been addressed. Also reverts r243389, which relied on this commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243527 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent edbf9d7 commit a229846

File tree

4 files changed

+15
-148
lines changed

4 files changed

+15
-148
lines changed

docs/ProgrammersManual.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,8 +1314,7 @@ never use hash_set and unordered_set because they are generally very expensive
13141314
std::multiset is useful if you're not interested in elimination of duplicates,
13151315
but has all the drawbacks of :ref:`std::set <dss_set>`. A sorted vector
13161316
(where you don't delete duplicate entries) or some other approach is almost
1317-
always better. LLVM actually offers SortedVector which does the job of a sorted
1318-
std::vector.
1317+
always better.
13191318

13201319
.. _ds_map:
13211320

include/llvm/ADT/SortedVector.h

Lines changed: 0 additions & 133 deletions
This file was deleted.

include/llvm/CodeGen/MachineBasicBlock.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
1515
#define LLVM_CODEGEN_MACHINEBASICBLOCK_H
1616

17-
#include "llvm/ADT/SortedVector.h"
1817
#include "llvm/ADT/GraphTraits.h"
1918
#include "llvm/CodeGen/MachineInstr.h"
2019
#include "llvm/Support/DataTypes.h"
@@ -81,7 +80,7 @@ class MachineBasicBlock : public ilist_node<MachineBasicBlock> {
8180

8281
/// LiveIns - Keep track of the physical registers that are livein of
8382
/// the basicblock.
84-
mutable SortedVector<unsigned> LiveIns;
83+
std::vector<unsigned> LiveIns;
8584

8685
/// Alignment - Alignment of the basic block. Zero if the basic block does
8786
/// not need to be aligned.
@@ -319,12 +318,15 @@ class MachineBasicBlock : public ilist_node<MachineBasicBlock> {
319318
/// Adds the specified register as a live in. Note that it is an error to add
320319
/// the same register to the same set more than once unless the intention is
321320
/// to call sortUniqueLiveIns after all registers are added.
322-
void addLiveIn(unsigned Reg) { LiveIns.insert(Reg); }
321+
void addLiveIn(unsigned Reg) { LiveIns.push_back(Reg); }
323322

324323
/// Sorts and uniques the LiveIns vector. It can be significantly faster to do
325324
/// this than repeatedly calling isLiveIn before calling addLiveIn for every
326325
/// LiveIn insertion.
327-
void sortUniqueLiveIns() { LiveIns.sortUnique(); }
326+
void sortUniqueLiveIns() {
327+
std::sort(LiveIns.begin(), LiveIns.end());
328+
LiveIns.erase(std::unique(LiveIns.begin(), LiveIns.end()), LiveIns.end());
329+
}
328330

329331
/// Add PhysReg as live in to this block, and ensure that there is a copy of
330332
/// PhysReg to a virtual register of class RC. Return the virtual register
@@ -337,20 +339,14 @@ class MachineBasicBlock : public ilist_node<MachineBasicBlock> {
337339

338340
/// isLiveIn - Return true if the specified register is in the live in set.
339341
///
340-
bool isLiveIn(unsigned Reg) const { return LiveIns.has(Reg); }
342+
bool isLiveIn(unsigned Reg) const;
341343

342344
// Iteration support for live in sets. These sets are kept in sorted
343345
// order by their register number.
344346
typedef std::vector<unsigned>::const_iterator livein_iterator;
347+
livein_iterator livein_begin() const { return LiveIns.begin(); }
348+
livein_iterator livein_end() const { return LiveIns.end(); }
345349
bool livein_empty() const { return LiveIns.empty(); }
346-
livein_iterator livein_begin() const {
347-
LiveIns.sortUnique();
348-
return LiveIns.begin();
349-
}
350-
livein_iterator livein_end() const {
351-
LiveIns.sortUnique();
352-
return LiveIns.end();
353-
}
354350

355351
/// getAlignment - Return alignment of the basic block.
356352
/// The alignment is specified as log2(bytes).

lib/CodeGen/MachineBasicBlock.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ void MachineBasicBlock::removeLiveIn(unsigned Reg) {
332332
LiveIns.erase(I);
333333
}
334334

335+
bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
336+
livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
337+
return I != livein_end();
338+
}
339+
335340
unsigned
336341
MachineBasicBlock::addLiveIn(unsigned PhysReg, const TargetRegisterClass *RC) {
337342
assert(getParent() && "MBB must be inserted in function");

0 commit comments

Comments
 (0)