[llvm-branch-commits] [clang] [Clang] Add pointer field protection feature. (PR #172119)
Florian Mayer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 13 08:30:20 PST 2026
================
@@ -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
More information about the llvm-branch-commits
mailing list