================
Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1599
@@ +1598,3 @@
+ if (!isThreadLocalBackingVariableAlwaysReferenceable(VD, CGM))
+ return VD->hasDefinition() ? llvm::GlobalValue::WeakAnyLinkage
+ : llvm::GlobalValue::ExternalLinkage;
----------------
Richard Smith wrote:
> Hmm, what's the motivation for making this weak? Should it be strong if the
> `thread_local` variable is a strong definition?
>
> (I'm also not completely sure whether `WeakAny` or `WeakODR` is appropriate
> for the case where the variable *is* weak; I *think* the intent is for the
> underlying mechanism to be replaceable, which implies using `WeakAny`.)
It's a strong definition but an internal one.
`WeakODR` permits inlining of the thread-wrapper. This, in turn, allows
references to the internal backing store of the variable to be proliferated if
the thread-wrapper gets inlined.
================
Comment at: test/CodeGenCXX/tls-init-funcs.cpp:6-7
@@ -5,2 +5,4 @@
+// CHECK: call {{.*}} @_ZTW3ext()
+// CHECK: declare hidden {{.*}} @_ZTW3ext()
// CHECK: define weak hidden {{.*}} @_ZTW1a
----------------
Richard Smith wrote:
> Why are these marked as `hidden`? Don't they need to be visible to support
> cross-DSO linking of `thread_local` variables?
ToT clang makes the thread-wrapper hidden. ItaniumCXXABI.cpp has the following
comment in it:
> Always resolve references to the wrapper at link time.
It was added by you in r179858.
http://reviews.llvm.org/D4109
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits