@@ -1339,6 +1339,8 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1339
1339
if (History.empty ())
1340
1340
continue ;
1341
1341
1342
+ auto origLocSize = TempDotDebugLocEntries.size ();
1343
+
1342
1344
// This loop was added during upgrade to clang 3.8.1. Upto clang 3.6, each inlined function copy
1343
1345
// got unique version of auto variable metadata nodes. This is because each auto variable had
1344
1346
// "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
1437
1439
// Emit location within the DIE
1438
1440
continue ;
1439
1441
}
1440
- else
1441
- {
1442
- // Emit location to debug_loc
1443
- if (RegVar->getDotDebugLocOffset () == ~0U )
1444
- RegVar->setDotDebugLocOffset (offset);
1445
- }
1446
1442
1447
1443
for (auto range : GenISARange)
1448
1444
{
@@ -1459,6 +1455,13 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1459
1455
const unsigned int lebSize = 8 ;
1460
1456
uint64_t rangeStart = range.first ;
1461
1457
uint64_t rangeEnd = range.second ;
1458
+
1459
+ // Emit location to debug_loc
1460
+ if (RegVar->getDotDebugLocOffset () == ~0U )
1461
+ {
1462
+ RegVar->setDotDebugLocOffset (offset);
1463
+ }
1464
+
1462
1465
write (dotLoc.loc , (unsigned char *)& rangeStart, pointerSize);
1463
1466
write (dotLoc.loc , (unsigned char *)& rangeEnd, pointerSize);
1464
1467
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
1483
1486
auto regNum = Loc.GetRegister ();
1484
1487
m_pModule->getVarInfo (" V" , regNum, varInfo);
1485
1488
1486
- // for (auto genIsaRange : varInfo.lrs)
1487
- if (varInfo.lrs .size () > 0 )
1489
+ for (auto & genIsaRange : varInfo.lrs )
1488
1490
{
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
+ }
1494
1513
1495
1514
write (dotLoc.loc , (unsigned char *)& startRange, pointerSize);
1496
1515
write (dotLoc.loc , (unsigned char *)& endRange, pointerSize);
1497
1516
1498
- if (varInfo .isGRF ())
1517
+ if (genIsaRange .isGRF ())
1499
1518
{
1500
- bool hasSubReg = varInfo .getGRF ().subRegNum != 0 ;
1519
+ bool hasSubReg = genIsaRange .getGRF ().subRegNum != 0 ;
1501
1520
unsigned int subRegSize = 0 , offsetLEB128Size = 0 , sizeLEB128Size = 0 ;
1502
1521
if (hasSubReg)
1503
1522
{
1504
- unsigned int subReg = varInfo .getGRF ().subRegNum ;
1523
+ unsigned int subReg = genIsaRange .getGRF ().subRegNum ;
1505
1524
auto offsetInBits = subReg * 8 ;
1506
1525
auto sizeInBits = (m_pModule->m_pShader ->getGRFSize () * 8 ) - offsetInBits;
1507
1526
offsetLEB128Size = encodeULEB128 (offsetInBits, bufLEB128);
@@ -1510,7 +1529,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1510
1529
subRegSize = sizeof (uint8_t ) + offsetLEB128Size + sizeLEB128Size;
1511
1530
}
1512
1531
1513
- regNum = varInfo .getGRF ().regNum ;
1532
+ regNum = genIsaRange .getGRF ().regNum ;
1514
1533
unsigned int op = llvm::dwarf::DW_OP_breg0;
1515
1534
if (Loc.IsInMemory ())
1516
1535
{
@@ -1558,7 +1577,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1558
1577
1559
1578
if (hasSubReg)
1560
1579
{
1561
- unsigned int subReg = varInfo .getGRF ().subRegNum ;
1580
+ unsigned int subReg = genIsaRange .getGRF ().subRegNum ;
1562
1581
auto offsetInBits = subReg * 8 ;
1563
1582
auto sizeInBits = (m_pModule->m_pShader ->getGRFSize () * 8 ) - offsetInBits;
1564
1583
@@ -1689,7 +1708,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1689
1708
1690
1709
if (Loc.IsVectorized () == false )
1691
1710
{
1692
- unsigned int subRegInBits = varInfo .getGRF ().subRegNum * 8 ;
1711
+ unsigned int subRegInBits = genIsaRange .getGRF ().subRegNum * 8 ;
1693
1712
1694
1713
// Scalar in a subregister
1695
1714
write (dotLoc.loc , (uint8_t )subRegInBits);
@@ -1735,12 +1754,12 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1735
1754
}
1736
1755
}
1737
1756
}
1738
- else if (varInfo .isSpill ())
1757
+ else if (genIsaRange .isSpill ())
1739
1758
{
1740
1759
if (!IGC_IS_FLAG_ENABLED (EnableSIMDLaneDebugging))
1741
1760
{
1742
1761
Address addr;
1743
- addr.Set (Address::Space::eScratch, 0 , varInfo .getSpillOffset ().memoryOffset );
1762
+ addr.Set (Address::Space::eScratch, 0 , genIsaRange .getSpillOffset ().memoryOffset );
1744
1763
1745
1764
unsigned int op = llvm::dwarf::DW_OP_const8u;
1746
1765
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
1761
1780
uint32_t numOfRegs = ((varSizeInReg * (uint32_t )simdWidth) > (grfSize * 8 )) ?
1762
1781
((varSizeInReg * (uint32_t )simdWidth) / (grfSize * 8 )) : 1 ;
1763
1782
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
1765
1784
uint8_t varSizeInBytes = 8 ;
1766
1785
if (varSizeInBits <= 0xFF )
1767
1786
{
@@ -1791,7 +1810,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1791
1810
1792
1811
// Calculate and write size of encodings for all vectors (if vectorized).
1793
1812
uint16_t allVectorsSize = 0 ;
1794
- auto currMemoryOffset = varInfo .getSpillOffset ().memoryOffset ;
1813
+ auto currMemoryOffset = genIsaRange .getSpillOffset ().memoryOffset ;
1795
1814
for (unsigned int vectorElem = 0 ; vectorElem < vectorNumElements; ++vectorElem)
1796
1815
{
1797
1816
if (IGC_IS_FLAG_ENABLED (EnableGTLocationDebugging))
@@ -1812,7 +1831,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1812
1831
1813
1832
write (dotLoc.loc , allVectorsSize);
1814
1833
1815
- currMemoryOffset = varInfo .getSpillOffset ().memoryOffset ;
1834
+ currMemoryOffset = genIsaRange .getSpillOffset ().memoryOffset ;
1816
1835
for (unsigned int vectorElem = 0 ; vectorElem < vectorNumElements; ++vectorElem)
1817
1836
{
1818
1837
if (IGC_IS_FLAG_ENABLED (EnableGTLocationDebugging))
@@ -1828,7 +1847,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1828
1847
else
1829
1848
{
1830
1849
Address addr;
1831
- uint64_t memoryOffset = (uint64_t )varInfo .getSpillOffset ().memoryOffset +
1850
+ uint64_t memoryOffset = (uint64_t )genIsaRange .getSpillOffset ().memoryOffset +
1832
1851
(uint64_t )(vectorElem * numOfRegs * m_pModule->m_pShader ->getGRFSize ());
1833
1852
addr.Set (Address::Space::eScratch, 0 , memoryOffset);
1834
1853
@@ -1859,7 +1878,7 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1859
1878
1860
1879
if (Loc.IsVectorized () == false )
1861
1880
{
1862
- unsigned int subRegInBits = varInfo .getGRF ().subRegNum * 8 ;
1881
+ unsigned int subRegInBits = genIsaRange .getGRF ().subRegNum * 8 ;
1863
1882
1864
1883
// Scalar in a subregister
1865
1884
write (dotLoc.loc , (uint8_t )subRegInBits);
@@ -1909,12 +1928,18 @@ void DwarfDebug::collectVariableInfo(const Function* MF, SmallPtrSet<const MDNod
1909
1928
RegVar->getDecorations ().append (" u " );
1910
1929
}
1911
1930
}
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
+ }
1914
1936
}
1915
1937
}
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
+ }
1918
1943
1919
1944
#if 0
1920
1945
// Simplify ranges that are fully coalesced.
0 commit comments