[PATCH] D149294: Do not optimize debug locations across section boundaries

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 09:39:15 PDT 2023


Orlando added reviewers: debug-info, dblaikie, probinson.
Orlando added a comment.

This seems sensible and the test looks good. I've added other reviewers who might want to take a look.



================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2049-2050
 
-  if (DL == PrevInstLoc) {
+  if (DL == PrevInstLoc && PrevInstBB &&
+      PrevInstBB->getSectionIDNum() == MI->getParent()->getSectionIDNum())  {
     // If we have an ongoing unspecified location, nothing to do here.
----------------
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`)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149294/new/

https://reviews.llvm.org/D149294



More information about the llvm-commits mailing list