Page MenuHomePhabricator

[MIR-Canon] Add support for rewriting VRegs that are typed but don't have an RC.
ClosedPublic

Authored by plotfi on May 28 2019, 11:56 AM.

Details

Summary

So it appears that in a lot of cases before registerbanks are selected, we dont have Register classes and MIR-Canon is crashing. This attempts to fix this by creating new override registers that use the generic type rather than the register class.

Diff Detail

Event Timeline

plotfi created this revision.May 28 2019, 11:56 AM
compnerd added inline comments.May 28 2019, 12:00 PM
llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
320

I think that the do is superfluous

325

I think that this can just be return MRI.getRegClassOrNull(VReg0) || MRI.getType(VReg0) == MRI.getType(VReg1);

519

Why not sink the get into the conditional?

if (auto RC = MRI.getRegClassOrNull(VReg))
  return MRI.createVirtualRegister(RC, OS.str());
bogner accepted this revision.May 29 2019, 12:24 PM

lgtm once you've addressed compnerd's comments

This revision is now accepted and ready to land.May 29 2019, 12:24 PM
plotfi updated this revision to Diff 202088.May 29 2019, 6:28 PM
plotfi updated this revision to Diff 202232.May 30 2019, 10:00 AM

Going to leave out the vregTypesMatch part as that changes some of the behavior in a way that causes llvm/test/CodeGen/MIR/AMDGPU/mir-canon-multi.mir to fail, and I'd like to understand why that is happening. But for now this change makes the cursor create vregs based on the vreg type if there is no register class to base off of.

plotfi marked 3 inline comments as done.May 30 2019, 10:01 AM
plotfi updated this revision to Diff 202234.May 30 2019, 10:04 AM
This revision was automatically updated to reflect the committed changes.