[PATCH] D48546: [CodeGen] Ensure split interval has valid ranges for all sub registers

David Stuttard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 25 06:21:30 PDT 2018


dstuttard created this revision.
Herald added subscribers: llvm-commits, nhaehnle, MatzeB.

The issue comes about due to an interval split (a prelude to adding a
spill). The insertion of the spill is the point at which the assertion is
triggered, but it is the initial interval split that causes the error state.

A split is created by adding 2 new virtual registers and a copy from one to the
other at the split point. In this case, the register being split has
sub-registers and one of the lanes is never defined (other than with an
IMPLICIT_DEF).

Inserting the copy causes a new use of the undefined lane and the copy is
inserted in a block with multiple predecessors. One of these predecessors has a
partial def (copy to one of the lanes) and is marked as undef which means that
the non-written lane is undefined. This is valid when there are no uses and the
original def is an IMPLICIT_DEF, but by adding the new use in the split copy,
this causes issues during the phase to extend uses during the split.

This fix detects a situation where it ignores any tagged
undefs in partial copies and traces back to any dead defs - if these are
confirmed then it treats the whole lane as dead and doesn't add the live range
to the newly created split register - this resolves the assertion.

There may be other more complicated cases with larger numbers of predecessors
that still break but are extremely unlikely to exhibit this issue.

See the comment in the lit test for an example of the problem (simplified in the
comments).


Repository:
  rL LLVM

https://reviews.llvm.org/D48546

Files:
  include/llvm/CodeGen/LiveInterval.h
  lib/CodeGen/LiveInterval.cpp
  lib/CodeGen/SplitKit.cpp
  test/CodeGen/AMDGPU/subreg-split-live-in-error.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48546.152678.patch
Type: text/x-patch
Size: 29679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180625/d917809c/attachment.bin>


More information about the llvm-commits mailing list