Prevent optimization of DebugLoc across section boundaries, such optimization will yield incorrect source location if memory layout of sections does not strictly match the Asm file.
Details
- Reviewers
dblaikie probinson MaskRay - Group Reviewers
debug-info - Commits
- rG971d982bd45c: Do not optimize debug locations across section boundaries
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This seems sensible and the test looks good. I've added other reviewers who might want to take a look.
Please could you add context to the patch (e.g. git diff -U9999)?
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | ||
---|---|---|
2049–2050 | I think it'd be worth splitting the new condition out to name it - or possibly just adding a comment instead. bool PrevInstInSameSection = PrevInstBB && PrevInstBB->getSectionIDNum() == MI->getParent()->getSectionIDNum(); if (DL == PrevInstLoc && PrevInstInSameSection) { And I'm not sure if I'm reading it right but should the condition be (!PrevInstBB || PrevInstBB->getSectionIDNum() == MI->getParent()->getSectionIDNum()) instead to maintain "first instruction" behaviour when DL is an unspecified location (!DL)? |
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | ||
---|---|---|
5 | Nit: It's more common to omit the blank line. | |
llvm/test/DebugInfo/debuglineinfo-at-section-boundary.ll | ||
2 | Drop -filetype=asm. It's the default and assumed by most `llc invocations. Drop -asm-verbose=0 as well. There is no difference in the output. The option isn't common to specify. |
Prevent optimization of DebugLoc across section boundaries, such optimization will yield incorrect source location if memory layout of sections does not strictly match the Asm file.
Consider adding the .loc 0 4 1 information to the summary (commit message).
DwarfDebug.cpp:
Remove empty line as per review
clang-format
testcase:
remove -filetype=asm and -asm-verbose=0 as per review.
[you may have noticed that the test was failing on Windows/ -basic-block-sections not supported]
I have moved and renamed the testcase to be more in sync with existing testcases for basic-block-sections
I do not have commit access, can someone with the proper credentials commit the patch? [if the the latest version looks ok]
Sorry I haven't been keeping up, but I have a suggestion for the test.
llvm/test/DebugInfo/X86/basic-block-sections-debug-lineinfo-at-section-boundary.ll | ||
---|---|---|
17 ↗ | (On Diff #520535) | This shows there are two .loc directives, but not that they are in different sections. I know I've seen redundant .loc directives and we even have a downstream patch to filter them out, so I think it would be good for this test to at least verify there's a .section directive between the two .loc directives. |
Nit: It's more common to omit the blank line.