Skip to content

[DebugInfo][NewGVN] Deleting instructions without salvaging their debug values #147511

@Apochens

Description

@Apochens

In NewGVN, NewGVN::eliminateInstructions deletes instructions by first marking them for deletion. In the following code, the instruction is deleted after being marked without having its debug value salvaged.

markInstructionForDeletion(DefI);

Here is an example: https://godbolt.org/z/K4EanM9Ka. In this example, %add2 is deleted and its debug value becomes poison.

; Before NewGVN
define void @binop(i32 %x, i32 %y) !dbg !5 {
  %add1 = add i32 %x, %y, !dbg !12
    #dbg_value(i32 %add1, !9, !DIExpression(), !12)
  %add2 = add i32 %y, %x, !dbg !13
    #dbg_value(i32 %add2, !11, !DIExpression(), !13)
  call void @use(i32 %add1, i32 %add2), !dbg !14
  ret void, !dbg !15
}

; After NewGVN
define void @binop(i32 %x, i32 %y) !dbg !5 {
  %add1 = add i32 %x, %y, !dbg !12
    #dbg_value(i32 %add1, !9, !DIExpression(), !12)
    #dbg_value(i32 poison, !11, !DIExpression(), !13)
  call void @use(i32 %add1, i32 %add1), !dbg !14
  ret void, !dbg !15
}

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