Skip to content

Commit f1f04ad

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: d08d9ce: [DebugInfo] Only emit stack value at the end of SIMD32 exprs
Since our emitter splits SIMD32 programs into SIMD16 subprograms, we should adapt the debug info by only emitting `DW_OP_stack_value` at the end of the source variable's DI Block, i.e. after the merge point that follows the upper SIMD16 register. The approach is to note the information about the split in an `IGC::DbgVariable` instance when generating the upper register variable. Potentially, we could also consider checking for the presence of `DW_OP_skip` when evaluating the DI expression, however it would seem less future-proof in case of future use cases for skips. The change is accompanied by minor in-place refactoring where appropriate.
1 parent aebad78 commit f1f04ad

File tree

5 files changed

+30
-163
lines changed

5 files changed

+30
-163
lines changed

IGC/DebugInfo/DwarfCompileUnit.cpp

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ IGC::DIE *CompileUnit::constructVariableDIE(DbgVariable &DV,
22572257

22582258
// Check if variable is described by a DBG_VALUE instruction.
22592259
const Instruction *pDbgInst = DV.getDbgInst();
2260-
if (!pDbgInst || !DV.currentLocationIsInlined()) {
2260+
if (!pDbgInst || !DV.isLocationInlined) {
22612261
DV.setDIE(VariableDie);
22622262
LLVM_DEBUG(dbgs() << " done. No dbg.inst assotiated\n");
22632263
return VariableDie;
@@ -2603,7 +2603,8 @@ bool CompileUnit::buildFpBasedLoc(const DbgVariable &var, IGC::DIEBlock *Block,
26032603
}
26042604

26052605
bool CompileUnit::buildSlicedLoc(
2606-
DbgVariable &var, IGC::DIEBlock *Block, const VISAVariableLocation &loc,
2606+
const DbgVariable &var, IGC::DIEBlock *Block,
2607+
const VISAVariableLocation &loc,
26072608
const std::vector<DbgDecoder::LiveIntervalsVISA> *vars) {
26082609
LLVM_DEBUG(dbgs() << " sliced variable, pushing lane \n");
26092610
// DW_OP_push_simd_lane
@@ -2627,7 +2628,7 @@ bool CompileUnit::buildSlicedLoc(
26272628
unsigned int offsetNotTaken = Block->ComputeSizeOnTheFly(Asm);
26282629

26292630
// Emit first register
2630-
if (!buildValidVar(var, Block, loc, vars, DbgRegisterType::FirstHalf))
2631+
if (!buildValidVar(var, Block, loc, vars, true))
26312632
return false;
26322633

26332634
// Emit second half register
@@ -2644,16 +2645,16 @@ bool CompileUnit::buildSlicedLoc(
26442645
// register in buildValidVar(), which always processes the 1st register only.
26452646
VISAVariableLocation second_loc(loc);
26462647
second_loc.SetRegister(loc.GetSecondReg());
2647-
if (!buildValidVar(var, Block, second_loc, vars, DbgRegisterType::SecondHalf))
2648+
if (!buildValidVar(var, Block, second_loc, vars, false))
26482649
return false;
26492650

26502651
return true;
26512652
}
26522653

26532654
bool CompileUnit::buildValidVar(
2654-
DbgVariable &var, IGC::DIEBlock *Block, const VISAVariableLocation &loc,
2655-
const std::vector<DbgDecoder::LiveIntervalsVISA> *vars,
2656-
DbgRegisterType regType) {
2655+
const DbgVariable &var, IGC::DIEBlock *Block,
2656+
const VISAVariableLocation &loc,
2657+
const std::vector<DbgDecoder::LiveIntervalsVISA> *vars, bool firstHalf) {
26572658
const DbgDecoder::VarInfo *VarInfo = nullptr;
26582659
const auto *VISAMod = loc.GetVISAModule();
26592660

@@ -2670,26 +2671,11 @@ bool CompileUnit::buildValidVar(
26702671
LLVM_DEBUG(dbgs() << " warning: could not get vISA Variable info\n");
26712672
}
26722673

2673-
const bool isSecondHalf = regType == DbgRegisterType::SecondHalf;
2674-
const unsigned NumVarsExpected = isSecondHalf ? 2 : 1;
2675-
// TODO: If neither condition is fulfilled, should we do an early
2676-
// 'return false' as in "invalid variable"? In that case, we could improve
2677-
// the logic in the following way:
2678-
//
2679-
// DbgDecoder::LiveIntervalsVISA *lrToUse = nullptr;
2680-
// if (vars->size() >= NumVarsExpected)
2681-
// lrToUse = vars->at(LRIndex);
2682-
// else if (VarInfo)
2683-
// lrToUse = VarInfo->lrs.front();
2684-
// if (!lrToUse)
2685-
// return false;
2686-
// /* remaining code from the if block */
2687-
if (VarInfo || vars->size() >= NumVarsExpected) {
2688-
const unsigned LRIndex = isSecondHalf ? 1 : 0;
2689-
const auto &lrToUse = vars ? vars->at(LRIndex) : VarInfo->lrs.front();
2674+
if (VarInfo || (vars && vars->size() >= (firstHalf ? 1u : 2u))) {
2675+
const auto &lrToUse =
2676+
vars ? vars->at(firstHalf ? 0 : 1) : VarInfo->lrs.front();
26902677
LLVM_DEBUG(dbgs() << " emitting variable location at LR: <";
26912678
lrToUse.print(dbgs()); dbgs() << ">\n");
2692-
var.setLocationRegisterType(regType);
26932679
emitLocation = true;
26942680
if (lrToUse.isGRF()) {
26952681
if (loc.IsVectorized() == false) {
@@ -2716,7 +2702,7 @@ bool CompileUnit::buildValidVar(
27162702
SimdOffset < MaxUI16);
27172703
if (loc.IsRegister())
27182704
addSimdLane(Block, var, loc, &lrToUse, (uint16_t)(SimdOffset),
2719-
false, isSecondHalf);
2705+
false, !firstHalf);
27202706
}
27212707
}
27222708
} else if (lrToUse.isSpill()) {
@@ -2752,7 +2738,7 @@ bool CompileUnit::buildValidVar(
27522738
static_cast<int32_t>(VectorOffset));
27532739
addBE_FP(Block);
27542740
addSimdLane(Block, var, loc, &lrToUse, 0, false,
2755-
isSecondHalf); // Emit SIMD lane for spill (unpacked)
2741+
!firstHalf); // Emit SIMD lane for spill (unpacked)
27562742
}
27572743
}
27582744
} else {
@@ -2765,7 +2751,7 @@ bool CompileUnit::buildValidVar(
27652751
}
27662752

27672753
IGC::DIEBlock *CompileUnit::buildGeneral(
2768-
DbgVariable &var, const VISAVariableLocation &loc,
2754+
const DbgVariable &var, const VISAVariableLocation &loc,
27692755
const std::vector<DbgDecoder::LiveIntervalsVISA> *vars,
27702756
IGC::DIE *VariableDie) {
27712757
IGC::DIEBlock *Block = new (DIEValueAllocator) IGC::DIEBlock();
@@ -2802,7 +2788,7 @@ IGC::DIEBlock *CompileUnit::buildGeneral(
28022788
if (loc.HasLocationSecondReg()) {
28032789
buildSlicedLoc(var, Block, loc, vars);
28042790
} else {
2805-
buildValidVar(var, Block, loc, vars, DbgRegisterType::Regular);
2791+
buildValidVar(var, Block, loc, vars, true);
28062792
}
28072793
}
28082794

IGC/DebugInfo/DwarfCompileUnit.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class CompileUnit {
524524
// buildSLM - Build expression for location described as offset in SLM memory.
525525
DIEBlock *buildSLM(const DbgVariable &, const VISAVariableLocation &,
526526
IGC::DIE *);
527-
DIEBlock *buildGeneral(DbgVariable &, const VISAVariableLocation &,
527+
DIEBlock *buildGeneral(const DbgVariable &, const VISAVariableLocation &,
528528
const std::vector<DbgDecoder::LiveIntervalsVISA> *,
529529
IGC::DIE *);
530530

@@ -533,13 +533,12 @@ class CompileUnit {
533533
const VISAVariableLocation &);
534534
bool buildFpBasedLoc(const DbgVariable &, IGC::DIEBlock *,
535535
const VISAVariableLocation &);
536-
bool buildSlicedLoc(DbgVariable &, IGC::DIEBlock *,
536+
bool buildSlicedLoc(const DbgVariable &, IGC::DIEBlock *,
537537
const VISAVariableLocation &,
538538
const std::vector<DbgDecoder::LiveIntervalsVISA> *);
539-
bool buildValidVar(DbgVariable &, IGC::DIEBlock *,
539+
bool buildValidVar(const DbgVariable &, IGC::DIEBlock *,
540540
const VISAVariableLocation &,
541-
const std::vector<DbgDecoder::LiveIntervalsVISA> *,
542-
DbgRegisterType);
541+
const std::vector<DbgDecoder::LiveIntervalsVISA> *, bool);
543542

544543
// Variables, used in buildGeneral-algorithm:
545544
bool emitLocation = false;

IGC/DebugInfo/DwarfDebug.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,14 @@ void DbgVariable::emitExpression(CompileUnit *CU, IGC::DIEBlock *Block) const {
211211
}
212212
I->appendToVector(Elements);
213213
}
214-
const bool isSimpleIndirect = currentLocationIsSimpleIndirectValue();
215-
if (isSimpleIndirect)
216-
// drop OP_deref
214+
bool isStackValueNeeded = false;
215+
if (currentLocationIsSimpleIndirectValue()) {
216+
// drop OP_deref and don't emit DW_OP_stack_value.
217217
Elements.erase(Elements.begin());
218-
bool shouldResetStackValue = currentLocationIsImplicit();
219-
if (shouldResetStackValue && !Elements.empty() &&
220-
*Elements.rbegin() == dwarf::DW_OP_stack_value) {
221-
Elements.pop_back();
218+
} else if (!currentLocationIsMemoryAddress() &&
219+
!currentLocationIsImplicit() && !currentLocationIsVector()) {
220+
isStackValueNeeded = true;
222221
}
223-
const bool isFirstHalf = this->RegType == DbgRegisterType::FirstHalf;
224-
bool isStackValueNeeded = !isSimpleIndirect &&
225-
!currentLocationIsMemoryAddress() &&
226-
!currentLocationIsVector() && !isFirstHalf;
227222

228223
for (auto elem : Elements) {
229224
auto BF = DIEInteger::BestForm(false, elem);
@@ -1653,7 +1648,7 @@ void DwarfDebug::collectVariableInfo(
16531648
(pInst->getMetadata("StorageOffset") ||
16541649
Loc.HasSurface() || Loc.IsSLM()))) {
16551650
RegVar->setDbgInst(pInst);
1656-
RegVar->setLocationInlined(true);
1651+
RegVar->isLocationInlined = true;
16571652
break;
16581653
}
16591654
}

IGC/DebugInfo/DwarfDebug.hpp

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ class DotDebugLocEntry {
123123
void setSymbol(llvm::MCSymbol *S) { Symbol = S; }
124124
};
125125

126-
//===----------------------------------------------------------------------===//
127-
/// \brief This enum is used to describe whether a register represents one of
128-
/// the SIMD32 register halves.
129-
enum class DbgRegisterType : uint8_t {
130-
Regular = 0, // Represents all SIMD channels for a source variable, no slice
131-
FirstHalf = 1, // SIMD32 sliced - lower channels
132-
SecondHalf = 2 // SIMD32 sliced - upper channels
133-
};
134-
135126
//===----------------------------------------------------------------------===//
136127
/// \brief This class is used to track local variable information.
137128
class DbgVariable {
@@ -152,12 +143,6 @@ class DbgVariable {
152143
// DBG_VALUE instruction of the variable
153144
const llvm::DbgVariableIntrinsic *m_pDbgInst = nullptr;
154145

155-
// isLocationInlined is true when we expect location to be inlined in
156-
// DW_AT_location.
157-
bool isLocationInlined = false;
158-
159-
DbgRegisterType RegType = DbgRegisterType::Regular;
160-
161146
public:
162147
// AbsVar may be NULL.
163148
DbgVariable(const llvm::DILocalVariable *V,
@@ -211,16 +196,6 @@ class DbgVariable {
211196
bool currentLocationIsSimpleIndirectValue() const;
212197
bool currentLocationIsVector() const;
213198

214-
bool currentLocationIsInlined() const { return isLocationInlined; }
215-
void setLocationInlined(bool isInlined = true) {
216-
isLocationInlined = isInlined;
217-
}
218-
219-
DbgRegisterType getLocationRegisterType() const { return RegType; }
220-
void setLocationRegisterType(DbgRegisterType RegType) {
221-
this->RegType = RegType;
222-
}
223-
224199
void emitExpression(CompileUnit *CU, IGC::DIEBlock *Block) const;
225200

226201
// Translate tag to proper Dwarf tag.
@@ -248,6 +223,10 @@ class DbgVariable {
248223
return false;
249224
}
250225

226+
// isLocationInlined is true when we expect location to be inlined in
227+
// DW_AT_location.
228+
bool isLocationInlined = false;
229+
251230
bool isBlockByrefVariable() const;
252231

253232
llvm::DIType *getType() const;

IGC/ocloc_tests/DebugInfo/simd32-split-stack-value.cl

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)