Skip to content

Commit 23e01bc

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: ecb7315: Fix DIStringType length emitting in DWARF
For some cases, there wasn't DW_AT_string_length added to variable, which resulted in treating vla array as character.
1 parent 40d882b commit 23e01bc

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

IGC/DebugInfo/DwarfCompileUnit.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,18 +2039,11 @@ void CompileUnit::constructContainingTypeDIEs() {
20392039
}
20402040
}
20412041

2042-
IGC::DIE *CompileUnit::constructVariableDIE(DbgVariable &DV) {
2042+
IGC::DIE *CompileUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) {
20432043
StringRef Name = DV.getName();
20442044
LLVM_DEBUG(dbgs() << "[DwarfDebug] constructing DIE for variable <" << Name << ">\n");
20452045
// Define variable debug information entry.
20462046
DIE *VariableDie = new DIE(DV.getTag());
2047-
insertDIE(const_cast<DILocalVariable *>(DV.getVariable()), VariableDie);
2048-
return VariableDie;
2049-
}
2050-
2051-
void CompileUnit::applyVariableAttributes(DbgVariable &DV, DIE *VariableDie, bool isScopeAbstract) {
2052-
StringRef Name = DV.getName();
2053-
LLVM_DEBUG(dbgs() << "[DwarfDebug] applying attributes for DIE variable <" << Name << ">\n");
20542047
DbgVariable *AbsVar = DV.getAbstractVariable();
20552048
DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : NULL;
20562049
if (AbsDIE) {
@@ -2070,7 +2063,7 @@ void CompileUnit::applyVariableAttributes(DbgVariable &DV, DIE *VariableDie, boo
20702063
if (isScopeAbstract) {
20712064
DV.setDIE(VariableDie);
20722065
LLVM_DEBUG(dbgs() << " done. Variable is scope-abstract\n");
2073-
return;
2066+
return VariableDie;
20742067
}
20752068

20762069
// Add variable address.
@@ -2091,20 +2084,21 @@ void CompileUnit::applyVariableAttributes(DbgVariable &DV, DIE *VariableDie, boo
20912084

20922085
DV.setDIE(VariableDie);
20932086
LLVM_DEBUG(dbgs() << " done. Location is taken from .debug_loc\n");
2094-
return;
2087+
return VariableDie;
20952088
}
20962089

20972090
// Check if variable is described by a DBG_VALUE instruction.
20982091
const Instruction *pDbgInst = DV.getDbgInst();
20992092
if (!pDbgInst || !DV.currentLocationIsInlined()) {
21002093
DV.setDIE(VariableDie);
21012094
LLVM_DEBUG(dbgs() << " done. No dbg.inst assotiated\n");
2102-
return;
2095+
return VariableDie;
21032096
}
21042097

21052098
buildLocation(pDbgInst, DV, VariableDie);
21062099

21072100
LLVM_DEBUG(dbgs() << " done. Location is emitted directly in DIE\n");
2101+
return VariableDie;
21082102
}
21092103

21102104
void CompileUnit::buildLocation(const llvm::Instruction *pDbgInst, DbgVariable &DV, IGC::DIE *VariableDie) {

IGC/DebugInfo/DwarfCompileUnit.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,7 @@ class CompileUnit {
355355
void constructContainingTypeDIEs();
356356

357357
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
358-
DIE *constructVariableDIE(DbgVariable &DV);
359-
360-
/// Apply attributes for DIE created in constructVariableDIE
361-
void applyVariableAttributes(DbgVariable &DV, DIE *VariableDie, bool isScopeAbstract);
358+
DIE *constructVariableDIE(DbgVariable &DV, bool isScopeAbstract);
362359

363360
/// Create a DIE with the given Tag, add the DIE to its parent, and
364361
/// call insertDIE if MD is not null.

IGC/DebugInfo/DwarfDebug.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ DIE *DwarfDebug::createScopeChildrenDIE(CompileUnit *TheCU, LexicalScope *Scope,
675675
DIE *ObjectPointer = NULL;
676676

677677
SmallVector<DbgVariable *, 8> dbgVariables;
678+
678679
// Collect arguments for current function.
679680
if (LScopes.isCurrentFunctionScope(Scope)) {
680681
std::copy(CurrentFnArguments.begin(), CurrentFnArguments.end(), std::back_inserter(dbgVariables));
@@ -686,23 +687,15 @@ DIE *DwarfDebug::createScopeChildrenDIE(CompileUnit *TheCU, LexicalScope *Scope,
686687
std::copy(Variables.begin(), Variables.end(), std::back_inserter(dbgVariables));
687688
}
688689

689-
// Create and collect all argument/variable children
690-
for (DbgVariable *ArgDV : dbgVariables) {
691-
if (!ArgDV)
692-
continue;
693-
DIE *Arg = TheCU->constructVariableDIE(*ArgDV);
694-
Children.push_back(Arg);
695-
if (ArgDV->isObjectPointer())
696-
ObjectPointer = Arg;
697-
}
698-
699-
// Apply attributes to each created DIE. It needs to be done after creating all
700-
// subprogram DIEs, beacuse we might need reference to them in addType() function.
690+
// Collect all argument/variable children
701691
for (DbgVariable *ArgDV : dbgVariables) {
702692
if (!ArgDV)
703693
continue;
704-
DIE *VarDIE = TheCU->getDIE(const_cast<DILocalVariable*>(ArgDV->getVariable()));
705-
TheCU->applyVariableAttributes(*ArgDV, VarDIE, Scope->isAbstractScope());
694+
if (DIE *Arg = TheCU->constructVariableDIE(*ArgDV, Scope->isAbstractScope())) {
695+
Children.push_back(Arg);
696+
if (ArgDV->isObjectPointer())
697+
ObjectPointer = Arg;
698+
}
706699
}
707700

708701
// There is no need to emit empty lexical block DIE.
@@ -1164,9 +1157,9 @@ void DwarfDebug::collectDeadVariables() {
11641157
if (!isa<DILocalVariable>(DV))
11651158
continue;
11661159
DbgVariable NewVar(cast<DILocalVariable>(DV));
1167-
DIE *VariableDIE = SPCU->constructVariableDIE(NewVar);
1168-
SPCU->applyVariableAttributes(NewVar, VariableDIE, false);
1169-
SPDIE->addChild(VariableDIE);
1160+
if (DIE *VariableDIE = SPCU->constructVariableDIE(NewVar, false)) {
1161+
SPDIE->addChild(VariableDIE);
1162+
}
11701163
}
11711164
}
11721165

0 commit comments

Comments
 (0)