[clang] [CIR] Add support for thread-local storage (TLS) (PR #168662)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 3 13:49:38 PST 2025
================
@@ -1933,6 +1902,35 @@ void CIRGenModule::setGVPropertiesAux(mlir::Operation *op,
assert(!cir::MissingFeatures::opGlobalPartition());
}
+cir::TLS_Model CIRGenModule::GetDefaultCIRTLSModel() const {
+ switch (getCodeGenOpts().getDefaultTLSModel()) {
+ case CodeGenOptions::GeneralDynamicTLSModel:
+ return cir::TLS_Model::GeneralDynamic;
+ case CodeGenOptions::LocalDynamicTLSModel:
+ return cir::TLS_Model::LocalDynamic;
+ case CodeGenOptions::InitialExecTLSModel:
+ return cir::TLS_Model::InitialExec;
+ case CodeGenOptions::LocalExecTLSModel:
+ return cir::TLS_Model::LocalExec;
+ }
+ llvm_unreachable("Invalid TLS model!");
+}
+
+void CIRGenModule::setTLSMode(mlir::Operation *op, const VarDecl &d) const {
+ assert(d.getTLSKind() && "setting TLS mode on non-TLS var!");
+
+ auto tlm = GetDefaultCIRTLSModel();
----------------
andykaylor wrote:
```suggestion
cir::TLS_Model tlm = getDefaultCIRTLSModel();
```
Even though the function definition is right above here currently, I don't think we want to use `auto` here.
https://github.com/llvm/llvm-project/pull/168662
More information about the cfe-commits
mailing list