[all-commits] [llvm/llvm-project] d17094: [RegAlloc] Immediately delete dead instructions wi...

Stanislav Mekhanoshin via All-commits all-commits at lists.llvm.org
Tue Aug 31 14:00:10 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d170945bb2b3a0855cea115d31d688b85ddf3dc5
      https://github.com/llvm/llvm-project/commit/d170945bb2b3a0855cea115d31d688b85ddf3dc5
  Author: Stanislav Mekhanoshin <Stanislav.Mekhanoshin at amd.com>
  Date:   2021-08-31 (Tue, 31 Aug 2021)

  Changed paths:
    M llvm/lib/CodeGen/LiveRangeEdit.cpp
    A llvm/test/CodeGen/X86/delete-dead-instrs-with-live-uses.mir

  Log Message:
  -----------
  [RegAlloc] Immediately delete dead instructions with live uses

When RA eliminated a dead def it can either immediately delete
the instruction itself or replace it with KILL to defer the
actual removal. If this instruction has a virtual register use
killing the register it will shrink the LI of the use. However,
if the LI covers the instruction and extends beyond it the
shrink will not happen. In fact that is impossible to shrink
such use because of the KILL still using it.

If later the LI of the use will be split at the KILL and the
KILL itself is eliminated after that point the new live segment
ends up at an invalid slot index.

This extremely rare condition was hit after D106408 which has
enabled rematerialization of such instructions. The replacement
with KILL is only done for rematerialized defs which became dead
and such rematerialization did not generally happen before.

The patch deletes an instruction immediately if it is a result
of rematerialization and has such use. An alternative would be
to prohibit a split at a KILL instruction, but it looks like it
is better to split a live range rather then keeping a killed
instruction just in case it can be rematerialized further.

Fixes PR51655.

Differential Revision: https://reviews.llvm.org/D108951




More information about the All-commits mailing list