This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/SI: Fix SI scheduler LiveOut Refcount issue
ClosedPublic

Authored by axeldavy on Feb 18 2017, 1:21 PM.

Details

Summary

The LiveOuts of a scheduling region were not properly refcounted,
thus the scheduler was incorrectly expecting them to be released
when the last block of the region using them as scheduled.

Diff Detail

Repository
rL LLVM

Event Timeline

axeldavy created this revision.Feb 18 2017, 1:21 PM
axeldavy added a project: Restricted Project.Feb 18 2017, 2:31 PM
axeldavy added a subscriber: llvm-commits.
arsenm added inline comments.Feb 21 2017, 3:47 PM
lib/Target/AMDGPU/SIMachineScheduler.cpp
1372

const reference

1374–1381

Double map lookup, use the iterator returned by find

axeldavy updated this revision to Diff 89800.Feb 25 2017, 1:59 PM

I added the suggested changes.
Also, it seems that incrementing non-existing map element will create it with value 0 (and then increment it), thus I don't need to check at all the existence:
++LiveOutRegsNumUsages[ID][Reg];
is enough.

I will propose a patch that will update the other cases in the code that would benefit this.

vpykhtin added inline comments.
lib/Target/AMDGPU/SIMachineScheduler.cpp
1372

constructing std::set every time you need to find one register in it is an obvious overkill. In this case its better to swap these two loops, construct the OutRegs set once for a block and then search all out regs there.

axeldavy added inline comments.Mar 22 2017, 11:59 AM
lib/Target/AMDGPU/SIMachineScheduler.cpp
1372

Sorry, I didn't know for (-U9999999) when I sent this patch, I'll update with it.

Probably the good way is const std::set<unsigned> &OutRegs = Block->getOutRegs();

For blocks, the result of getOutRegs is computed once.

This is different to DAG->getOutRegs, which is added in this patch.

axeldavy updated this revision to Diff 92675.Mar 22 2017, 12:04 PM

Prevented a set copy using a reference.

t-tye added a subscriber: t-tye.Mar 22 2017, 6:38 PM
tony-tye removed a subscriber: tony-tye.Mar 22 2017, 6:48 PM
vpykhtin accepted this revision.Mar 23 2017, 7:40 AM

LGTM, Thanks!

This revision is now accepted and ready to land.Mar 23 2017, 7:40 AM
This revision was automatically updated to reflect the committed changes.