This is an archive of the discontinued LLVM Phabricator instance.

[InlineSpiller] Only examine defs in BUNDLE instruction
Needs RevisionPublic

Authored by uabelho on Jul 6 2017, 6:36 AM.

Details

Reviewers
qcolombet
MatzeB
Summary

If we have a bundle like

BUNDLE %vreg0<imp-def,dead>
  * %vreg0<def> = <some_instr>

and the entire %vreg0 live range needs to be spilled to the stack, we still
shouldn't insert a spill of %vreg0 after the above bundle since that
particular def is dead and the verifier will then complain about a use
after the dead def.

To solve this problem when there seems to be a mismatch between the dead
flags in the BUNDLE instruction and the bundled instructions, we only
examine the defs of the BUNDLE instruction if it exists.

On some targets there are bundles without BUNDLE instructions, and in those
cases we continue to examine the def of each individual bundled
instruction.

Diff Detail

Event Timeline

uabelho created this revision.Jul 6 2017, 6:36 AM
MatzeB requested changes to this revision.Jul 6 2017, 2:02 PM

This adds bundle-specific behaviour into the register allocator. I think this is wrong!

From an RAs perspective the bundle really should be the union of all operands on a single instruction. So the real question to solve here is what to do with an instruction that has "%vreg0<imp-def,dead>" and "%vreg0<def>" at the same time and not checking for bundles and changing behaviour when we have them.

This revision now requires changes to proceed.Jul 6 2017, 2:02 PM
qcolombet requested changes to this revision.Jul 6 2017, 2:04 PM
qcolombet added inline comments.
lib/CodeGen/InlineSpiller.cpp
993

I think we need to converge on what a dead flag of something already defined and used mean before moving forward with a fix.

Thanks for the comments!

I have no idea if this is the right fix to do, that's why I asked in the thread on llvm-dev if there was any
point in putting up a patch with this change or not.

We've run with this locally on our out-of-tree target for a while now and haven't seen anything break
from it, but if there is a better change then I'm all for it. I don't know what it is though.