[all-commits] [llvm/llvm-project] 718793: [OpenMP][OMPIRBuilder] Handle replace uses of Cons...

agozillon via All-commits all-commits at lists.llvm.org
Wed Nov 15 06:45:46 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 718793ce6a54b8fb95884d7fb37f70fd339cab3b
      https://github.com/llvm/llvm-project/commit/718793ce6a54b8fb95884d7fb37f70fd339cab3b
  Author: agozillon <Andrew.Gozillon at amd.com>
  Date:   2023-11-15 (Wed, 15 Nov 2023)

  Changed paths:
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    A mlir/test/Target/LLVMIR/omptarget-constant-indexing-device-region.mlir
    A openmp/libomptarget/test/offloading/fortran/constant-arr-index.f90

  Log Message:
  -----------
  [OpenMP][OMPIRBuilder] Handle replace uses of ConstantExpr's inside of Target regions (#71891)

Currently there's an edge cases where constant indexing in target
regions can lead to incorrect results as we do not correctly replace
uses of mapped variables in generated target functions with the target
arguments (and accessor instructions) that replace them. This patch
seeks to fix that by extending the current logic in the OMPIRBuilder.

Things like GEP's can come in the form of Constants/ConstantExprs,
Constants and ConstantExpr's do not have access to the knowledge of what
they're contained in, so we must dig a little to find an instruction so
we can tell if they're used inside of the function we're outlining so we
can be sure they are replaceable and we are not accidentally replacing a
usage somewhere else in the module that's still necessary.

This patch handles these by replacing the original constant expression
with a new instruction equivalent; an instruction as it allows easy
modification in the following loop, as we can now know the constant
(instruction) is owned by our target function (as it holds this
knowledge) and replaceUsesOfWith can now be invoked on it (cannot do
this with constants it seems), a brand new one also allows us to be
cautious as it is perhaps possible the old expression was used inside of
the function but exists and is used externally (unlikely by the nature
of a Constant, but still a positive side affect).




More information about the All-commits mailing list