Similar to imported declarations and types, the patch tracks function-local
static variables (globals in terms of LLVM IR) in DISubprogram's 'retainedNodes'.
DwarfDebug is adjusted in accordance with the aforementioned metadata change and
provided a support of static locals scoped by a lexical block.
CodeViewDebug is modified to collect global variables from DISubprogram's
'retainedNodes' too.
The patch assumes that DICompileUnit's 'globals' no longer tracks static locals
and DwarfDebug would assert if any locally-scoped variables get placed there.
Have you thought about adding this support to CodeView as well? I believe that a similar code could be added to CodeViewDebug::endModule() for the CodeView emission to display static locals in proper lexical blocks.