diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-10-08 01:07:54 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-10-08 01:07:54 +0000 |
commit | 453e0564673e85dc9b98e60e0e54f2e65d42d81b (patch) | |
tree | 4e5f1f501f3249a9288869cd76d5139a0f0ce28e /clang/lib/CodeGen/CodeGenModule.h | |
parent | 1256198bbcccc66632810d0d3df748af38351b0f (diff) | |
download | bcm5719-llvm-453e0564673e85dc9b98e60e0e54f2e65d42d81b.tar.gz bcm5719-llvm-453e0564673e85dc9b98e60e0e54f2e65d42d81b.zip |
Fix IRGen for referencing a static local before emitting its decl
Summary:
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 creating the static local upon access and ensuring that the
deferred function body gets emitted. We may not be able to emit the
initializer properly from outside the function body, so don't try.
Fixes PR18020. See also previous attempts to fix static locals in
PR6769 and PR7101.
Reviewers: rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D4787
llvm-svn: 219265
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 8334f7ce8bc..955f665f86c 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -549,6 +549,10 @@ public: StaticLocalDeclMap[D] = C; } + llvm::Constant * + getOrCreateStaticVarDecl(const VarDecl &D, + llvm::GlobalValue::LinkageTypes Linkage); + llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) { return StaticLocalDeclGuardMap[D]; } |