[Mlir-commits] [mlir] 4138dc4 - [MLIR][OpenMP] Preserve debug location in OpenMPIRBuilder calls. (#211254)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jul 23 01:57:45 PDT 2026
Author: Abid Qadeer
Date: 2026-07-23T09:57:40+01:00
New Revision: 4138dc431ad849bd8c0e76f907345c6d0507890b
URL: https://github.com/llvm/llvm-project/commit/4138dc431ad849bd8c0e76f907345c6d0507890b
DIFF: https://github.com/llvm/llvm-project/commit/4138dc431ad849bd8c0e76f907345c6d0507890b.diff
LOG: [MLIR][OpenMP] Preserve debug location in OpenMPIRBuilder calls. (#211254)
Many `OpenMPIRBuilder` entry points take an
`OpenMPIRBuilder::LocationDescription`. It has two relevant
constructors:
`LocationDescription(const IRBuilderBase &IRB)` // captures IP and debug
loc
`LocationDescription(const InsertPointTy &IP)` // captures IP only; DL
is empty
The OpenMP MLIR-to-LLVM-IR translation constructs the location from
`builder` in almost all places (~45 call sites), which selects the first
constructor and propagates both the insertion point and the current
debug location. A few call sites instead passed `builder.saveIP()`,
which selects the second constructor and silently drops the debug
location.
Change the 9 offending call sites to pass `builder` instead of
`builder.saveIP()`, so the debug location is preserved.
Added:
Modified:
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 85963c402bc87..1c38fd27daae1 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -271,7 +271,7 @@ class LinearClauseProcessor {
// Emit barrier
builder.SetInsertPoint(linearExitBB->getTerminator());
return moduleTranslation.getOpenMPBuilder()->createBarrier(
- builder.saveIP(), llvm::omp::OMPD_barrier);
+ builder, llvm::omp::OMPD_barrier);
}
// Emit stores for linear variables. Useful in case of SIMD
@@ -1654,8 +1654,8 @@ static LogicalResult createReductionsAndCleanup(
llvm::UnreachableInst *tempTerminator = builder.CreateUnreachable();
builder.SetInsertPoint(tempTerminator);
llvm::OpenMPIRBuilder::InsertPointOrErrorTy contInsertPoint =
- ompBuilder->createReductions(builder.saveIP(), allocaIP, reductionInfos,
- isByRef, isNowait, isTeamsReduction);
+ ompBuilder->createReductions(builder, allocaIP, reductionInfos, isByRef,
+ isNowait, isTeamsReduction);
if (failed(handleError(contInsertPoint, *op)))
return failure();
@@ -2003,7 +2003,7 @@ static LogicalResult copyFirstPrivateVars(
if (insertBarrier && !opIsInSingleThread(op)) {
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
llvm::OpenMPIRBuilder::InsertPointOrErrorTy res =
- ompBuilder->createBarrier(builder.saveIP(), llvm::omp::OMPD_barrier);
+ ompBuilder->createBarrier(builder, llvm::omp::OMPD_barrier);
if (failed(handleError(res, *op)))
return failure();
}
@@ -4475,7 +4475,7 @@ convertOmpTaskwaitOp(omp::TaskwaitOp twOp, llvm::IRBuilderBase &builder,
return failure();
}
- moduleTranslation.getOpenMPBuilder()->createTaskwait(builder.saveIP(), dds);
+ moduleTranslation.getOpenMPBuilder()->createTaskwait(builder, dds);
if (dds.DepArray) {
builder.CreateFree(dds.DepArray);
}
@@ -4635,7 +4635,7 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
loopInfo->getPreheader());
llvm::OpenMPIRBuilder::InsertPointOrErrorTy afterBarrierIP =
moduleTranslation.getOpenMPBuilder()->createBarrier(
- builder.saveIP(), llvm::omp::OMPD_barrier);
+ builder, llvm::omp::OMPD_barrier);
if (failed(handleError(afterBarrierIP, *loopOp)))
return failure();
builder.restoreIP(*afterBarrierIP);
@@ -4832,9 +4832,10 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
builder.SetInsertPoint(tempTerminator);
llvm::OpenMPIRBuilder::InsertPointOrErrorTy contInsertPoint =
- ompBuilder->createReductions(
- builder.saveIP(), allocaIP, reductionInfos, isByRef,
- /*IsNoWait=*/false, /*IsTeamsReduction=*/false);
+ ompBuilder->createReductions(builder, allocaIP, reductionInfos,
+ isByRef,
+ /*IsNoWait=*/false,
+ /*IsTeamsReduction=*/false);
if (!contInsertPoint)
return contInsertPoint.takeError();
@@ -9796,8 +9797,7 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
return failure();
llvm::OpenMPIRBuilder::InsertPointOrErrorTy afterIP =
- ompBuilder->createBarrier(builder.saveIP(),
- llvm::omp::OMPD_barrier);
+ ompBuilder->createBarrier(builder, llvm::omp::OMPD_barrier);
LogicalResult res = handleError(afterIP, *op);
if (res.succeeded()) {
// If the barrier generated a cancellation check, the insertion
@@ -9810,7 +9810,7 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
if (failed(checkImplementationStatus(*op)))
return failure();
- ompBuilder->createTaskyield(builder.saveIP());
+ ompBuilder->createTaskyield(builder);
return success();
})
.Case([&](omp::FlushOp op) {
@@ -9825,7 +9825,7 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
//
// The argument list is discarded so that, flush with a list is
// treated same as a flush without a list.
- ompBuilder->createFlush(builder.saveIP());
+ ompBuilder->createFlush(builder);
return success();
})
.Case([&](omp::ParallelOp op) {
More information about the Mlir-commits
mailing list