[all-commits] [llvm/llvm-project] 0b168a: [mlir][LLVMIR] Use a new way to verify GEPOp indices

Min-Yih Hsu via All-commits all-commits at lists.llvm.org
Tue May 17 10:30:14 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0b168a49bf584ddd9aae4be8b1907aee8ed65615
      https://github.com/llvm/llvm-project/commit/0b168a49bf584ddd9aae4be8b1907aee8ed65615
  Author: Min-Yih Hsu <minyihh at uci.edu>
  Date:   2022-05-17 (Tue, 17 May 2022)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
    M mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    M mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
    A mlir/test/Dialect/LLVMIR/dynamic-gep-index.mlir
    A mlir/test/Target/LLVMIR/Import/dynamic-gep-index.ll

  Log Message:
  -----------
  [mlir][LLVMIR] Use a new way to verify GEPOp indices

Previously, GEPOp relies on `findKnownStructIndices` to check if a GEP
index should be static. The truth is, `findKnownStructIndices` can only
tell you a GEP index _might_ be indexing into a struct (which should use
a static GEP index). But GEPOp::build and GEPOp::verify are falsely
taking this information as a certain answer, which creates many false
alarms like the one depicted in
`test/Target/LLVMIR/Import/dynamic-gep-index.ll`.

The solution presented here adopts a new verification scheme: When we're
recursively checking the child element types of a struct type, instead
of checking every child types, we only check the one dictated by the
(static) GEP index value. We also combine "refinement" logics --
refine/promote struct index mlir::Value into constants -- into the very
verification process since they have lots of logics in common. The
resulting code is more concise and less brittle.

We also hide GEPOp::findKnownStructIndices since most of the
aforementioned logics are already encapsulated within GEPOp::build and
GEPOp::verify, we found little reason for findKnownStructIndices (or the
new findStructIndices) to be public.

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




More information about the All-commits mailing list