Skip to content

Commit 0f9383f

Browse files
author
Tony Linthicum
committed
Address PR 149367 review comments
1 parent f4e8978 commit 0f9383f

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

llvm/include/llvm/CodeGen/MachineInstrBuilder.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,15 @@ class MachineInstrBuilder {
380380
return *this;
381381
}
382382

383+
/// Inserts the newly-built instruction after the given position in the
384+
/// given MachineBasicBlock.
385+
const MachineInstrBuilder &insertAfter(MachineInstr *MInstr) const {
386+
MachineBasicBlock *MBB = MInstr->getParent();
387+
MachineBasicBlock::iterator I = MInstr->getIterator();
388+
MBB->insertAfter(I, MI);
389+
return *this;
390+
}
391+
383392
bool constrainAllUses(const TargetInstrInfo &TII,
384393
const TargetRegisterInfo &TRI,
385394
const RegisterBankInfo &RBI) const {
@@ -464,20 +473,6 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
464473
return MachineInstrBuilder(MF, MI).copyMIMetadata(MIMD);
465474
}
466475

467-
/// This version of the builder inserts the newly-built instruction after the
468-
/// given position in the given MachineBasicBlock, and does NOT take a
469-
/// destination register.
470-
inline MachineInstrBuilder BuildMIAfter(MachineBasicBlock &BB,
471-
MachineBasicBlock::iterator I,
472-
const MIMetadata &MIMD,
473-
const MCInstrDesc &MCID) {
474-
MachineFunction &MF = *BB.getParent();
475-
MachineInstr *MI = MF.CreateMachineInstr(MCID, MIMD.getDL());
476-
BB.insertAfter(I, MI);
477-
return MachineInstrBuilder(MF, MI)
478-
.copyMIMetadata(MIMD);
479-
}
480-
481476
inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
482477
MachineBasicBlock::instr_iterator I,
483478
const MIMetadata &MIMD,

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,7 @@ bool RewriteScheduleStage::initHeuristics(
19661966
continue;
19671967

19681968
int ReplacementOp = AMDGPU::getMFMASrcCVDstAGPROp(MI.getOpcode());
1969-
assert(ReplacementOp != -1)
1969+
assert(ReplacementOp != -1);
19701970

19711971
RewriteCands.push_back({&MI, MI.getOpcode()});
19721972
MI.setDesc(TII->get(ReplacementOp));
@@ -2256,10 +2256,10 @@ bool RewriteScheduleStage::rewrite(
22562256
// Do not create redundant copies.
22572257
if (ReachingDefCopyMap[Src2Reg].insert(RD).second) {
22582258
MachineInstrBuilder VGPRCopy =
2259-
BuildMIAfter(*RD->getParent(), RD->getIterator(),
2260-
RD->getDebugLoc(), TII->get(TargetOpcode::COPY))
2259+
BuildMI(DAG.MF, RD->getDebugLoc(), TII->get(TargetOpcode::COPY))
22612260
.addDef(MappedReg, 0, 0)
2262-
.addUse(Src2Reg, 0, 0);
2261+
.addUse(Src2Reg, 0, 0)
2262+
.insertAfter(RD);
22632263
DAG.LIS->InsertMachineInstrInMaps(*VGPRCopy);
22642264

22652265
// If this reaching def was the last MI in the region, update the
@@ -2338,10 +2338,10 @@ bool RewriteScheduleStage::rewrite(
23382338
// Do not create reundant copies.
23392339
if (ReachingDefCopyMap[DstReg].insert(RD).second) {
23402340
MachineInstrBuilder VGPRCopy =
2341-
BuildMIAfter(*RD->getParent(), RD->getIterator(),
2342-
RD->getDebugLoc(), TII->get(TargetOpcode::COPY))
2341+
BuildMI(DAG.MF, RD->getDebugLoc(), TII->get(TargetOpcode::COPY))
23432342
.addDef(MappedReg, 0, 0)
2344-
.addUse(DstReg, 0, 0);
2343+
.addUse(DstReg, 0, 0)
2344+
.insertAfter(RD);
23452345
DAG.LIS->InsertMachineInstrInMaps(*VGPRCopy);
23462346

23472347
// If this reaching def was the last MI in the region, update the
@@ -2418,10 +2418,10 @@ bool RewriteScheduleStage::rewrite(
24182418

24192419
// If this UseInst was the first MI in the region, update the region
24202420
// boundaries.
2421-
if (LastMIToRegion.contains(UseInst)) {
2421+
if (FirstMIToRegion.contains(UseInst)) {
24222422
unsigned UpdateRegion = FirstMIToRegion[UseInst];
24232423
DAG.Regions[UpdateRegion].first = VGPRCopy;
2424-
LastMIToRegion.erase(UseInst);
2424+
FirstMIToRegion.erase(UseInst);
24252425
}
24262426

24272427
// Replace the operand for all users.
@@ -2469,6 +2469,8 @@ bool RewriteScheduleStage::rewrite(
24692469
for (unsigned Region = 0; Region < DAG.Regions.size(); Region++)
24702470
DAG.LiveIns[Region] = LiveInUpdater.getLiveRegsForRegionIdx(Region);
24712471

2472+
DAG.Pressure[RegionIdx] = DAG.getRealRegPressure(RegionIdx);
2473+
24722474
return true;
24732475
}
24742476

0 commit comments

Comments
 (0)