[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 18:42:23 PDT 2024


================
@@ -1059,9 +1059,10 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn,
     if (Guard.isValid()) {
       // If we have a guard variable, check whether we've already performed
       // these initializations. This happens for TLS initialization functions.
-      llvm::Value *GuardVal = Builder.CreateLoad(Guard);
-      llvm::Value *Uninit = Builder.CreateIsNull(GuardVal,
-                                                 "guard.uninitialized");
+      llvm::Value *GuardVal = EmitLoadOfScalar(
+          MakeAddrLValue(Guard, getContext().IntTy), SourceLocation());
----------------
ChuanqiXu9 wrote:

I am slightly not happy with the use of `MakeAddrLValue` since the term `LValue` is a language concept in my mind and here are some codes for implementing details for the language to me. I may feel better to implement this with the `CreateThreadLocalAddress` API directly.

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


More information about the cfe-commits mailing list