This patch resolves an issue reported in review https://reviews.llvm.org/D91722 (post-commit). The error in this case is simple: during the lambda function hasUnknownVReg, used to determine whether an SDDbgValue has any unresolved VReg arguments, constructs an SDValue from any SDNode operands to the debug value. The constructor for an SDValue asserts that it is a valid value; this means that when a debug value has an invalid operand, this check will trigger that assertion and crash the compiler.
The solution in this patch is to only perform this check if !SDDbgValue->isInvalidated(); the check is irrelevant for an invalidated debug value in the first place, because we will set all of its operands to undef, so it doesn't matter whether any of its arguments are unresolved at that point. This check is not used to determine the "correct" insert location for a DBG_VALUE, only the first location where it can be valid, so there should be no harm in short-circuiting this way.
You could add --implicit-check-not=DBG_VALUE to FileCheck and remove the CHECK-NOTs? No strong opinion on this though.