-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) #83175
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-codegen Author: Aleksei Vetrov (noxwell) ChangesUse Fixes #83174 Full diff: https://github.com/llvm/llvm-project/pull/83175.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index c2c01439f2dc99..2a24cc1a9dc020 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -628,9 +628,8 @@ void CGDebugInfo::CreateCompileUnit() {
// file was specified with an absolute path.
if (CSKind)
CSInfo.emplace(*CSKind, Checksum);
- llvm::DIFile *CUFile = DBuilder.createFile(
- remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
- getSource(SM, SM.getMainFileID()));
+ llvm::DIFile *CUFile = createFile(
+ MainFileName, CSInfo, getSource(SM, SM.getMainFileID()));
StringRef Sysroot, SDK;
if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
704f904
to
237264f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for this?
remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo, | ||
getSource(SM, SM.getMainFileID())); | ||
llvm::DIFile *CUFile = | ||
createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is MainFileName no longer being remapped here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGDebugInfo::createFile
takes care of remapping, see std::string RemappedFile = remapDIPath(FileName)
.
…CompileUnit Use `CGDebugInfo::createFile` wrapper that handles file remapping and corner cases instead of directly using `DBuilder.createFile` in `CGDebugInfo::CreateCompileUnit`. Add test to check corner case with remapping absolute path to relative. Fixes llvm#83174
237264f
to
731463e
Compare
I added a test for remapping of absolute path. It passes with this PR and fails on trunk. However, I found much bigger problem. This fix fails test
It looks like there may be a problem in the standard: you can't have DW_TAG_compile_unit that references file by relative path, but not relative to DW_AT_comp_dir. What do you think? |
// CHECK: = distinct !DICompileUnit({{.*}}file: ![[#CUFILE:]] | ||
// CHECK: ![[#CUFILE]] = !DIFile( | ||
// CHECK-NOT: directory: "./out" | ||
// CHECK-SAME: filename: "./src{{[^"]+}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you compare this to other tests with paths in them? In my memory you need to do some fancy regex for the /
path separator work under Windows.
Closing this PR, because these changes are incompatible to DWARF standard, see 83175#issuecomment-1969473992 |
Use
CGDebugInfo::createFile
wrapper that handles file remapping and corner cases instead of directly usingDBuilder.createFile
inCGDebugInfo::CreateCompileUnit
.Fixes #83174