If a static variable (which is also a global variable) is defined in a function that is inlined and removed, then the concrete DIE of the function will not be created and the variable's DIE won't have the correct parent. Instead, delay the construction of static variable DIEs until finalizeModuleInfo() so that the abstract origin SP DIEs are available. This depends on https://reviews.llvm.org/D110294 because getOrCreateGlobalVariableDIE() should look for an abstract origin SP DIE in this case.
This fixes https://bugs.llvm.org/show_bug.cgi?id=30637
Some of this work was inspired by @krisb's work in https://reviews.llvm.org/D109703.
Rather than creating then deferring them - would it work if the whole creation were deferred until needed? (ie: move this loop:
from beginModule to finalizeModuleInfo?