[PATCH] Fix IRGen for referencing a static local before emitting its decl
Reid Kleckner
rnk at google.com
Mon Aug 4 19:31:40 PDT 2014
Hi rsmith,
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.
http://reviews.llvm.org/D4787
Files:
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGenCXX/static-local-in-local-class.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4787.12185.patch
Type: text/x-patch
Size: 8647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140805/45748aa6/attachment.bin>
More information about the cfe-commits
mailing list