Skip to content

Commit bfa9646

Browse files
pratikasharsys_zuul
authored andcommitted
Skip marking source variables with Output attribute. Some cleanup.
Change-Id: I5d88a8cc8d2424faba5af3133c5ac62eedaafd89
1 parent 85ec4fc commit bfa9646

File tree

5 files changed

+104
-70
lines changed

5 files changed

+104
-70
lines changed

IGC/Compiler/CISACodeGen/DebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void DebugInfoData::markOutputVars(const llvm::Instruction* pInst)
280280
// values anywhere in the code till they are in scope.
281281
if (m_outputVals.find(pVar) == m_outputVals.end())
282282
{
283-
m_pShader->GetEncoder().GetVISAKernel()->AddAttributeToVar(pVar->visaGenVariable[0], "Output", 0, nullptr);
283+
//m_pShader->GetEncoder().GetVISAKernel()->AddAttributeToVar(pVar->visaGenVariable[0], "Output", 0, nullptr);
284284
(void)m_outputVals.insert(pVar);
285285
}
286286
}

IGC/Compiler/DebugInfo/DwarfCompileUnit.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ void CompileUnit::addSourceLine(DIE * Die, DINamespace * NS)
402402
}
403403
#endif
404404

405+
void CompileUnit::addRegisterLoc(DIEBlock* TheDie, unsigned DWReg, int64_t Offset, const llvm::Instruction* dbgInst)
406+
{
407+
if (isa<llvm::DbgDeclareInst>(dbgInst))
408+
addRegisterOffset(TheDie, DWReg, Offset);
409+
else
410+
addRegisterOp(TheDie, DWReg);
411+
}
412+
405413
/// addRegisterOp - Add register operand.
406414
void CompileUnit::addRegisterOp(DIEBlock* TheDie, unsigned DWReg)
407415
{
@@ -892,7 +900,7 @@ void CompileUnit::addBindlessSamplerLocation(DIEBlock* Block, VISAVariableLocati
892900
// of variable
893901
void CompileUnit::addScratchLocation(DIEBlock* Block, DbgDecoder::VarInfo* varInfo, int32_t vectorOffset)
894902
{
895-
uint32_t offset = varInfo->getSpillOffset().memoryOffset + vectorOffset;
903+
uint32_t offset = varInfo->lrs.front().getSpillOffset().memoryOffset + vectorOffset;
896904

897905
if (IGC_IS_FLAG_ENABLED(EnableGTLocationDebugging))
898906
{
@@ -1984,10 +1992,13 @@ void CompileUnit::buildSLM(DbgVariable& var, DIE* die, VISAVariableLocation* loc
19841992
auto regNum = loc->GetRegister();
19851993
VISAMod->getVarInfo("V", regNum, varInfo);
19861994

1995+
if (varInfo.lrs.size() == 0)
1996+
return;
1997+
19871998
Address addr;
19881999
addr.Set(Address::Space::eLocal, 0, 0);
19892000

1990-
addRegisterOffset(Block, varInfo.getGRF().regNum, 0);
2001+
addRegisterLoc(Block, varInfo.lrs.front().getGRF().regNum, 0, var.getDbgInst());
19912002

19922003
addUInt(Block, dwarf::DW_FORM_data1, dwarf::DW_OP_deref_size);
19932004
addUInt(Block, dwarf::DW_FORM_data1, 4);
@@ -2054,18 +2065,21 @@ void CompileUnit::buildGeneral(DbgVariable& var, DIE* die, VISAVariableLocation*
20542065
auto VISAMod = const_cast<VISAModule*>(loc->GetVISAModule());
20552066
VISAMod->getVarInfo("V", regNum, varInfo);
20562067

2057-
if (varInfo.isGRF())
2068+
if (varInfo.lrs.size() == 0)
2069+
return;
2070+
2071+
if (varInfo.lrs.front().isGRF())
20582072
{
20592073
DIEBlock* Block = new (DIEValueAllocator)DIEBlock();
2060-
uint16_t regNum = varInfo.getGRF().regNum;
2074+
uint16_t regNum = varInfo.lrs.front().getGRF().regNum;
20612075

20622076
if (!IGC_IS_FLAG_ENABLED(EnableSIMDLaneDebugging))
20632077
{
2064-
addRegisterOffset(Block, varInfo.getGRF().regNum, 0);
2078+
addRegisterLoc(Block, varInfo.lrs.front().getGRF().regNum, 0, var.getDbgInst());
20652079

2066-
if (varInfo.getGRF().subRegNum != 0)
2080+
if (varInfo.lrs.front().getGRF().subRegNum != 0)
20672081
{
2068-
unsigned int subReg = varInfo.getGRF().subRegNum;
2082+
unsigned int subReg = varInfo.lrs.front().getGRF().subRegNum;
20692083
auto offsetInBits = subReg * 8;
20702084
auto sizeInBits = (VISAMod->m_pShader->getGRFSize() * 8) - offsetInBits;
20712085

@@ -2080,8 +2094,8 @@ void CompileUnit::buildGeneral(DbgVariable& var, DIE* die, VISAVariableLocation*
20802094

20812095
if (loc->IsVectorized() == false)
20822096
{
2083-
unsigned int subReg = varInfo.getGRF().subRegNum;
2084-
addRegisterOffset(Block, regNum, 0);
2097+
unsigned int subReg = varInfo.lrs.front().getGRF().subRegNum;
2098+
addRegisterLoc(Block, regNum, 0, var.getDbgInst());
20852099

20862100
addGTRelativeLocation(Block, loc); // Emit GT-relative location expression
20872101

@@ -2097,7 +2111,7 @@ void CompileUnit::buildGeneral(DbgVariable& var, DIE* die, VISAVariableLocation*
20972111

20982112
for (unsigned int vectorElem = 0; vectorElem < loc->GetVectorNumElements(); ++vectorElem)
20992113
{
2100-
addRegisterOffset(Block, regNum, 0);
2114+
addRegisterLoc(Block, regNum, 0, var.getDbgInst());
21012115

21022116
addGTRelativeLocation(Block, loc); // Emit GT-relative location expression
21032117

@@ -2111,15 +2125,15 @@ void CompileUnit::buildGeneral(DbgVariable& var, DIE* die, VISAVariableLocation*
21112125

21122126
addBlock(die, dwarf::DW_AT_location, Block);
21132127
}
2114-
else if (varInfo.isSpill())
2128+
else if (varInfo.lrs.front().isSpill())
21152129
{
21162130
// handle spill
21172131
DIEBlock* Block = new (DIEValueAllocator)DIEBlock();
21182132

21192133
if (!IGC_IS_FLAG_ENABLED(EnableSIMDLaneDebugging))
21202134
{
21212135
Address addr;
2122-
addr.Set(Address::Space::eScratch, 0, varInfo.getSpillOffset().memoryOffset);
2136+
addr.Set(Address::Space::eScratch, 0, varInfo.lrs.front().getSpillOffset().memoryOffset);
21232137

21242138
addUInt(Block, dwarf::DW_FORM_data1, dwarf::DW_OP_const8u);
21252139
addUInt(Block, dwarf::DW_FORM_data8, addr.GetAddress());
@@ -2145,7 +2159,7 @@ void CompileUnit::buildGeneral(DbgVariable& var, DIE* die, VISAVariableLocation*
21452159
}
21462160
else
21472161
{
2148-
IGC_ASSERT_MESSAGE(false, "\nVariable neither in GRF nor spilled\n");
2162+
//IGC_ASSERT_MESSAGE(false, "\nVariable neither in GRF nor spilled\n");
21492163
}
21502164

21512165
}

IGC/Compiler/DebugInfo/DwarfCompileUnit.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ namespace IGC
235235
/// addTemplateParams - Add template parameters in buffer.
236236
void addTemplateParams(DIE& Buffer, llvm::DINodeArray TParams);
237237

238+
/// addRegisterLoc - Decide whether to emit regx or bregx
239+
void addRegisterLoc(DIEBlock* TheDie, unsigned DWReg, int64_t Offset, const llvm::Instruction* dbgInst);
240+
238241
/// addRegisterOp - Add register operand.
239242
void addRegisterOp(DIEBlock* TheDie, unsigned Reg);
240243

IGC/Compiler/DebugInfo/DwarfDebug.cpp

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,8 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
13391339
if (History.empty())
13401340
continue;
13411341

1342+
auto origLocSize = TempDotDebugLocEntries.size();
1343+
13421344
// This loop was added during upgrade to clang 3.8.1. Upto clang 3.6, each inlined function copy
13431345
// got unique version of auto variable metadata nodes. This is because each auto variable had
13441346
// "inlinedAt" field as part of its metadata. With clang 3.8.1, inlinedAt field is no
@@ -1437,12 +1439,6 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
14371439
// Emit location within the DIE
14381440
continue;
14391441
}
1440-
else
1441-
{
1442-
// Emit location to debug_loc
1443-
if (RegVar->getDotDebugLocOffset() == ~0U)
1444-
RegVar->setDotDebugLocOffset(offset);
1445-
}
14461442

14471443
for (auto range : GenISARange)
14481444
{
@@ -1459,6 +1455,13 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
14591455
const unsigned int lebSize = 8;
14601456
uint64_t rangeStart = range.first;
14611457
uint64_t rangeEnd = range.second;
1458+
1459+
// Emit location to debug_loc
1460+
if (RegVar->getDotDebugLocOffset() == ~0U)
1461+
{
1462+
RegVar->setDotDebugLocOffset(offset);
1463+
}
1464+
14621465
write(dotLoc.loc, (unsigned char*)& rangeStart, pointerSize);
14631466
write(dotLoc.loc, (unsigned char*)& rangeEnd, pointerSize);
14641467
write(dotLoc.loc, (uint16_t)(sizeof(uint8_t) + sizeof(const unsigned char) + lebSize));
@@ -1483,25 +1486,41 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
14831486
auto regNum = Loc.GetRegister();
14841487
m_pModule->getVarInfo("V", regNum, varInfo);
14851488

1486-
//for (auto genIsaRange : varInfo.lrs)
1487-
if (varInfo.lrs.size() > 0)
1489+
for (auto& genIsaRange : varInfo.lrs)
14881490
{
1489-
// Assume that VISA vars are marked with Output
1490-
// atttribute. This also guarantees same storage
1491-
// location for all sub-sets of varInfo.lrs.
1492-
uint64_t startRange = range.first; //varInfo.lrs.front().start;
1493-
uint64_t endRange = range.second; //varInfo.lrs.back().end;
1491+
auto startIt = m_pModule->VISAIndexToAllGenISAOff.find(genIsaRange.start);
1492+
if (startIt == m_pModule->VISAIndexToAllGenISAOff.end())
1493+
continue;
1494+
uint64_t startRange = (*startIt).second.front();
1495+
auto endIt = m_pModule->VISAIndexToAllGenISAOff.find(genIsaRange.end);
1496+
if (endIt == m_pModule->VISAIndexToAllGenISAOff.end())
1497+
continue;
1498+
uint64_t endRange = (*endIt).second.back();
1499+
1500+
if (endRange < range.first)
1501+
continue;
1502+
if (startRange > range.second)
1503+
continue;
1504+
1505+
startRange = std::max(startRange, (uint64_t)range.first);
1506+
endRange = std::min(endRange, (uint64_t)range.second);
1507+
1508+
// Emit location to debug_loc
1509+
if (RegVar->getDotDebugLocOffset() == ~0U)
1510+
{
1511+
RegVar->setDotDebugLocOffset(offset);
1512+
}
14941513

14951514
write(dotLoc.loc, (unsigned char*)& startRange, pointerSize);
14961515
write(dotLoc.loc, (unsigned char*)& endRange, pointerSize);
14971516

1498-
if (varInfo.isGRF())
1517+
if (genIsaRange.isGRF())
14991518
{
1500-
bool hasSubReg = varInfo.getGRF().subRegNum != 0;
1519+
bool hasSubReg = genIsaRange.getGRF().subRegNum != 0;
15011520
unsigned int subRegSize = 0, offsetLEB128Size = 0, sizeLEB128Size = 0;
15021521
if (hasSubReg)
15031522
{
1504-
unsigned int subReg = varInfo.getGRF().subRegNum;
1523+
unsigned int subReg = genIsaRange.getGRF().subRegNum;
15051524
auto offsetInBits = subReg * 8;
15061525
auto sizeInBits = (m_pModule->m_pShader->getGRFSize() * 8) - offsetInBits;
15071526
offsetLEB128Size = encodeULEB128(offsetInBits, bufLEB128);
@@ -1510,7 +1529,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
15101529
subRegSize = sizeof(uint8_t) + offsetLEB128Size + sizeLEB128Size;
15111530
}
15121531

1513-
regNum = varInfo.getGRF().regNum;
1532+
regNum = genIsaRange.getGRF().regNum;
15141533
unsigned int op = llvm::dwarf::DW_OP_breg0;
15151534
if (Loc.IsInMemory())
15161535
{
@@ -1558,7 +1577,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
15581577

15591578
if (hasSubReg)
15601579
{
1561-
unsigned int subReg = varInfo.getGRF().subRegNum;
1580+
unsigned int subReg = genIsaRange.getGRF().subRegNum;
15621581
auto offsetInBits = subReg * 8;
15631582
auto sizeInBits = (m_pModule->m_pShader->getGRFSize() * 8) - offsetInBits;
15641583

@@ -1689,7 +1708,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
16891708

16901709
if (Loc.IsVectorized() == false)
16911710
{
1692-
unsigned int subRegInBits = varInfo.getGRF().subRegNum * 8;
1711+
unsigned int subRegInBits = genIsaRange.getGRF().subRegNum * 8;
16931712

16941713
// Scalar in a subregister
16951714
write(dotLoc.loc, (uint8_t)subRegInBits);
@@ -1735,12 +1754,12 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
17351754
}
17361755
}
17371756
}
1738-
else if (varInfo.isSpill())
1757+
else if (genIsaRange.isSpill())
17391758
{
17401759
if (!IGC_IS_FLAG_ENABLED(EnableSIMDLaneDebugging))
17411760
{
17421761
Address addr;
1743-
addr.Set(Address::Space::eScratch, 0, varInfo.getSpillOffset().memoryOffset);
1762+
addr.Set(Address::Space::eScratch, 0, genIsaRange.getSpillOffset().memoryOffset);
17441763

17451764
unsigned int op = llvm::dwarf::DW_OP_const8u;
17461765
write(dotLoc.loc, (uint16_t)(sizeof(uint8_t) + sizeof(uint64_t) + sizeof(uint8_t)));
@@ -1761,7 +1780,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
17611780
uint32_t numOfRegs = ((varSizeInReg * (uint32_t)simdWidth) > (grfSize * 8)) ?
17621781
((varSizeInReg * (uint32_t)simdWidth) / (grfSize * 8)) : 1;
17631782
auto lebsizeScratchBaseAddr = encodeULEB128(scratchBaseAddr, bufLEB128); // Address for bregx
1764-
auto lebsizeScratchOffset = encodeULEB128(varInfo.getSpillOffset().memoryOffset, bufLEB128); // Offset for bregx
1783+
auto lebsizeScratchOffset = encodeULEB128(genIsaRange.getSpillOffset().memoryOffset, bufLEB128); // Offset for bregx
17651784
uint8_t varSizeInBytes = 8;
17661785
if (varSizeInBits <= 0xFF)
17671786
{
@@ -1791,7 +1810,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
17911810

17921811
// Calculate and write size of encodings for all vectors (if vectorized).
17931812
uint16_t allVectorsSize = 0;
1794-
auto currMemoryOffset = varInfo.getSpillOffset().memoryOffset;
1813+
auto currMemoryOffset = genIsaRange.getSpillOffset().memoryOffset;
17951814
for (unsigned int vectorElem = 0; vectorElem < vectorNumElements; ++vectorElem)
17961815
{
17971816
if (IGC_IS_FLAG_ENABLED(EnableGTLocationDebugging))
@@ -1812,7 +1831,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
18121831

18131832
write(dotLoc.loc, allVectorsSize);
18141833

1815-
currMemoryOffset = varInfo.getSpillOffset().memoryOffset;
1834+
currMemoryOffset = genIsaRange.getSpillOffset().memoryOffset;
18161835
for (unsigned int vectorElem = 0; vectorElem < vectorNumElements; ++vectorElem)
18171836
{
18181837
if (IGC_IS_FLAG_ENABLED(EnableGTLocationDebugging))
@@ -1828,7 +1847,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
18281847
else
18291848
{
18301849
Address addr;
1831-
uint64_t memoryOffset = (uint64_t)varInfo.getSpillOffset().memoryOffset +
1850+
uint64_t memoryOffset = (uint64_t)genIsaRange.getSpillOffset().memoryOffset +
18321851
(uint64_t)(vectorElem * numOfRegs * m_pModule->m_pShader->getGRFSize());
18331852
addr.Set(Address::Space::eScratch, 0, memoryOffset);
18341853

@@ -1859,7 +1878,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
18591878

18601879
if (Loc.IsVectorized() == false)
18611880
{
1862-
unsigned int subRegInBits = varInfo.getGRF().subRegNum * 8;
1881+
unsigned int subRegInBits = genIsaRange.getGRF().subRegNum * 8;
18631882

18641883
// Scalar in a subregister
18651884
write(dotLoc.loc, (uint8_t)subRegInBits);
@@ -1909,12 +1928,18 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
19091928
RegVar->getDecorations().append("u ");
19101929
}
19111930
}
1912-
offset += dotLoc.loc.size();
1913-
TempDotDebugLocEntries.push_back(dotLoc);
1931+
if (RegVar->getDotDebugLocOffset() != ~0U)
1932+
{
1933+
offset += dotLoc.loc.size();
1934+
TempDotDebugLocEntries.push_back(dotLoc);
1935+
}
19141936
}
19151937
}
1916-
TempDotDebugLocEntries.push_back(DotDebugLocEntry());
1917-
offset += pointerSize * 2;
1938+
if (TempDotDebugLocEntries.size() > origLocSize)
1939+
{
1940+
TempDotDebugLocEntries.push_back(DotDebugLocEntry());
1941+
offset += pointerSize * 2;
1942+
}
19181943

19191944
#if 0
19201945
// Simplify ranges that are fully coalesced.

0 commit comments

Comments
 (0)