Skip to content

[DebugInfo][NewGVN] Debug value loss caused by the missing salvage #149301

@Apochens

Description

@Apochens

NewGVN deletes trivially dead instructions without salvaging the corresponding debug values (markInstructionForDeletion(&I)).

if (isInstructionTriviallyDead(&I, TLI)) {
InstrDFS[&I] = 0;
LLVM_DEBUG(dbgs() << "Skipping trivially dead instruction " << I << "\n");
markInstructionForDeletion(&I);
continue;
}

Here is an example: https://godbolt.org/z/G4PWEv6nr. In this example, the icmp instruction is deleted without its debug value being slavaged.

Before the deletion:

bb1:
  %tmp = load i8, ptr null, align 1, !dbg !25
    #dbg_value(i8 %tmp, !9, !DIExpression(), !25)
  %tmp2 = icmp eq i8 %tmp, 8, !dbg !26
    #dbg_value(i1 %tmp2, !11, !DIExpression(), !26)
  br label %bb3, !dbg !27

After the deletion:

bb1:
  %tmp = load i8, ptr null, align 1, !dbg !25
    #dbg_value(i8 %tmp, !9, !DIExpression(), !25)
    #dbg_value(i1 poison, !11, !DIExpression(), !26)
  br label %bb3, !dbg !27

Metadata

Metadata

Assignees

No one assigned

    Labels

    debuginfollvm:GVNGVN and NewGVN stages (Global value numbering)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions