Skip to content

Commit ca72b0a

Browse files
committed
[CodeGen] Use the TII hook for Noop insertion in BBSections (NFC)
Refactor BasicBlockSections to use the target-specific noop insertion hook from TargetInstrInfo instead of building it ourselves. Using the TII hook is both cleaner and makes it easier to extend BBSections to non-X86 targets. Differential Revision: https://reviews.llvm.org/D158303
1 parent 67b71ad commit ca72b0a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

llvm/lib/CodeGen/BasicBlockSections.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ void llvm::avoidZeroOffsetLandingPad(MachineFunction &MF) {
285285
MachineBasicBlock::iterator MI = MBB.begin();
286286
while (!MI->isEHLabel())
287287
++MI;
288-
MCInst Nop = MF.getSubtarget().getInstrInfo()->getNop();
289-
BuildMI(MBB, MI, DebugLoc(),
290-
MF.getSubtarget().getInstrInfo()->get(Nop.getOpcode()));
288+
MF.getSubtarget().getInstrInfo()->insertNoop(MBB, MI);
291289
}
292290
}
293291
}

llvm/lib/Target/X86/X86InstrInfo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8443,6 +8443,12 @@ void X86InstrInfo::setExecutionDomain(MachineInstr &MI, unsigned Domain) const {
84438443
MI.setDesc(get(table[Domain - 1]));
84448444
}
84458445

8446+
void X86InstrInfo::insertNoop(MachineBasicBlock &MBB,
8447+
MachineBasicBlock::iterator MI) const {
8448+
DebugLoc DL;
8449+
BuildMI(MBB, MI, DL, get(X86::NOOP));
8450+
}
8451+
84468452
/// Return the noop instruction to use for a noop.
84478453
MCInst X86InstrInfo::getNop() const {
84488454
MCInst Nop;

llvm/lib/Target/X86/X86InstrInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ class X86InstrInfo final : public X86GenInstrInfo {
457457
int64_t Offset2,
458458
unsigned NumLoads) const override;
459459

460+
void insertNoop(MachineBasicBlock &MBB,
461+
MachineBasicBlock::iterator MI) const override;
462+
460463
MCInst getNop() const override;
461464

462465
bool

0 commit comments

Comments
 (0)