[all-commits] [llvm/llvm-project] 401a45: Fix late rematerialization operands check

Stanislav Mekhanoshin via All-commits all-commits at lists.llvm.org
Mon Aug 23 12:24:14 PDT 2021


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

  Changed paths:
    M llvm/lib/CodeGen/LiveRangeEdit.cpp
    A llvm/test/CodeGen/AArch64/pr51516.mir
    A llvm/test/CodeGen/AMDGPU/pr51516.mir

  Log Message:
  -----------
  Fix late rematerialization operands check

D106408 enables rematerialization of instructions with virtual
register uses. That has uncovered the bug in the allUsesAvailableAt
implementation: https://bugs.llvm.org/show_bug.cgi?id=51516.

In the majority of cases canRematerializeAt() called to check if
an instruction can be rematerialized before the given UseIdx.
However, SplitEditor::enterIntvAtEnd() calls it to rematerialize
an instruction at the end of a block passing LIS.getMBBEndIdx()
into the check. In the testcase from the bug it has attempted to
rematerialize ADDXri after STRXui in bb.17. The use operand %55
of the ADD is killed by the STRX but that is undetected by the check
because it adjusts passed UseIdx to the reg slot, before the kill.
The value is dead at the index passed to the check however.

This change uses a later of passed UseIdx and its reg slot. This
shall be correct because if are checking an availability of operands
before an instruction that instruction cannot be the one defining
these operands. If we are checking for late rematerialization we
are really interested if operands live past the instruction.

The bug is not exploitable without D106408 but needed to reland
reverted D106408.

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




More information about the All-commits mailing list