Fixed PR51501 (tests from D112337).
This patch proposes two changes that get squashed to this single patch due to
their close dependencies:
- Reuse of DISubprogram's 'retainedNodes' to track other function-local entities together with local variables and labels (this patch cares about function-local import while D144006 and D144008 use the same approach for local types and static variables). So, effectively this patch moves ownership of tracking local import from DICompileUnit's 'imports' field to DISubprogram's 'retainedNodes' and adjusts DWARF emitter for the new layout. The old layout is considered unsupported (DwarfDebug would assert on such debug metadata).
DICompileUnit's 'imports' field is supposed to track global imported declarations as it does before.
This addresses various FIXMEs and simplifies the next part of the patch.
- Postpone emission of function-local imported entities from DwarfDebug::endFunctionImpl() to DwarfDebug::endModule(). While in DwarfDebug::endFunctionImpl() we do not have all the information about a parent subprogram or a referring subprogram (whether a subprogram inlined or not), so we can't guarantee we emit an imported entity correctly and place it in a proper subprogram tree. So now, we just gather needed details about the import itself and its parent entity (either a Subprogram or a LexicalBlock) during processing in DwarfDebug::endFunctionImpl(), but all the real work is done in DwarfDebug::endModule() when we have all the required information to make proper emission.