[all-commits] [llvm/llvm-project] 5fbb19: [OpenMP][MLIR] Hoist static `alloca`s emitted by p...

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Thu Dec 11 01:17:02 PST 2025


  Branch: refs/heads/users/ergawy/hoist_init_allocas
  Home:   https://github.com/llvm/llvm-project
  Commit: 5fbb19e5048a3357dec2c2dd535ed0402102c30e
      https://github.com/llvm/llvm-project/commit/5fbb19e5048a3357dec2c2dd535ed0402102c30e
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-12-11 (Thu, 11 Dec 2025)

  Changed paths:
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    A mlir/test/Target/LLVMIR/openmp-private-allloca-hoisting.mlir

  Log Message:
  -----------
  [OpenMP][MLIR] Hoist static `alloca`s emitted by private `init` regions to the allocation IP of the construct

Having more than 1 descritpr (allocatable or array) on the same `private` clause triggers a runtime crash on GPUs at the moment.

For SPMD kernels, the issue happens because the initialization logic includes:
* Allocating a number of temporary structs (these are emitted by flang when `fir` is lowered to `mlir.llvm`).
* There is a conditional branch that determines whether we will allocate storage for the descriptor and initialize array bounds from the original descriptor or whether we will initialize the private descriptor to null.

Because of these 2 things, temp allocations needed for descriptors beyond the 1st one are preceded by branching which causes the observed the runtime crash.

This PR solves this issue by hoisting these static `alloca`s instructions to the suitable allca IP of the parent construct.


  Commit: c9c432fd2a6fddb2b121f6d56eb2293e7c848f5f
      https://github.com/llvm/llvm-project/commit/c9c432fd2a6fddb2b121f6d56eb2293e7c848f5f
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-12-11 (Thu, 11 Dec 2025)

  Changed paths:
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

  Log Message:
  -----------
  review comments, Tom


Compare: https://github.com/llvm/llvm-project/compare/9e64fefb3dad...c9c432fd2a6f

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list