[PATCH] D20456: [CodeGen] Fix problem with X86 byte registers in CriticalAntiDepBreaker

Mitch Bodart via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 16:52:25 PDT 2016


mbodart created this revision.
mbodart added reviewers: qcolombet, hfinkel.
mbodart added a subscriber: llvm-commits.

This fix addresses the failures reported in pr27681, pr27580 and pr27804, caused by a bug in CriticalAntiDepBreaker.cpp, which increased in exposure when I recently enabled the post-RA-scheduler for more X86 cpus.

At the heart of the issue is that MCSuperRegIterator does not exhaust all registers in the underlying container.
For example if starting with %CL it will encounter %CL, %CX, %ECX and %RCX, but not %CH.  This isn't a direct problem,
but it leads to some subtle differences in the various register properties maintained by this optimization,
where %CH stands out as different.

In the case of pr27681, all %RCX subregs other than %CH get conservatively added to the KeepRegs set when we see
a %CL def tied to a use in PreScanInstruction.  When we later see an %ECX def in ScanInstruction's def processing,
we skip state updates because of the %ECX presence in KeepRegs.  This leaves %CH in an incorrect "free" state.

My fix is to ensure %CH gets added to KeepRegs as well, and to avoid choosing a KeepRegs register
when looking for a free register.

Any use of MCSuperRegIterator or MCRegAliasIterator is prone to this subtle issue.  I briefly looked at the other
uses in this optimization, and it was not clear if they could be problematic, so I chose not to touch them.

http://reviews.llvm.org/D20456

Files:
  lib/CodeGen/CriticalAntiDepBreaker.cpp
  test/CodeGen/X86/pr27681.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20456.57878.patch
Type: text/x-patch
Size: 9035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160519/70826b80/attachment.bin>


More information about the llvm-commits mailing list