Skip to content

Commit 1390d57

Browse files
lwesiersigcbot
authored andcommitted
IGCMetrics - fix issues with VISAOffset
Some of the instructions dosen't have VISAOffset - mostly, because those instructions are a dead code. IGCMetrics during matching Spill/Fills was facing such scenerio - now, we are ignoring load/store without VISAOffest.
1 parent ff6d318 commit 1390d57

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

IGC/DebugInfo/VISAModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ void VISAModule::BeginEncodingMark() { ValidateVisaId(); }
165165

166166
void VISAModule::EndEncodingMark() { UpdateVisaId(); }
167167

168+
bool VISAModule::HasVisaOffset(const llvm::Instruction *pInst) const {
169+
return m_instInfoMap.find(pInst) != m_instInfoMap.end();
170+
}
171+
168172
unsigned int VISAModule::GetVisaOffset(const llvm::Instruction *pInst) const {
169173
InstInfoMap::const_iterator itr = m_instInfoMap.find(pInst);
170174
IGC_ASSERT_MESSAGE(itr != m_instInfoMap.end(), "Invalid Instruction");

IGC/DebugInfo/VISAModule.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,11 @@ class VISAModule {
448448
/// @brief Mark end of VISA code emitting section.
449449
void EndEncodingMark();
450450

451+
/// @brief Return true if instruction has VISA offset.
452+
/// @param Instruction to query.
453+
/// @return Return true if instruction has VISA offset, otherwise false.
454+
bool HasVisaOffset(const llvm::Instruction *pInst) const;
455+
451456
/// @brief Return VISA offset (in instructions) mapped to given instruction.
452457
/// @param Instruction to query.
453458
/// @return VISA offset (in instructions)

IGC/Metrics/IGCMetricImpl.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,13 +1084,18 @@ namespace IGCMetrics
10841084
auto spillMD = instr.getMetadata(metric->fillInstrKindID);
10851085
if (spillMD != nullptr)
10861086
{
1087-
auto func_m = metric->GetFuncMetric(&instr);
1088-
auto spillFill_m = func_m->mutable_spillfill_stats();
1087+
// Some instructions dosen't have visa offset
1088+
// that means the instruction is a dead code
1089+
if (CurrentVISA->HasVisaOffset(&instr))
1090+
{
1091+
auto func_m = metric->GetFuncMetric(&instr);
1092+
auto spillFill_m = func_m->mutable_spillfill_stats();
10891093

1090-
spillFill_m->set_countfillinstr(spillFill_m->countfillinstr() + 1);
1094+
spillFill_m->set_countfillinstr(spillFill_m->countfillinstr() + 1);
10911095

1092-
// Add spill instruction to metrics
1093-
spillFill_m->add_fillinstrvisaid(CurrentVISA->GetVisaOffset(&instr));
1096+
// Add spill instruction to metrics
1097+
spillFill_m->add_fillinstrvisaid(CurrentVISA->GetVisaOffset(&instr));
1098+
}
10941099
}
10951100
}
10961101

@@ -1099,13 +1104,18 @@ namespace IGCMetrics
10991104
auto fillMD = instr.getMetadata(metric->spillInstrKindID);
11001105
if (fillMD != nullptr)
11011106
{
1102-
auto func_m = metric->GetFuncMetric(&instr);
1103-
auto spillFill_m = func_m->mutable_spillfill_stats();
1107+
// Some instructions dosen't have visa offset
1108+
// that means the instruction is a dead code
1109+
if (CurrentVISA->HasVisaOffset(&instr))
1110+
{
1111+
auto func_m = metric->GetFuncMetric(&instr);
1112+
auto spillFill_m = func_m->mutable_spillfill_stats();
11041113

1105-
spillFill_m->set_countspillinstr(spillFill_m->countspillinstr() + 1);
1114+
spillFill_m->set_countspillinstr(spillFill_m->countspillinstr() + 1);
11061115

1107-
// Add spill instruction to metrics
1108-
spillFill_m->add_spillinstrvisaid(CurrentVISA->GetVisaOffset(&instr));
1116+
// Add spill instruction to metrics
1117+
spillFill_m->add_spillinstrvisaid(CurrentVISA->GetVisaOffset(&instr));
1118+
}
11091119
}
11101120
}
11111121
};

0 commit comments

Comments
 (0)