[llvm] [mlir] [OMPIRBuilder] Don't generate DISubprogram for outlined function. (PR #138149)

Abid Qadeer via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 18 08:28:16 PDT 2025


================
@@ -4982,9 +4982,27 @@ 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();
   if (failed(checkImplementationStatus(opInst)))
     return failure();
 
+  // During the handling of target op, we will generate instructions in the
+  // parent function like call to the oulined function or branch to a 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();
+  assert(parentBB);
----------------
abidh wrote:

Done.

https://github.com/llvm/llvm-project/pull/138149


More information about the llvm-commits mailing list