Analyze SCEV expression after IR is removed clarification

In short:

Shall analysis of a SCEV expression be allowed even though part of the IR that was analyzed to build the SCEV expression has been removed?

In more detail with background:

About a month ago I landed where SCEV is used to do additional debug-info salvaging in LSR. The idea was to compute (and store) a SCEV of what llvm.dbg.value intrinsics inside the loop refers to and then after LSR transformation compare these SCEVs with the current SCEVs of PHI-nodes of the loop header. If any of these match (with a possible offset) then the llvm.dbg.value intrinsic can be updated to refer to the PHI-node (with a possible offset in the DIExpression).

This use-case obviously depends on being able to analyze a SCEV where parts of the corresponding IR has been removed.

Now last week was reported which raises the question if this is allowed use-case or not.

Clearly if the Value that a SCEVUnknown refers to has been deleted then that renders the entire SCEV useless. But if only IR that SCEV has successfully “analyzed through” is removed then I would argue that the SCEV expression should still be analyzable.

Thoughts, comments and clarifications are welcome.