With assignment tracking enabled debug intrinsics are ignored by SelectionDAG and it instead reads location definitions generated by the analysis pass.
SelectionDAG itself has no fundamental need to refer to debug intrinsics directly so this change is fairly straightforward.
The analysis results are used in SelectionDAGBuilder::visit - fetching the batch of definitions that come just before each instruction that is about to be processed, and processing them as if they were debug intrinsics. They're also used in SelectionDAGISel::SelectAllBasicBlocks where dbg.declare intrinsic behaviour is mimicked for single memory location defs.
DanglingDebugInfo has been updated to point to a either a DbgValueInst or a VarLocRecord, and its API has been updated to fetch information from whichever it was initialised with.
With this, tests can be added - coming in the next patch.
Since processDbgDeclares is not the only function that will call this now-extracted code, probably best to just use the name of this function directly so as not to mislead.