[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:37 PST 2025


================
@@ -308,14 +300,17 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
     return cir::GlobalViewAttr::get(type, symbol, indices);
   }
 
-  mlir::Value createGetGlobal(mlir::Location loc, cir::GlobalOp global) {
+  mlir::Value createGetGlobal(mlir::Location loc, cir::GlobalOp global,
+                              bool threadLocal = false) {
     assert(!cir::MissingFeatures::addressSpace());
-    return cir::GetGlobalOp::create(
-        *this, loc, getPointerTo(global.getSymType()), global.getSymName());
+    auto getGlobalOp = cir::GetGlobalOp::create(
+        *this, loc, getPointerTo(global.getSymType()), global.getSymNameAttr(),
+        threadLocal);
+    return getGlobalOp.getAddr();
----------------
andykaylor wrote:

Why is this necessary? Can't you just return the result of the `cir::GetGlobalOp::create` call directly as it was before?

https://github.com/llvm/llvm-project/pull/168662


More information about the cfe-commits mailing list