[llvm] [AIX] Support per global code model. (PR #79202)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 09:58:16 PST 2024


================
@@ -561,6 +561,43 @@ static bool hasTocDataAttr(SDValue Val, unsigned PointerSize) {
   return true;
 }
 
+static CodeModel::Model getCodeModel(const PPCSubtarget &Subtarget,
+                                     const TargetMachine &TM,
+                                     const SDNode *Node) {
+  // If there isn't an attribute to override the module code model
+  // this will be the effective code model.
+  CodeModel::Model ModuleModel = TM.getCodeModel();
+
+  // Initially support per global code model for AIX only.
+  if (!Subtarget.isAIXABI())
+    return ModuleModel;
+
+  // If the operand is not a global address there is no
+  // GlobalVariable to query for an attribute.
+  SDValue Operand = Node->getOperand(0);
+  if (!isa<GlobalAddressSDNode>(Operand))
+    return ModuleModel;
+
+  GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Operand);
+  if (!GA)
----------------
diggerlin wrote:

just curiously  ,
if `isa<GlobalAddressSDNode>(Operand)` is true,

is there possibility that  GA==nullptr?

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


More information about the llvm-commits mailing list