Currently, dbg.value's of "nullptr" are dropped when entering a SelectionDAG -- apparently just because of an oversight when recognising Values that are constant (see PR39787 [0]). This patch adds ConstantPointerNull to the list of constants that can be attached to DBG_VALUEs.
An open question is what to do about address-spaces and platforms where null is nonzero. Currently the code in SelectionDAGBuilder::getValueImpl just assumes that null is zero-valued, and I've read other parts of the code base that believe the default address space always has a zero valued null. To be conservative, I've assigned null to be zero-valued for the default address space only, all the others get "undef" (which is an improvement in itself).
(More could be done on address spaces, but this patch accounts for the common case, and avoids having to ask any hard questions about how address space plumbing really works).
I haven't added an individual test for this behaviour: instead DebugInfo/X86/sdag-dangling-dbgvalue.ll needed updating to represent the new DBG_VALUEs being present. That test should trip if dbg.value of null ever goes away. Alternately I can add a dedicated test if that's desirable.
How about: //Note: This assumes that all nullptr constants are zero-valued.