Previously CodeGen assumed that static locals were emitted before they
could be accessed, which is true for automatic storage duration locals.
However, it is possible to have CodeGen emit a nested function that uses
a static local before emitting the function that defines the static
local, breaking that assumption.
Fix it by splitting static local creation up into a getAddrOf phase and
a definition phase, as is done for other globals.
Fixes PR18020. See also previous attempts to fix static locals in
PR6769 and PR7101.
Does it still make sense for this to be on CodeGenFunction since it can now be called while emitting the "wrong" function? It seems to risk using local state of the CodeGenFunction object, which would be bad.