This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix global isel for kernels using agprs on gfx90a
ClosedPublic

Authored by rampitec on Oct 27 2021, 11:44 AM.

Details

Summary

With Global ISel getReservedRegs() is called before function is
regbank selected for the first time. Defer caching of usesAGPRs()
in this case.

Diff Detail

Event Timeline

rampitec created this revision.Oct 27 2021, 11:44 AM
rampitec requested review of this revision.Oct 27 2021, 11:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2021, 11:44 AM
Herald added a subscriber: wdng. · View Herald Transcript

How was this breaking?

How was this breaking?

LLVM ERROR: no registers from class available to allocate

What happens usesAGPRs() does not see any agprs used and then the whole register budget is allocated to vgprs.

How was this breaking?

LLVM ERROR: no registers from class available to allocate

What happens usesAGPRs() does not see any agprs used and then the whole register budget is allocated to vgprs.

Wouldn't it work correctly after later getReservedRegs calls? I don't think we should be calling this before finalizeIsel?

How was this breaking?

LLVM ERROR: no registers from class available to allocate

What happens usesAGPRs() does not see any agprs used and then the whole register budget is allocated to vgprs.

Wouldn't it work correctly after later getReservedRegs calls? I don't think we should be calling this before finalizeIsel?

It does work correctly with a later call from freezeReservedRegs(). The first call though comes from MachineVerifier::visitMachineFunctionBefore().

How was this breaking?

LLVM ERROR: no registers from class available to allocate

What happens usesAGPRs() does not see any agprs used and then the whole register budget is allocated to vgprs.

Wouldn't it work correctly after later getReservedRegs calls? I don't think we should be calling this before finalizeIsel?

It does work correctly with a later call from freezeReservedRegs(). The first call though comes from MachineVerifier::visitMachineFunctionBefore().

But if the later call fixes it up, how is it able to break in allocation later?

How was this breaking?

LLVM ERROR: no registers from class available to allocate

What happens usesAGPRs() does not see any agprs used and then the whole register budget is allocated to vgprs.

Wouldn't it work correctly after later getReservedRegs calls? I don't think we should be calling this before finalizeIsel?

It does work correctly with a later call from freezeReservedRegs(). The first call though comes from MachineVerifier::visitMachineFunctionBefore().

But if the later call fixes it up, how is it able to break in allocation later?

I am caching this value. The first call did not find any agprs and cached it. Here I am skipping the caching until selection is finalized.

arsenm accepted this revision.Oct 29 2021, 2:03 PM
This revision is now accepted and ready to land.Oct 29 2021, 2:03 PM
This revision was landed with ongoing or failed builds.Oct 29 2021, 2:23 PM
This revision was automatically updated to reflect the committed changes.