[PATCH] CodeGen: Don't emit a thread-wrapper if we can't touch the backing variable
Richard Smith
richard at metafoo.co.uk
Fri Jun 27 08:39:53 PDT 2014
================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1580
@@ +1579,3 @@
+ // the thread wrapper instead of directly referencing the backing variable.
+ return VD->getTLSKind() != VarDecl::TLS_Dynamic ||
+ !CGM.getTarget().getTriple().isMacOSX();
----------------
`thread_local` local variables should presumably not be covered by this special case... though perhaps we never get here for those?
================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1596-1597
@@ -1586,7 +1595,4 @@
- // All accesses to the thread_local variable go through the thread wrapper.
- // However, this means that we cannot allow the thread wrapper to get inlined
- // into any functions.
- if (VD->getTLSKind() == VarDecl::TLS_Dynamic &&
- CGM.getTarget().getTriple().isMacOSX())
- return llvm::GlobalValue::WeakAnyLinkage;
+ // The thread wrapper can't be inlined if the backing variable cannot always
+ // be referenced.
+ if (!isThreadLocalBackingVariableAlwaysReferenceable(VD, CGM)) {
----------------
I think this comment should explain that we intend for the thread wrapper to be replaceable; otherwise, someone looking at this will wonder why we don't use the noinline attribute instead. Maybe `isThreadLocalBacking...` should instead be called `isThreadWrapperReplaceable`?
http://reviews.llvm.org/D4109
More information about the cfe-commits
mailing list