Skip to content

Commit 448c9ec

Browse files
pratikasharigcbot
authored andcommitted
Fix nullptr deref
When entryBB ends with call, its RET__loc is identified as LiveThrough since it's defined in entryBB and used in some other function. This is not really a problem because RET__loc's interference is correctly captured by SIMT interference. Whenever we see a call site, in handleCallSite(), we assume that RET__loc belongs to DefBeforeCallSite so we create an empty interval for it, which in this special case never gets updated and interval start/end remains nullptr. When emitting debug info ranges, these nullptrs are dereferenced which causes a crash. Fix is to rely on sortedIntervals when updating debug info.
1 parent 7e766dc commit 448c9ec

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

visa/GraphColor.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,7 +3856,14 @@ void Augmentation::handleCallSite(G4_BB *curBB, unsigned int &funcCnt) {
38563856
// If a function has multiple call sites to same
38573857
// callee then there would be as many trivial
38583858
// live-intervals for corresponding RET__loc dcl.
3859-
gra.pushBackNewInterval(retLocDcl);
3859+
3860+
// RET__loc dcl in entryBB is identified as LiveThrough
3861+
// rather than DefBeforeEachCall. LiveThrough variable's
3862+
// interference is fully handled by SIMT. So we don't
3863+
// need to create the short interval for RET__loc at
3864+
// call site.
3865+
if (isDefBeforeEachCallArg(retLocDcl))
3866+
gra.pushBackNewInterval(retLocDcl);
38603867

38613868
auto *callee = curBB->getCalleeInfo();
38623869
vISA_ASSERT(argsPerSub.count(callee) > 0, "didnt find entry for sub");
@@ -5628,8 +5635,8 @@ void Augmentation::augmentIntfGraph() {
56285635
dclIntervals.reserve(sortedIntervals.size());
56295636
for (auto &interval : sortedIntervals) {
56305637
auto dcl = interval.dcl;
5631-
dclIntervals.push_back(std::make_tuple(
5632-
dcl, gra.getLastStartInterval(dcl), gra.getLastEndInterval(dcl)));
5638+
dclIntervals.push_back(std::make_tuple(dcl, interval.interval.start,
5639+
interval.interval.end));
56335640
}
56345641
updateDebugInfo(kernel, dclIntervals);
56355642
}

0 commit comments

Comments
 (0)