[all-commits] [llvm/llvm-project] d0f19c: [mlir] Handle different pointer sizes in unranked ...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Thu Feb 9 11:15:11 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d0f19ce774b0d3fa5cd3b22561cc75c7b38b290d
      https://github.com/llvm/llvm-project/commit/d0f19ce774b0d3fa5cd3b22561cc75c7b38b290d
  Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
  Date:   2023-02-09 (Thu, 09 Feb 2023)

  Changed paths:
    M mlir/include/mlir/Conversion/LLVMCommon/MemRefBuilder.h
    M mlir/include/mlir/Conversion/LLVMCommon/StructBuilder.h
    M mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp
    M mlir/lib/Conversion/LLVMCommon/Pattern.cpp
    M mlir/lib/Conversion/LLVMCommon/StructBuilder.cpp
    M mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
    M mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
    M mlir/test/Conversion/FuncToLLVM/calling-convention.mlir
    M mlir/test/Conversion/MemRefToLLVM/convert-dynamic-memref-ops.mlir
    M mlir/test/Conversion/MemRefToLLVM/typed-pointers.mlir

  Log Message:
  -----------
  [mlir] Handle different pointer sizes in unranked memref descriptors

The code for unranked memref descriptors assumed that
sizeof(!llvm.ptr) == lizeof(!llvm.ptr<N>) for all address spaces N.
This is not always true (ex. the AMDGPU compiler backend has
sizeof(!llvm.ptr) = 64 bits but sizeof(!llvm.ptr<5>) = 32 bits, where
address space 5 is used for stack allocations). While this is merely
an overallocation in the case where a non-0 address space has pointers
smaller than the default, the existing code could cause OOB memory
accesses when sizeof(!llvm.ptr<N>) > sizeof(!llvm.ptr).

So, add an address spaces parameter to computeSizes in order to
partially resolve this class of bugs. Note that the LLVM data layout
in the conversion passes is currently set to "" and not constructed
from the MLIR data layout or some other source, but this could change
in the future.

Depends on D142159

Reviewed By: ftynse

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




More information about the All-commits mailing list