Skip to content

Commit f671584

Browse files
authored
[CFIInstrInserter] Use number of supported registers (NFC) (#71797)
This makes use of the more accurate register number introduced in PR #70222 to avoid CFI calculations for unsupported registers. This has basically no impact right now, but results in a 0.2% compile-time improvement at O0 when applied on top of #70958. The reason is that the extra registers that PR adds push the `BitVector` out of the `SmallVector` space, which results in an outsized impact. (This does make me wonder whether `BitVector` should accept an `N` template parameter to allow using a larger `SmallVector`...)
1 parent b90cba1 commit f671584

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/CodeGen/CFIInstrInserter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void CFIInstrInserter::calculateCFAInfo(MachineFunction &MF) {
151151
Register InitialRegister =
152152
MF.getSubtarget().getFrameLowering()->getInitialCFARegister(MF);
153153
InitialRegister = TRI.getDwarfRegNum(InitialRegister, true);
154-
unsigned NumRegs = TRI.getNumRegs();
154+
unsigned NumRegs = TRI.getNumSupportedRegs(MF);
155155

156156
// Initialize MBBMap.
157157
for (MachineBasicBlock &MBB : MF) {
@@ -181,7 +181,7 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
181181
MachineFunction *MF = MBBInfo.MBB->getParent();
182182
const std::vector<MCCFIInstruction> &Instrs = MF->getFrameInstructions();
183183
const TargetRegisterInfo &TRI = *MF->getSubtarget().getRegisterInfo();
184-
unsigned NumRegs = TRI.getNumRegs();
184+
unsigned NumRegs = TRI.getNumSupportedRegs(*MF);
185185
BitVector CSRSaved(NumRegs), CSRRestored(NumRegs);
186186

187187
// Determine cfa offset and register set by the block.

0 commit comments

Comments
 (0)