[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
Mon Nov 11 07:14:43 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:
I feel slightly confused reading the comment and the current `if` expression. I read the comment as saying "... Thus, only early-return with this location if it's a valid location", but `!DL` is not a location we can use?
Should this be `if (DL && DL->getLine() != 0)` instead of `if (!DL || DL->getLine() != 0)`?
https://github.com/llvm/llvm-project/pull/107849
More information about the llvm-commits
mailing list