diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-09-10 20:14:30 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-09-10 20:14:30 +0000 |
commit | d8110b6558ad111a1c1c1542c12122900791311e (patch) | |
tree | f33978db28811dcedd14fcba833b925738598b84 /clang/lib/CodeGen/ItaniumCXXABI.cpp | |
parent | 1cee407a9b5cec3251157378e9d44dacae51b68d (diff) | |
download | bcm5719-llvm-d8110b6558ad111a1c1c1542c12122900791311e.tar.gz bcm5719-llvm-d8110b6558ad111a1c1c1542c12122900791311e.zip |
[ms-cxxabi] Implement guard variables for static initialization
Static locals requiring initialization are not thread safe on Windows.
Unfortunately, it's possible to create static locals that are actually
externally visible with inline functions and templates. As a result, we
have to implement an initialization guard scheme that is compatible with
TUs built by MSVC, which makes thread safety prohibitively difficult.
MSVC's scheme is that every function that requires a guard gets an i32
bitfield. Each static local is assigned a bit that indicates if it has
been initialized, up to 32 bits, at which point a new bitfield is
created. MSVC rejects inline functions with more than 32 static locals,
and the externally visible mangling (?_B) only allows for one guard
variable per function.
On Eli's recommendation, I used MangleNumberingContext to track which
bit each static corresponds to.
Implements PR16888.
Reviewers: rjmccall, eli.friedman
Differential Revision: http://llvm-reviews.chandlerc.com/D1416
llvm-svn: 190427
Diffstat (limited to 'clang/lib/CodeGen/ItaniumCXXABI.cpp')
-rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 980face2176..b08e9b7462c 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -1142,7 +1142,7 @@ void ItaniumCXXABI::EmitGuardedInit(CodeGenFunction &CGF, SmallString<256> guardName; { llvm::raw_svector_ostream out(guardName); - getMangleContext().mangleItaniumGuardVariable(&D, out); + getMangleContext().mangleStaticGuardVariable(&D, out); out.flush(); } |