[llvm] [DebugInfo][NewGVN] Salvage debug values of trivially dead instructions (PR #149304)

Shan Huang via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 17 06:53:50 PDT 2025


Apochens wrote:

> Are there are other calls to markInstructionForDeletion that should be accompanied by a salvage?

For now, I found this call to `markInstructionForDeletion` and the prior issue (#147511) should be accompanied by a salvage. The other ones mark instructions like `store` or `phi` instructions. For these instructions, we don't need to salvage the corresponding debug values (`salvageDebugInfo` cannot handle them).

> What's the consequences of putting the salvage call in markInstructionForDeletion instead?

As discussed in the prior issue (#147511), placing the salvage call into the following loop would introduce unnecessary computation overhead of salvaging.

https://github.com/llvm/llvm-project/blob/95cb8336d1598780d66eeb85d8fcb1c9a433a459/llvm/lib/Transforms/Scalar/NewGVN.cpp#L3527

Similarly, putting the salvage call into `markInstructionForDeletion` would lead to extra salvage operations on instructions like `store` or `phi` instructions marked for deletion. So, IMO, it's better to put the salvage at a place where fewer or no extra salvage operations would be introduced. 

https://github.com/llvm/llvm-project/pull/149304


More information about the llvm-commits mailing list