Skip to content

Commit cc39998

Browse files
pratikasharigcbot
authored andcommitted
Debug info emission fix when scratch offset is encoded
in LSC message Teach VISA debug info emission to emit scratch offset when it's directly embedded in LSC message.
1 parent fdc4334 commit cc39998

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

visa/DebugInfo.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,10 +1991,12 @@ void SaveRestoreManager::addInst(G4_INST *inst) {
19911991
srInfo[srInfo.size() - 2].saveRestoreMap;
19921992
}
19931993

1994+
auto *kernel = visaKernel->getKernel();
1995+
19941996
if (inst->opcode() == G4_add && inst->getSrc(1) && inst->getSrc(1)->isImm() &&
19951997
inst->getSrc(0) && inst->getSrc(0)->isSrcRegRegion() &&
19961998
GetTopDclFromRegRegion(inst->getSrc(0)) ==
1997-
visaKernel->getKernel()->fg.builder->getBEFP()) {
1999+
kernel->fg.builder->getBEFP()) {
19982000
memOffset = (int32_t)inst->getSrc(1)->asImm()->getImm();
19992001
regWithMemOffset =
20002002
inst->getDst()->getLinearizedStart() / builder.numEltPerGRF<Type_UB>();
@@ -2011,6 +2013,29 @@ void SaveRestoreManager::addInst(G4_INST *inst) {
20112013
absOffset = true;
20122014
}
20132015

2016+
if (inst->isSend()) {
2017+
auto *sendInst = inst->asSendInst();
2018+
if (GlobalRA::LSCUsesImmOff(*kernel->fg.builder) &&
2019+
sendInst->getMsgDesc()->isLSC() && sendInst->getMsgDescRaw() &&
2020+
sendInst->getMsgDescRaw()->getLscAddrType() == LSC_ADDR_TYPE_SS &&
2021+
(inst->getSrc(0)->getLinearizedStart() /
2022+
builder.numEltPerGRF<Type_UB>()) ==
2023+
kernel->stackCall.getSpillHeaderGRF()) {
2024+
// Spill offset is inlined in LSC message as:
2025+
// GlobalRA::SPILL_FILL_IMMOFF_MAX + Inlined offset in LSC
2026+
auto maxSpillFillImmOffMax = GlobalRA::SPILL_FILL_IMMOFF_MAX;
2027+
2028+
auto msgDesc = inst->asSendInst()->getMsgDesc();
2029+
auto off = msgDesc->getOffset();
2030+
if (off) {
2031+
memOffset = (maxSpillFillImmOffMax + off.value().immOff);
2032+
absOffset = false;
2033+
regWithMemOffset = inst->getSrc(0)->getLinearizedStart() /
2034+
builder.numEltPerGRF<Type_UB>();
2035+
}
2036+
}
2037+
}
2038+
20142039
srInfo.back().update(inst, memOffset, regWithMemOffset, absOffset);
20152040
}
20162041

visa/GraphColor.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10954,17 +10954,7 @@ int GlobalRA::coloringRegAlloc() {
1095410954
// b. Spill size exceeds what can be represented using hword msg on PVC+
1095510955
// c. Xe2+ requires LSC stack (can force on DG2+ via -lscNonStackSpill)
1095610956
if (builder.supportsLSC()) {
10957-
10958-
const auto scratchAddrType = VISA_LSC_IMMOFF_ADDR_TYPE_SS;
10959-
const uint32_t immOffOpts =
10960-
builder.getuint32Option(vISA_lscEnableImmOffsFor);
10961-
canUseLscImmediateOffsetSpillFill =
10962-
// HW supports it
10963-
builder.getPlatform() >= Xe2 &&
10964-
// the spill/fill is enabled in options
10965-
(immOffOpts & (1 << VISA_LSC_IMMOFF_SPILL_FILL)) != 0 &&
10966-
// address type is also enabled in options
10967-
(immOffOpts & (1 << scratchAddrType)) != 0;
10957+
canUseLscImmediateOffsetSpillFill = LSCUsesImmOff(builder);
1096810958
}
1096910959

1097010960
stackCallSaveRestore(hasStackCall);

visa/GraphColor.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,23 @@ class GlobalRA {
13481348

13491349
const bool use4GRFAlign = false;
13501350

1351+
// [-2^16...2^16) in bytes
1352+
// (frame pointer is biased 2^16 so that -2^16 references scratch[0x0])
1353+
static constexpr unsigned SPILL_FILL_IMMOFF_MAX = 0x10000; // 64k
1354+
1355+
static bool LSCUsesImmOff(IR_Builder &builder) {
1356+
const auto scratchAddrType = VISA_LSC_IMMOFF_ADDR_TYPE_SS;
1357+
const uint32_t immOffOpts =
1358+
builder.getuint32Option(vISA_lscEnableImmOffsFor);
1359+
return
1360+
// HW supports it
1361+
builder.getPlatform() >= Xe2 &&
1362+
// the spill/fill is enabled in options
1363+
(immOffOpts & (1 << VISA_LSC_IMMOFF_SPILL_FILL)) != 0 &&
1364+
// address type is also enabled in options
1365+
(immOffOpts & (1 << scratchAddrType)) != 0;
1366+
}
1367+
13511368
private:
13521369
template <class REGION_TYPE>
13531370
static unsigned getRegionDisp(REGION_TYPE *region, const IR_Builder &irb);
@@ -1392,10 +1409,6 @@ class GlobalRA {
13921409
// store instructions that shouldnt be rematerialized.
13931410
std::unordered_set<G4_INST *> dontRemat;
13941411

1395-
// [-2^16...2^16) in bytes
1396-
// (frame pointer is biased 2^16 so that -2^16 references scratch[0x0])
1397-
static constexpr unsigned SPILL_FILL_IMMOFF_MAX = 0x10000; // 64k
1398-
13991412
// map each BB to its local RA GRF usage summary, populated in local RA.
14001413
std::map<G4_BB *, PhyRegSummary *> bbLocalRAMap;
14011414
llvm::SpecificBumpPtrAllocator<PhyRegSummary> PRSAlloc;

0 commit comments

Comments
 (0)