[llvm] [AIX][TLS] Produce a faster local-exec access sequence for the "aix-small-tls" global variable attribute (PR #83053)

zhijian lin via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 13:05:05 PDT 2024


================
@@ -7573,6 +7573,22 @@ static void reduceVSXSwap(SDNode *N, SelectionDAG *DAG) {
   DAG->ReplaceAllUsesOfValueWith(SDValue(N, 0), N->getOperand(0));
 }
 
+// Check if an SDValue has the 'aix-small-tls' global variable attribute.
+static bool hasAIXSmallTLSAttr(SDValue Val) {
+  GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(Val);
+  if (!GA)
+    return false;
+
+  const GlobalVariable *GV = dyn_cast<GlobalVariable>(GA->getGlobal());
+  if (!GV)
+    return false;
+
+  if (!GV->hasAttribute("aix-small-tls"))
+    return false;
+
+  return true;
----------------
diggerlin wrote:

I prefer change function code to 


```
static bool hasAIXSmallTLSAttr(SDValue Val) {
  if (GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(Val))
       if (GlobalVariable *GV = dyn_cast<GlobalVariable>(GA->getGlobal());
           if (GV->hasAttribute("aix-small-tls"))
                return true;
    return false;
}
```


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


More information about the llvm-commits mailing list