[clang] [Clang] Remap paths in OpenMP runtime calls (#82541) (PR #141250)
Dan McGregor via cfe-commits
cfe-commits at lists.llvm.org
Fri May 23 09:44:49 PDT 2025
https://github.com/dankm updated https://github.com/llvm/llvm-project/pull/141250
>From 7fdc69f5c55074fa9d647b01f4a370a34c26f966 Mon Sep 17 00:00:00 2001
From: Dan McGregor <dan.mcgregor at usask.ca>
Date: Fri, 23 May 2025 10:19:22 -0600
Subject: [PATCH] [Clang] Remap paths in OpenMP runtime calls
Apply the debug prefix mapping to the OpenMP location strings.
Fixes https://github.com/llvm/llvm-project/issues/82541
---
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index e458d437d085a..d77e624c5edbe 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1352,7 +1352,12 @@ static StringRef getIdentStringFromSourceLocation(CodeGenFunction &CGF,
llvm::raw_svector_ostream OS(Buffer);
// Build debug location
PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
- OS << ";" << PLoc.getFilename() << ";";
+ OS << ";";
+ if (CGF.getDebugInfo())
+ OS << CGF.getDebugInfo()->remapDIPath(PLoc.getFilename());
+ else
+ OS << PLoc.getFilename();
+ OS << ";";
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl))
OS << FD->getQualifiedNameAsString();
OS << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
@@ -1370,10 +1375,14 @@ llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
SrcLocStr = OMPBuilder.getOrCreateDefaultSrcLocStr(SrcLocStrSize);
} else {
std::string FunctionName;
+ std::string FileName;
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl))
FunctionName = FD->getQualifiedNameAsString();
PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
- const char *FileName = PLoc.getFilename();
+ if (CGF.getDebugInfo())
+ FileName = CGF.getDebugInfo()->remapDIPath(PLoc.getFilename());
+ else
+ FileName = PLoc.getFilename();
unsigned Line = PLoc.getLine();
unsigned Column = PLoc.getColumn();
SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FunctionName, FileName, Line,
@@ -8840,10 +8849,14 @@ emitMappingInformation(CodeGenFunction &CGF, llvm::OpenMPIRBuilder &OMPBuilder,
ExprName = MapExprs.getMapDecl()->getNameAsString();
}
+ std::string FileName;
PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
- return OMPBuilder.getOrCreateSrcLocStr(PLoc.getFilename(), ExprName,
- PLoc.getLine(), PLoc.getColumn(),
- SrcLocStrSize);
+ if (CGF.getDebugInfo())
+ FileName = CGF.getDebugInfo()->remapDIPath(PLoc.getFilename());
+ else
+ FileName = PLoc.getFilename();
+ return OMPBuilder.getOrCreateSrcLocStr(FileName, ExprName, PLoc.getLine(),
+ PLoc.getColumn(), SrcLocStrSize);
}
/// Emit the arrays used to pass the captures and map information to the
/// offloading runtime library. If there is no map or capture information,
More information about the cfe-commits
mailing list