Skip to content

Commit 2395379

Browse files
committed
[VirtRegMap] Remove unnecessary calls to Register::id() accessing IndexMaps.
VirtReg2IndexFunctor already takes a Register.
1 parent 2f48178 commit 2395379

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

llvm/include/llvm/CodeGen/VirtRegMap.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class TargetInstrInfo;
104104
/// virtual register
105105
MCRegister getPhys(Register virtReg) const {
106106
assert(virtReg.isVirtual());
107-
return MCRegister::from(Virt2PhysMap[virtReg.id()]);
107+
return MCRegister::from(Virt2PhysMap[virtReg]);
108108
}
109109

110110
/// creates a mapping for the specified virtual register to
@@ -130,9 +130,9 @@ class TargetInstrInfo;
130130
/// register mapping
131131
void clearVirt(Register virtReg) {
132132
assert(virtReg.isVirtual());
133-
assert(Virt2PhysMap[virtReg.id()] != NO_PHYS_REG &&
133+
assert(Virt2PhysMap[virtReg] != NO_PHYS_REG &&
134134
"attempt to clear a not assigned virtual register");
135-
Virt2PhysMap[virtReg.id()] = NO_PHYS_REG;
135+
Virt2PhysMap[virtReg] = NO_PHYS_REG;
136136
}
137137

138138
/// clears all virtual to physical register mappings
@@ -151,15 +151,15 @@ class TargetInstrInfo;
151151

152152
/// records virtReg is a split live interval from SReg.
153153
void setIsSplitFromReg(Register virtReg, Register SReg) {
154-
Virt2SplitMap[virtReg.id()] = SReg;
154+
Virt2SplitMap[virtReg] = SReg;
155155
if (hasShape(SReg)) {
156156
Virt2ShapeMap[virtReg] = getShape(SReg);
157157
}
158158
}
159159

160160
/// returns the live interval virtReg is split from.
161161
Register getPreSplitReg(Register virtReg) const {
162-
return Virt2SplitMap[virtReg.id()];
162+
return Virt2SplitMap[virtReg];
163163
}
164164

165165
/// getOriginal - Return the original virtual register that VirtReg descends
@@ -178,15 +178,15 @@ class TargetInstrInfo;
178178
return true;
179179
// Split register can be assigned a physical register as well as a
180180
// stack slot or remat id.
181-
return (Virt2SplitMap[virtReg.id()] &&
182-
Virt2PhysMap[virtReg.id()] != NO_PHYS_REG);
181+
return (Virt2SplitMap[virtReg] &&
182+
Virt2PhysMap[virtReg] != NO_PHYS_REG);
183183
}
184184

185185
/// returns the stack slot mapped to the specified virtual
186186
/// register
187187
int getStackSlot(Register virtReg) const {
188188
assert(virtReg.isVirtual());
189-
return Virt2StackSlotMap[virtReg.id()];
189+
return Virt2StackSlotMap[virtReg];
190190
}
191191

192192
/// create a mapping for the specifed virtual register to

llvm/lib/CodeGen/VirtRegMap.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ void VirtRegMap::grow() {
8484

8585
void VirtRegMap::assignVirt2Phys(Register virtReg, MCPhysReg physReg) {
8686
assert(virtReg.isVirtual() && Register::isPhysicalRegister(physReg));
87-
assert(Virt2PhysMap[virtReg.id()] == NO_PHYS_REG &&
87+
assert(Virt2PhysMap[virtReg] == NO_PHYS_REG &&
8888
"attempt to assign physical register to already mapped "
8989
"virtual register");
9090
assert(!getRegInfo().isReserved(physReg) &&
9191
"Attempt to map virtReg to a reserved physReg");
92-
Virt2PhysMap[virtReg.id()] = physReg;
92+
Virt2PhysMap[virtReg] = physReg;
9393
}
9494

9595
unsigned VirtRegMap::createSpillSlot(const TargetRegisterClass *RC) {
@@ -126,20 +126,20 @@ bool VirtRegMap::hasKnownPreference(Register VirtReg) const {
126126

127127
int VirtRegMap::assignVirt2StackSlot(Register virtReg) {
128128
assert(virtReg.isVirtual());
129-
assert(Virt2StackSlotMap[virtReg.id()] == NO_STACK_SLOT &&
129+
assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
130130
"attempt to assign stack slot to already spilled register");
131131
const TargetRegisterClass* RC = MF->getRegInfo().getRegClass(virtReg);
132-
return Virt2StackSlotMap[virtReg.id()] = createSpillSlot(RC);
132+
return Virt2StackSlotMap[virtReg] = createSpillSlot(RC);
133133
}
134134

135135
void VirtRegMap::assignVirt2StackSlot(Register virtReg, int SS) {
136136
assert(virtReg.isVirtual());
137-
assert(Virt2StackSlotMap[virtReg.id()] == NO_STACK_SLOT &&
137+
assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
138138
"attempt to assign stack slot to already spilled register");
139139
assert((SS >= 0 ||
140140
(SS >= MF->getFrameInfo().getObjectIndexBegin())) &&
141141
"illegal fixed frame index");
142-
Virt2StackSlotMap[virtReg.id()] = SS;
142+
Virt2StackSlotMap[virtReg] = SS;
143143
}
144144

145145
void VirtRegMap::print(raw_ostream &OS, const Module*) const {

0 commit comments

Comments
 (0)