Skip to content

Commit 156a0df

Browse files
committed
[MCP] Early exit if no copies (NFC)
These two functions do expensive per-regunit work, but are no-ops if there are no Copies, so short-circuit this case.
1 parent 4d2a670 commit 156a0df

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ class CopyTracker {
175175
/// Remove register from copy maps.
176176
void invalidateRegister(MCRegister Reg, const TargetRegisterInfo &TRI,
177177
const TargetInstrInfo &TII, bool UseCopyInstr) {
178+
if (Copies.empty())
179+
return;
180+
178181
// Since Reg might be a subreg of some registers, only invalidate Reg is not
179182
// enough. We have to find the COPY defines Reg or registers defined by Reg
180183
// and invalidate all of them. Similarly, we must invalidate all of the
@@ -262,6 +265,9 @@ class CopyTracker {
262265
/// Clobber a single register, removing it from the tracker's copy maps.
263266
void clobberRegister(MCRegister Reg, const TargetRegisterInfo &TRI,
264267
const TargetInstrInfo &TII, bool UseCopyInstr) {
268+
if (Copies.empty())
269+
return;
270+
265271
for (MCRegUnit Unit : TRI.regunits(Reg)) {
266272
clobberRegUnit(Unit, TRI, TII, UseCopyInstr);
267273
}

0 commit comments

Comments
 (0)