[llvm] [mlir] [OMPIRBuilder] Don't generate DISubprogram for outlined function. (PR #138149)
Sergio Afonso via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 05:40:35 PDT 2025
================
@@ -4982,6 +4982,20 @@ static LogicalResult
convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
auto targetOp = cast<omp::TargetOp>(opInst);
+ // The current debug location already has the DISubprogram for the outlined
+ // function that will be created for the target op. We save it here so that
+ // we can set it on the outlined function.
+ llvm::DebugLoc OutlinedFnLoc = builder.getCurrentDebugLocation();
+ // During the handling of target op, we will generate instructions in the
+ // parent function like call to oulined function or branch to new BasicBlock.
+ // We set the debug location here to parent function so that those get the
+ // correct debug locations. For outlined functions, the normal MLIR op
+ // conversion will automatically pick the correct location.
+ llvm::BasicBlock *parentBB = builder.GetInsertBlock();
+ if (parentBB && !parentBB->empty())
+ builder.SetCurrentDebugLocation(parentBB->back().getDebugLoc());
+ else
+ builder.SetCurrentDebugLocation(llvm::DebugLoc());
if (failed(checkImplementationStatus(opInst)))
----------------
skatrak wrote:
Nit: The call to `checkImplementationStatus` should probably be first, to avoid doing unnecessary work if we find out the operation is not supported yet.
https://github.com/llvm/llvm-project/pull/138149
More information about the llvm-commits
mailing list