[llvm] [DWARF] Emit a worst-case prologue_end flag for pathological inputs (PR #107849)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 02:25:17 PST 2024
================
@@ -2192,12 +2279,20 @@ DwarfDebug::emitInitialLocDirective(const MachineFunction &MF, unsigned CUID) {
bool IsEmptyPrologue = PrologEnd.second;
// If the prolog is empty, no need to generate scope line for the proc.
- if (IsEmptyPrologue)
+ if (IsEmptyPrologue) {
// In degenerate cases, we can have functions with no source locations
- // at all. These want a scope line, to avoid a totally empty function.
- // Thus, only skip scope line if there's location to place prologue_end.
- if (PrologEndLoc)
- return PrologEndLoc;
+ // at all, or only empty ones. These want a scope line, to avoid a totally
+ // empty function. Thus, only skip the scope line if there's location to
+ // place prologue_end.
+ if (PrologEndLoc) {
+ const DebugLoc &DL = PrologEndLoc->getDebugLoc();
+ if (!DL || DL->getLine() != 0)
----------------
OCHyams wrote:
Oh right, yep I see that now, thanks. This all feels a bit tangled up in an unfortunate way, but I've not got any immediate ideas (possibly there's some way of refactoring this, but maybe not), so LGTM.
https://github.com/llvm/llvm-project/pull/107849
More information about the llvm-commits
mailing list