This is an archive of the discontinued LLVM Phabricator instance.

[RegisterScavenger] Remove aliasing registers of operands from the candidate set
ClosedPublic

Authored by sbaranga on Sep 1 2016, 6:57 AM.

Details

Summary

In addition to not including the register operand of the current
instruction also don't include any aliasing registers. We can't consider
these as candidates because using them will clobber the corresponding
register operand of the current instruction.

This change doesn't include a test case and it would probably be difficult
to produce a stable one since the bug depends on the results of register
allocation.

Diff Detail

Event Timeline

sbaranga updated this revision to Diff 70000.Sep 1 2016, 6:57 AM
sbaranga retitled this revision from to [RegisterScavenger] Remove aliasing registers of operands from the candidate set.
sbaranga updated this object.
sbaranga added reviewers: MatzeB, qcolombet.
sbaranga added a subscriber: llvm-commits.
hfinkel accepted this revision.Sep 6 2016, 12:02 AM
hfinkel added a reviewer: hfinkel.
hfinkel added a subscriber: hfinkel.

LGTM

This revision is now accepted and ready to land.Sep 6 2016, 12:02 AM
sbaranga closed this revision.Sep 6 2016, 3:18 AM

Thanks, Hal! r280698

qcolombet edited edge metadata.Sep 6 2016, 9:56 AM

Have you investigate using the mir representation to produce a test case?

Have you investigate using the mir representation to produce a test case?

I haven't tried it. I also haven't looked at MIR before but it seems really useful in this case. I'll have a look at it.

There's also a large test case in https://reviews.llvm.org/D24239 for this, but most likely we would want to have something less fragile.

I've investigated using MIR for getting a test case. The problem that I currently have with this is that I'm unable to run the PEI pass (where the problem is happening). If I try to do this I get a segfault in the stack protector pass. The problem seems to be that the TargetMachine is null. I'm not sure if this is something specific to PEI - but there doesn't seem to be any other regression tests that tries to run just this pass.

Here are the conditions that would trigger this bug:
We need to have a huge stack frame and a load or store to a stack location such that the location is far enough from the stack pointer and we need to scavenge a register to form the address. In order to avoid the heuristics from the register scavenger, all other registers except the one we want should be live. Our instruction should load or store a sub-register of the address register (for example str w0, [x0]).