14 changes: 7 additions & 7 deletions llvm/lib/CodeGen/RegisterPressure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ void RegPressureTracker::bumpDeadDefs(ArrayRef<RegisterMaskPair> DeadDefs) {
/// instruction independent of liveness.
void RegPressureTracker::recede(const RegisterOperands &RegOpers,
SmallVectorImpl<RegisterMaskPair> *LiveUses) {
assert(!CurrPos->isDebugInstr());
assert(!CurrPos->isDebugOrPseudoInstr());

// Boost pressure for all dead defs together.
bumpDeadDefs(RegOpers.DeadDefs);
Expand Down Expand Up @@ -863,7 +863,7 @@ void RegPressureTracker::recedeSkipDebugValues() {
CurrPos = prev_nodbg(CurrPos, MBB->begin());

SlotIndex SlotIdx;
if (RequireIntervals && !CurrPos->isDebugInstr())
if (RequireIntervals && !CurrPos->isDebugOrPseudoInstr())
SlotIdx = LIS->getInstructionIndex(*CurrPos).getRegSlot();

// Open the top of the region using slot indexes.
Expand All @@ -873,9 +873,9 @@ void RegPressureTracker::recedeSkipDebugValues() {

void RegPressureTracker::recede(SmallVectorImpl<RegisterMaskPair> *LiveUses) {
recedeSkipDebugValues();
if (CurrPos->isDebugValue()) {
// It's possible to only have debug_value instructions and hit the start of
// the block.
if (CurrPos->isDebugValue() || CurrPos->isPseudoProbe()) {
// It's possible to only have debug_value and pseudo probe instructions and
// hit the start of the block.
assert(CurrPos == MBB->begin());
return;
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ static void computeMaxPressureDelta(ArrayRef<unsigned> OldMaxPressureVec,
/// This is intended for speculative queries. It leaves pressure inconsistent
/// with the current position, so must be restored by the caller.
void RegPressureTracker::bumpUpwardPressure(const MachineInstr *MI) {
assert(!MI->isDebugInstr() && "Expect a nondebug instruction.");
assert(!MI->isDebugOrPseudoInstr() && "Expect a nondebug instruction.");

SlotIndex SlotIdx;
if (RequireIntervals)
Expand Down Expand Up @@ -1282,7 +1282,7 @@ LaneBitmask RegPressureTracker::getLiveThroughAt(Register RegUnit,
/// This is intended for speculative queries. It leaves pressure inconsistent
/// with the current position, so must be restored by the caller.
void RegPressureTracker::bumpDownwardPressure(const MachineInstr *MI) {
assert(!MI->isDebugInstr() && "Expect a nondebug instruction.");
assert(!MI->isDebugOrPseudoInstr() && "Expect a nondebug instruction.");

SlotIndex SlotIdx;
if (RequireIntervals)
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/RegisterScavenging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void RegScavenger::forward() {
I.Restore = nullptr;
}

if (MI.isDebugInstr())
if (MI.isDebugOrPseudoInstr())
return;

determineKillsAndDefs();
Expand Down Expand Up @@ -298,7 +298,7 @@ Register RegScavenger::findSurvivorReg(MachineBasicBlock::iterator StartMI,

bool inVirtLiveRange = false;
for (++MI; InstrLimit > 0 && MI != ME; ++MI, --InstrLimit) {
if (MI->isDebugInstr()) {
if (MI->isDebugOrPseudoInstr()) {
++InstrLimit; // Don't count debug instructions
continue;
}
Expand Down
11 changes: 7 additions & 4 deletions llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void ScheduleDAGInstrs::addVRegDefDeps(SUnit *SU, unsigned OperIdx) {
/// TODO: Handle ExitSU "uses" properly.
void ScheduleDAGInstrs::addVRegUseDeps(SUnit *SU, unsigned OperIdx) {
const MachineInstr *MI = SU->getInstr();
assert(!MI->isDebugInstr());
assert(!MI->isDebugOrPseudoInstr());

const MachineOperand &MO = MI->getOperand(OperIdx);
Register Reg = MO.getReg();
Expand Down Expand Up @@ -572,7 +572,7 @@ void ScheduleDAGInstrs::initSUnits() {
SUnits.reserve(NumRegionInstrs);

for (MachineInstr &MI : make_range(RegionBegin, RegionEnd)) {
if (MI.isDebugInstr())
if (MI.isDebugOrPseudoInstr())
continue;

SUnit *SU = newSUnit(&MI);
Expand Down Expand Up @@ -814,6 +814,9 @@ void ScheduleDAGInstrs::buildSchedGraph(AAResults *AA,
if (MI.isDebugLabel())
continue;

if (MI.isPseudoProbe())
continue;

SUnit *SU = MISUnitMap[&MI];
assert(SU && "No SUnit mapped to this MI");

Expand Down Expand Up @@ -1117,7 +1120,7 @@ void ScheduleDAGInstrs::fixupKills(MachineBasicBlock &MBB) {

// Examine block from end to start...
for (MachineInstr &MI : make_range(MBB.rbegin(), MBB.rend())) {
if (MI.isDebugInstr())
if (MI.isDebugOrPseudoInstr())
continue;

// Update liveness. Registers that are defed but not used in this
Expand Down Expand Up @@ -1152,7 +1155,7 @@ void ScheduleDAGInstrs::fixupKills(MachineBasicBlock &MBB) {
while (I->isBundledWithSucc())
++I;
do {
if (!I->isDebugInstr())
if (!I->isDebugOrPseudoInstr())
toggleKills(MRI, LiveRegs, *I, true);
--I;
} while (I != Bundle);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SlotIndexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
SlotIndex blockStartIndex(&indexList.back(), SlotIndex::Slot_Block);

for (MachineInstr &MI : MBB) {
if (MI.isDebugInstr())
if (MI.isDebugOrPseudoInstr())
continue;

// Insert a store index for the instr.
Expand Down Expand Up @@ -241,7 +241,7 @@ void SlotIndexes::repairIndexesInRange(MachineBasicBlock *MBB,
for (MachineBasicBlock::iterator I = End; I != Begin;) {
--I;
MachineInstr &MI = *I;
if (!MI.isDebugInstr() && mi2iMap.find(&MI) == mi2iMap.end())
if (!MI.isDebugOrPseudoInstr() && mi2iMap.find(&MI) == mi2iMap.end())
insertMachineInstrInMaps(MI);
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SplitKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ void SplitEditor::removeBackCopies(SmallVectorImpl<VNInfo*> &Copies) {
MachineBasicBlock::iterator MBBI(MI);
bool AtBegin;
do AtBegin = MBBI == MBB->begin();
while (!AtBegin && (--MBBI)->isDebugInstr());
while (!AtBegin && (--MBBI)->isDebugOrPseudoInstr());

LLVM_DEBUG(dbgs() << "Removing " << Def << '\t' << *MI);
LIS.removeVRegDefAt(*LI, Def);
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/Transforms/SampleProfile/pseudo-probe-slotindex.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; REQUIRES: x86_64-linux
; RUN: llc -print-after=slotindexes -stop-after=slotindexes -mtriple=x86_64-- %s -filetype=asm -o %t 2>&1 | FileCheck %s

define void @foo(i32* %p) {
store i32 0, i32* %p
call void @llvm.pseudoprobe(i64 5116412291814990879, i64 1, i32 0, i64 -1)
store i32 0, i32* %p
ret void
}

;; Check the pseudo probe instruction isn't assigned a slot index.
;CHECK: IR Dump {{.*}}
;CHECK: # Machine code for function foo{{.*}}
;CHECK: {{[0-9]+}}B bb.0 (%ir-block.0)
;CHECK: {{[0-9]+}}B %0:gr64 = COPY killed $rdi
;CHECK: {{^}} PSEUDO_PROBE 5116412291814990879
;CHECK: {{[0-9]+}}B MOV32mi
;CHECK: {{[0-9]+}}B RET 0

declare void @llvm.pseudoprobe(i64, i64, i32, i64) #0

attributes #0 = { inaccessiblememonly nounwind willreturn }