================
@@ -1656,7 +1680,20 @@ ConstantEmitter::emitAbstract(SourceLocation loc, const 
APValue &value,
 
 llvm::Constant *ConstantEmitter::tryEmitForInitializer(const VarDecl &D) {
   initializeNonAbstract(D.getType().getAddressSpace());
-  return markIfFailed(tryEmitPrivateForVarInit(D));
+  llvm::Constant *Init = tryEmitPrivateForVarInit(D);
+
+  // If a placeholder address was needed for a TLS variable, implying that the
+  // initializer's value depends on its address, then the object may not be
+  // initialized in .tdata because the initializer will be memcpy'd to the
+  // thread's TLS. Instead the initialization must be done in code.
+  if (!PlaceholderAddresses.empty() && D.getTLSKind() != VarDecl::TLS_None) {
+    for (auto &entry : PlaceholderAddresses)
----------------
fmayer wrote:

nit: Entry. Maybe use a structured binding?

https://github.com/llvm/llvm-project/pull/172119
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to