[SelectionDAG] Fix crash for salvaging with indirect debug values (#72645)
commitc093383ffadff8dfadfd6bc0ab7107a0e194aa7e
authorDavid Stenberg <david.stenberg@ericsson.com>
Sat, 18 Nov 2023 16:01:27 +0000 (18 17:01 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Nov 2023 16:01:27 +0000 (18 17:01 +0100)
tree8ffc7abf98d870b32b5e113121182963c95000a9
parentb00e2f2a5f3e48fbbe2324b0b371e5657ccd969c
[SelectionDAG] Fix crash for salvaging with indirect debug values (#72645)

This is a follow-up to #68981, and fix for #72630, #72447.

We may end up in SelectionDAG::salvageDebugInfo() with indirect debug
values, and attempting to salvage ADD nodes with non-constant RHS would
lead us to try to turn those indirect debug values variadic, which is
not allowed.

This triggered the following assert in the SDDbgValue constructor:

  Assertion `!(IsVariadic && IsIndirect)' failed.

This also adds a lit test for salvaging when having an indirect debug
value and constant RHS, as there seems like there was no such lit test.
However, I am not sure if the use of the stack_value operation is
correct in that case (which is existing behavior before #68981), but
that at least documents the current behavior.
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/DebugInfo/X86/salvage-add-node-indirect.ll [new file with mode: 0644]