@@ -66,6 +66,8 @@ namespace {
66
66
// / can be used to determine dominance between instructions in same MBB.
67
67
class InstrPosIndexes {
68
68
public:
69
+ void unsetInitialized () { IsInitialized = false ; }
70
+
69
71
void init (const MachineBasicBlock &MBB) {
70
72
CurMBB = &MBB;
71
73
Instr2PosIndex.clear ();
@@ -80,6 +82,13 @@ class InstrPosIndexes {
80
82
// / index without affecting existing instruction's index. Return true if all
81
83
// / instructions index has been reassigned.
82
84
bool getIndex (const MachineInstr &MI, uint64_t &Index) {
85
+ if (!IsInitialized) {
86
+ init (*MI.getParent ());
87
+ IsInitialized = true ;
88
+ Index = Instr2PosIndex.at (&MI);
89
+ return true ;
90
+ }
91
+
83
92
assert (MI.getParent () == CurMBB && " MI is not in CurMBB" );
84
93
auto It = Instr2PosIndex.find (&MI);
85
94
if (It != Instr2PosIndex.end ()) {
@@ -159,6 +168,7 @@ class InstrPosIndexes {
159
168
}
160
169
161
170
private:
171
+ bool IsInitialized = false ;
162
172
enum { InstrDist = 1024 };
163
173
const MachineBasicBlock *CurMBB = nullptr ;
164
174
DenseMap<const MachineInstr *, uint64_t > Instr2PosIndex;
@@ -1665,7 +1675,7 @@ void RegAllocFast::allocateBasicBlock(MachineBasicBlock &MBB) {
1665
1675
this ->MBB = &MBB;
1666
1676
LLVM_DEBUG (dbgs () << " \n Allocating " << MBB);
1667
1677
1668
- PosIndexes.init (MBB );
1678
+ PosIndexes.unsetInitialized ( );
1669
1679
RegUnitStates.assign (TRI->getNumRegUnits (), regFree);
1670
1680
assert (LiveVirtRegs.empty () && " Mapping not cleared from last block?" );
1671
1681
0 commit comments