[Mlir-commits] [mlir] [OpenMPToLLVMIRTranslation] Save allocaIP after splitting (PR #228495)

Nikita Popov llvmlistbot at llvm.org
Fri Oct 2 08:49:32 PDT 2026


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/228495

allocatePrivateVars() splits the block, such that the original
saved insertion point now points into a different block. Move the
saving until after the call, so it uses the adjusted insertion
point.

This is an attempt to fix the amdgpu-clang-flang buildbot after
PR #228117.

>From 2220eb88d7333f1e29fbf249b3f7a2db0bb1ad46 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 2 Oct 2026 17:47:03 +0200
Subject: [PATCH] [OpenMPToLLVMIRTranslation] Save allocaIP after splitting

allocatePrivateVars() splits the block, such that the original
saved insertion point now points into a different block. Move the
saving until after the call, so it uses the adjusted insertion
point.

This is an attempt to fix the amdgpu-clang-flang buildbot after
PR #228117.
---
 .../Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp      | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 1f0f7314f71fd..9859008ebe08c 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -8802,11 +8802,6 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
   auto bodyGenCB =
       [&](InsertPointTy allocaIP, InsertPointTy codeGenIP,
           llvm::ArrayRef<llvm::BasicBlock *> deallocBlocks) -> llvm::Error {
-    // Save the alloca insertion point on ModuleTranslation stack for use in
-    // nested regions.
-    LLVM::ModuleTranslation::SaveStack<OpenMPAllocStackFrame> frame(
-        moduleTranslation, allocaIP, deallocBlocks);
-
     // DistributeOp has only one region associated with it.
     builder.restoreIP(codeGenIP);
     PrivateVarsInfo privVarsInfo(distributeOp);
@@ -8816,6 +8811,12 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder,
     if (handleError(afterAllocas, opInst).failed())
       return llvm::make_error<PreviouslyReportedError>();
 
+    // Save the alloca insertion point on ModuleTranslation stack for use in
+    // nested regions. This must be after allocatePrivateVars, which splits
+    // the alloca block and updates allocaIP.
+    LLVM::ModuleTranslation::SaveStack<OpenMPAllocStackFrame> frame(
+        moduleTranslation, allocaIP, deallocBlocks);
+
     if (handleError(initPrivateVars(builder, moduleTranslation, privVarsInfo),
                     opInst)
             .failed())



More information about the Mlir-commits mailing list