[llvm] GlobalOpt: Handle threadlocal.address intrinsic (PR #88454)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 13:38:55 PDT 2024


================
@@ -172,9 +172,20 @@ static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS,
           return true;
         GS.StoredType = GlobalStatus::Stored;
       } else if (const auto *CB = dyn_cast<CallBase>(I)) {
-        if (!CB->isCallee(&U))
-          return true;
-        GS.IsLoaded = true;
+        bool KnownIntrinsic = false;
+        if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
+          if (II->getIntrinsicID() == Intrinsic::threadlocal_address &&
----------------
efriedma-quic wrote:

No need to `dyn_cast<IntrinsicInst>(I)`; just use `CB->getIntrinsicID()`.  (Then, since the `if` isn't nested, you can eliminate the KnownIntrinsic variable.)

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


More information about the llvm-commits mailing list