This is an archive of the discontinued LLVM Phabricator instance.

[X86]: Add imp-uses of live regs when creating conditional tail calls (PR31257)
ClosedPublic

Authored by hans on Feb 10 2017, 3:54 PM.

Details

Summary

This is a second stab at fixing PR31257 (the previous one was D29511). The patch is intended to be applied on top of a revert of r294348.

The idea is to mark registers which are live before the call, but potentially clobbered by it, as imp-used and imp-defined, as a way of keeping them alive. In reality, the registers are not clobbered unless the call is made, in which case it doesn't matter as control leaves the function.

This is the same technique that's used when creating predicated variants of instructions in IfConverter::CopyAndPredicateBlock.

Diff Detail

Repository
rL LLVM

Event Timeline

hans created this revision.Feb 10 2017, 3:54 PM
qcolombet added inline comments.Feb 10 2017, 5:39 PM
lib/Target/X86/X86InstrInfo.cpp
5665 ↗(On Diff #88069)

You'll need to add implicit-def as well otherwise the liveness will think later uses are referencing undef values, because this are still clobbered by the TC.
Basically, you've fixed the part of the live-range getting to the TC, but you have to fix part that leaves the TC.

hans updated this revision to Diff 88420.Feb 14 2017, 1:14 PM
hans edited the summary of this revision. (Show Details)

Adding imp-defs as well.

hans marked an inline comment as done.Feb 14 2017, 1:15 PM
hans added inline comments.
test/CodeGen/X86/tail-call-conditional.mir
51 ↗(On Diff #88069)

There is a lot of redundancy in the list of implicitly used registers. Do you know of a convenient way to clean it up?

qcolombet accepted this revision.Feb 14 2017, 6:08 PM

LGTM

test/CodeGen/X86/tail-call-conditional.mir
51 ↗(On Diff #88069)

I don't think we have a convenient way to clean that up other than eliminating the redundancies programmatically.
One way to do this is to walk through the list and remember the register with the largest size for each clobbered reg unit.
I believe we do something like that somewhere else, but I don't remember where on top of my head. What I am saying is that there may be opportunities to share some code.

This revision is now accepted and ready to land.Feb 14 2017, 6:08 PM
This revision was automatically updated to reflect the committed changes.