[all-commits] [llvm/llvm-project] f8d044: [TBLGEN] Fix subreg value overflow in DAGISelMatcher

Stanislav Mekhanoshin via All-commits all-commits at lists.llvm.org
Wed Feb 12 13:30:09 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f8d044bbcfdc9e1ddc02247ffb86fe39e1f277f0
      https://github.com/llvm/llvm-project/commit/f8d044bbcfdc9e1ddc02247ffb86fe39e1f277f0
  Author: Stanislav Mekhanoshin <Stanislav.Mekhanoshin at amd.com>
  Date:   2020-02-12 (Wed, 12 Feb 2020)

  Changed paths:
    A llvm/test/TableGen/Common/reg-with-subregs-common.td
    A llvm/test/TableGen/dag-isel-subregs.td
    M llvm/utils/TableGen/CodeGenRegisters.cpp
    M llvm/utils/TableGen/CodeGenRegisters.h
    M llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
    M llvm/utils/TableGen/DAGISelMatcherGen.cpp
    M llvm/utils/TableGen/RegisterInfoEmitter.cpp

  Log Message:
  -----------
  [TBLGEN] Fix subreg value overflow in DAGISelMatcher

Tablegen's DAGISelMatcher emits integers in a VBR format,
so if an integer is below 128 it can fit into a single
byte, otherwise high bit is set, next byte is used etc.
MatcherTable is essentially an unsigned char table. When
SelectionDAGISel parses the table it does a reverse translation.

In a situation when numeric value of an integer to emit is
unknown it can be emitted not as OPC_EmitInteger but as
OPC_EmitStringInteger using a symbolic name of the value.
In this situation the value should not exceed 127.

One of the situations when OPC_EmitStringInteger is used is
if we need to emit a subreg into a matcher table. However,
number of subregs can exceed 127. Currently last defined subreg
for AMDGPU is 192. That results in a silent bug in the ISel
with matcher reading from an invalid offset.

Fixed this bug to emit actual VBR encoded value for a subregs
which value exceeds 127.

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




More information about the All-commits mailing list