Skip to content

Commit ab626eb

Browse files
committed
Reapply "Convert many LivePhysRegs uses to LiveRegUnits"
This only converts the instances where all that is needed is to change the variable type name. Basically, anything that involves a function that LiveRegUnits does not directly have was skipped to play it safe. Reverts 7a0e222
1 parent 9f96db8 commit ab626eb

File tree

10 files changed

+45
-53
lines changed

10 files changed

+45
-53
lines changed

llvm/lib/CodeGen/ReachingDefAnalysis.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "llvm/ADT/SmallSet.h"
10-
#include "llvm/ADT/SetOperations.h"
11-
#include "llvm/CodeGen/LivePhysRegs.h"
129
#include "llvm/CodeGen/ReachingDefAnalysis.h"
10+
#include "llvm/ADT/SetOperations.h"
11+
#include "llvm/ADT/SmallSet.h"
12+
#include "llvm/CodeGen/LiveRegUnits.h"
1313
#include "llvm/CodeGen/TargetRegisterInfo.h"
1414
#include "llvm/CodeGen/TargetSubtargetInfo.h"
1515
#include "llvm/Support/Debug.h"
@@ -421,9 +421,9 @@ void ReachingDefAnalysis::getLiveOuts(MachineBasicBlock *MBB,
421421
return;
422422

423423
VisitedBBs.insert(MBB);
424-
LivePhysRegs LiveRegs(*TRI);
424+
LiveRegUnits LiveRegs(*TRI);
425425
LiveRegs.addLiveOuts(*MBB);
426-
if (LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
426+
if (LiveRegs.available(PhysReg))
427427
return;
428428

429429
if (auto *Def = getLocalLiveOutMIDef(MBB, PhysReg))
@@ -469,19 +469,19 @@ MachineInstr *ReachingDefAnalysis::getMIOperand(MachineInstr *MI,
469469
bool ReachingDefAnalysis::isRegUsedAfter(MachineInstr *MI,
470470
MCRegister PhysReg) const {
471471
MachineBasicBlock *MBB = MI->getParent();
472-
LivePhysRegs LiveRegs(*TRI);
472+
LiveRegUnits LiveRegs(*TRI);
473473
LiveRegs.addLiveOuts(*MBB);
474474

475475
// Yes if the register is live out of the basic block.
476-
if (!LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
476+
if (!LiveRegs.available(PhysReg))
477477
return true;
478478

479479
// Walk backwards through the block to see if the register is live at some
480480
// point.
481481
for (MachineInstr &Last :
482482
instructionsWithoutDebug(MBB->instr_rbegin(), MBB->instr_rend())) {
483483
LiveRegs.stepBackward(Last);
484-
if (!LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
484+
if (!LiveRegs.available(PhysReg))
485485
return InstIds.lookup(&Last) > InstIds.lookup(MI);
486486
}
487487
return false;
@@ -504,9 +504,9 @@ bool ReachingDefAnalysis::isRegDefinedAfter(MachineInstr *MI,
504504
bool ReachingDefAnalysis::isReachingDefLiveOut(MachineInstr *MI,
505505
MCRegister PhysReg) const {
506506
MachineBasicBlock *MBB = MI->getParent();
507-
LivePhysRegs LiveRegs(*TRI);
507+
LiveRegUnits LiveRegs(*TRI);
508508
LiveRegs.addLiveOuts(*MBB);
509-
if (LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
509+
if (LiveRegs.available(PhysReg))
510510
return false;
511511

512512
auto Last = MBB->getLastNonDebugInstr();
@@ -525,9 +525,9 @@ bool ReachingDefAnalysis::isReachingDefLiveOut(MachineInstr *MI,
525525
MachineInstr *
526526
ReachingDefAnalysis::getLocalLiveOutMIDef(MachineBasicBlock *MBB,
527527
MCRegister PhysReg) const {
528-
LivePhysRegs LiveRegs(*TRI);
528+
LiveRegUnits LiveRegs(*TRI);
529529
LiveRegs.addLiveOuts(*MBB);
530-
if (LiveRegs.available(MBB->getParent()->getRegInfo(), PhysReg))
530+
if (LiveRegs.available(PhysReg))
531531
return nullptr;
532532

533533
auto Last = MBB->getLastNonDebugInstr();

llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
1212
#include "SIRegisterInfo.h"
1313
#include "llvm/ADT/SmallVector.h"
14-
#include "llvm/CodeGen/LivePhysRegs.h"
14+
#include "llvm/CodeGen/LiveRegUnits.h"
1515
#include "llvm/CodeGen/MachineFunctionPass.h"
1616
#include "llvm/CodeGen/MachineOperand.h"
1717
#include "llvm/CodeGen/TargetRegisterInfo.h"
@@ -313,7 +313,7 @@ MachineBasicBlock::reverse_iterator SIOptimizeExecMasking::findExecCopy(
313313
return E;
314314
}
315315

316-
// XXX - Seems LivePhysRegs doesn't work correctly since it will incorrectly
316+
// XXX - Seems LiveRegUnits doesn't work correctly since it will incorrectly
317317
// report the register as unavailable because a super-register with a lane mask
318318
// is unavailable.
319319
static bool isLiveOut(const MachineBasicBlock &MBB, unsigned Reg) {
@@ -383,7 +383,7 @@ bool SIOptimizeExecMasking::isRegisterInUseBetween(MachineInstr &Stop,
383383
MCRegister Reg,
384384
bool UseLiveOuts,
385385
bool IgnoreStart) const {
386-
LivePhysRegs LR(*TRI);
386+
LiveRegUnits LR(*TRI);
387387
if (UseLiveOuts)
388388
LR.addLiveOuts(*Stop.getParent());
389389

@@ -396,7 +396,7 @@ bool SIOptimizeExecMasking::isRegisterInUseBetween(MachineInstr &Stop,
396396
LR.stepBackward(*A);
397397
}
398398

399-
return !LR.available(*MRI, Reg);
399+
return !LR.available(Reg) || MRI->isReserved(Reg);
400400
}
401401

402402
// Determine if a register Reg is not re-defined and still in use

llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "llvm/ADT/Statistic.h"
3232
#include "llvm/ADT/iterator_range.h"
3333
#include "llvm/Analysis/AliasAnalysis.h"
34-
#include "llvm/CodeGen/LivePhysRegs.h"
34+
#include "llvm/CodeGen/LiveRegUnits.h"
3535
#include "llvm/CodeGen/MachineBasicBlock.h"
3636
#include "llvm/CodeGen/MachineDominators.h"
3737
#include "llvm/CodeGen/MachineFrameInfo.h"
@@ -109,7 +109,7 @@ namespace {
109109
const ARMSubtarget *STI;
110110
const TargetLowering *TL;
111111
ARMFunctionInfo *AFI;
112-
LivePhysRegs LiveRegs;
112+
LiveRegUnits LiveRegs;
113113
RegisterClassInfo RegClassInfo;
114114
MachineBasicBlock::const_iterator LiveRegPos;
115115
bool LiveRegsValid;
@@ -589,7 +589,7 @@ unsigned ARMLoadStoreOpt::findFreeReg(const TargetRegisterClass &RegClass) {
589589
}
590590

591591
for (unsigned Reg : RegClassInfo.getOrder(&RegClass))
592-
if (LiveRegs.available(MF->getRegInfo(), Reg))
592+
if (LiveRegs.available(Reg) && !MF->getRegInfo().isReserved(Reg))
593593
return Reg;
594594
return 0;
595595
}

llvm/lib/Target/ARM/Thumb1FrameLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,11 @@ bool Thumb1FrameLowering::needPopSpecialFixUp(const MachineFunction &MF) const {
612612

613613
static void findTemporariesForLR(const BitVector &GPRsNoLRSP,
614614
const BitVector &PopFriendly,
615-
const LivePhysRegs &UsedRegs, unsigned &PopReg,
615+
const LiveRegUnits &UsedRegs, unsigned &PopReg,
616616
unsigned &TmpReg, MachineRegisterInfo &MRI) {
617617
PopReg = TmpReg = 0;
618618
for (auto Reg : GPRsNoLRSP.set_bits()) {
619-
if (UsedRegs.available(MRI, Reg)) {
619+
if (UsedRegs.available(Reg)) {
620620
// Remember the first pop-friendly register and exit.
621621
if (PopFriendly.test(Reg)) {
622622
PopReg = Reg;
@@ -684,7 +684,7 @@ bool Thumb1FrameLowering::emitPopSpecialFixUp(MachineBasicBlock &MBB,
684684
// Look for a temporary register to use.
685685
// First, compute the liveness information.
686686
const TargetRegisterInfo &TRI = *STI.getRegisterInfo();
687-
LivePhysRegs UsedRegs(TRI);
687+
LiveRegUnits UsedRegs(TRI);
688688
UsedRegs.addLiveOuts(MBB);
689689
// The semantic of pristines changed recently and now,
690690
// the callee-saved registers that are touched in the function

llvm/lib/Target/Hexagon/HexagonGenMux.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "llvm/ADT/DenseMap.h"
2727
#include "llvm/ADT/SmallVector.h"
2828
#include "llvm/ADT/StringRef.h"
29-
#include "llvm/CodeGen/LivePhysRegs.h"
29+
#include "llvm/CodeGen/LiveRegUnits.h"
3030
#include "llvm/CodeGen/MachineBasicBlock.h"
3131
#include "llvm/CodeGen/MachineFunction.h"
3232
#include "llvm/CodeGen/MachineFunctionPass.h"
@@ -346,14 +346,8 @@ bool HexagonGenMux::genMuxInBlock(MachineBasicBlock &B) {
346346

347347
// Fix up kill flags.
348348

349-
LivePhysRegs LPR(*HRI);
349+
LiveRegUnits LPR(*HRI);
350350
LPR.addLiveOuts(B);
351-
auto IsLive = [&LPR, this](unsigned Reg) -> bool {
352-
for (MCPhysReg S : HRI->subregs_inclusive(Reg))
353-
if (LPR.contains(S))
354-
return true;
355-
return false;
356-
};
357351
for (MachineInstr &I : llvm::reverse(B)) {
358352
if (I.isDebugInstr())
359353
continue;
@@ -365,7 +359,7 @@ bool HexagonGenMux::genMuxInBlock(MachineBasicBlock &B) {
365359
if (!Op.isReg() || !Op.isUse())
366360
continue;
367361
assert(Op.getSubReg() == 0 && "Should have physical registers only");
368-
bool Live = IsLive(Op.getReg());
362+
bool Live = !LPR.available(Op.getReg());
369363
Op.setIsKill(!Live);
370364
}
371365
LPR.stepBackward(I);

llvm/lib/Target/SystemZ/SystemZElimCompare.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "llvm/ADT/SmallVector.h"
1919
#include "llvm/ADT/Statistic.h"
2020
#include "llvm/ADT/StringRef.h"
21-
#include "llvm/CodeGen/LivePhysRegs.h"
21+
#include "llvm/CodeGen/LiveRegUnits.h"
2222
#include "llvm/CodeGen/MachineBasicBlock.h"
2323
#include "llvm/CodeGen/MachineFunction.h"
2424
#include "llvm/CodeGen/MachineFunctionPass.h"
@@ -690,9 +690,9 @@ bool SystemZElimCompare::processBlock(MachineBasicBlock &MBB) {
690690
// Walk backwards through the block looking for comparisons, recording
691691
// all CC users as we go. The subroutines can delete Compare and
692692
// instructions before it.
693-
LivePhysRegs LiveRegs(*TRI);
693+
LiveRegUnits LiveRegUnits(*TRI);
694694
LiveRegs.addLiveOuts(MBB);
695-
bool CompleteCCUsers = !LiveRegs.contains(SystemZ::CC);
695+
bool CompleteCCUsers = LiveRegs.available(SystemZ::CC);
696696
SmallVector<MachineInstr *, 4> CCUsers;
697697
MachineBasicBlock::iterator MBBI = MBB.end();
698698
while (MBBI != MBB.begin()) {

llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "llvm/ADT/Statistic.h"
1919
#include "llvm/CodeGen/LiveInterval.h"
2020
#include "llvm/CodeGen/LiveIntervals.h"
21-
#include "llvm/CodeGen/LivePhysRegs.h"
21+
#include "llvm/CodeGen/LiveRegUnits.h"
2222
#include "llvm/CodeGen/LiveVariables.h"
2323
#include "llvm/CodeGen/MachineBasicBlock.h"
2424
#include "llvm/CodeGen/MachineFrameInfo.h"
@@ -1874,9 +1874,9 @@ prepareCompareSwapOperands(MachineBasicBlock::iterator const MBBI) const {
18741874
}
18751875
}
18761876
if (CCLive) {
1877-
LivePhysRegs LiveRegs(*MBB->getParent()->getSubtarget().getRegisterInfo());
1877+
LiveRegUnits LiveRegs(*MBB->getParent()->getSubtarget().getRegisterInfo());
18781878
LiveRegs.addLiveOuts(*MBB);
1879-
if (LiveRegs.contains(SystemZ::CC))
1879+
if (!LiveRegs.available(SystemZ::CC))
18801880
return false;
18811881
}
18821882

llvm/lib/Target/SystemZ/SystemZShortenInst.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#include "SystemZTargetMachine.h"
16-
#include "llvm/CodeGen/LivePhysRegs.h"
16+
#include "llvm/CodeGen/LiveRegUnits.h"
1717
#include "llvm/CodeGen/MachineFunctionPass.h"
1818
#include "llvm/CodeGen/MachineInstrBuilder.h"
1919
#include "llvm/CodeGen/TargetRegisterInfo.h"
@@ -46,7 +46,7 @@ class SystemZShortenInst : public MachineFunctionPass {
4646

4747
const SystemZInstrInfo *TII;
4848
const TargetRegisterInfo *TRI;
49-
LivePhysRegs LiveRegs;
49+
LiveRegUnits LiveRegs;
5050
};
5151

5252
char SystemZShortenInst::ID = 0;
@@ -88,7 +88,7 @@ bool SystemZShortenInst::shortenIIF(MachineInstr &MI, unsigned LLIxL,
8888
unsigned GR64BitReg =
8989
TRI->getMatchingSuperReg(Reg, thisSubRegIdx, &SystemZ::GR64BitRegClass);
9090
Register OtherReg = TRI->getSubReg(GR64BitReg, otherSubRegIdx);
91-
if (LiveRegs.contains(OtherReg))
91+
if (!LiveRegs.available(OtherReg))
9292
return false;
9393

9494
uint64_t Imm = MI.getOperand(1).getImm();
@@ -143,7 +143,7 @@ bool SystemZShortenInst::shortenOn001(MachineInstr &MI, unsigned Opcode) {
143143
// Calls shortenOn001 if CCLive is false. CC def operand is added in
144144
// case of success.
145145
bool SystemZShortenInst::shortenOn001AddCC(MachineInstr &MI, unsigned Opcode) {
146-
if (!LiveRegs.contains(SystemZ::CC) && shortenOn001(MI, Opcode)) {
146+
if (LiveRegs.available(SystemZ::CC) && shortenOn001(MI, Opcode)) {
147147
MachineInstrBuilder(*MI.getParent()->getParent(), &MI)
148148
.addReg(SystemZ::CC, RegState::ImplicitDefine | RegState::Dead);
149149
return true;

llvm/lib/Target/X86/X86FloatingPoint.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "llvm/ADT/SmallVector.h"
3131
#include "llvm/ADT/Statistic.h"
3232
#include "llvm/CodeGen/EdgeBundles.h"
33-
#include "llvm/CodeGen/LivePhysRegs.h"
33+
#include "llvm/CodeGen/LiveRegUnits.h"
3434
#include "llvm/CodeGen/MachineFunctionPass.h"
3535
#include "llvm/CodeGen/MachineInstrBuilder.h"
3636
#include "llvm/CodeGen/MachineRegisterInfo.h"
@@ -1751,7 +1751,7 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &Inst) {
17511751
void FPS::setKillFlags(MachineBasicBlock &MBB) const {
17521752
const TargetRegisterInfo &TRI =
17531753
*MBB.getParent()->getSubtarget().getRegisterInfo();
1754-
LivePhysRegs LPR(TRI);
1754+
LiveRegUnits LPR(TRI);
17551755

17561756
LPR.addLiveOuts(MBB);
17571757

@@ -1773,14 +1773,14 @@ void FPS::setKillFlags(MachineBasicBlock &MBB) const {
17731773

17741774
if (MO.isDef()) {
17751775
Defs.set(Reg);
1776-
if (!LPR.contains(MO.getReg()))
1776+
if (LPR.available(MO.getReg()))
17771777
MO.setIsDead();
17781778
} else
17791779
Uses.push_back(&MO);
17801780
}
17811781

17821782
for (auto *MO : Uses)
1783-
if (Defs.test(getFPReg(*MO)) || !LPR.contains(MO->getReg()))
1783+
if (Defs.test(getFPReg(*MO)) || LPR.available(MO->getReg()))
17841784
MO->setIsKill();
17851785

17861786
LPR.stepBackward(MI);

llvm/test/CodeGen/Thumb/PR35481.ll

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ define <4 x i32> @f() local_unnamed_addr #0 {
1818
; CHECK-V4T-NEXT: movs r2, #3
1919
; CHECK-V4T-NEXT: movs r3, #4
2020
; CHECK-V4T-NEXT: bl g
21+
; CHECK-V4T-NEXT: ldr r7, [sp, #4]
22+
; CHECK-V4T-NEXT: mov lr, r7
2123
; CHECK-V4T-NEXT: pop {r7}
22-
; CHECK-V4T-NEXT: mov r12, r0
23-
; CHECK-V4T-NEXT: pop {r0}
24-
; CHECK-V4T-NEXT: mov lr, r0
25-
; CHECK-V4T-NEXT: mov r0, r12
24+
; CHECK-V4T-NEXT: add sp, #4
2625
; CHECK-V4T-NEXT: bx lr
2726
;
2827
; CHECK-V8M-LABEL: f:
@@ -36,11 +35,10 @@ define <4 x i32> @f() local_unnamed_addr #0 {
3635
; CHECK-V8M-NEXT: movs r1, #2
3736
; CHECK-V8M-NEXT: movs r2, #3
3837
; CHECK-V8M-NEXT: movs r3, #4
38+
; CHECK-V8M-NEXT: ldr r7, [sp, #4]
39+
; CHECK-V8M-NEXT: mov lr, r7
3940
; CHECK-V8M-NEXT: pop {r7}
40-
; CHECK-V8M-NEXT: mov r12, r0
41-
; CHECK-V8M-NEXT: pop {r0}
42-
; CHECK-V8M-NEXT: mov lr, r0
43-
; CHECK-V8M-NEXT: mov r0, r12
41+
; CHECK-V8M-NEXT: add sp, #4
4442
; CHECK-V8M-NEXT: b g
4543
entry:
4644
%call = tail call i32 @h(i32 1)

0 commit comments

Comments
 (0)