[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
================
@@ -466,6 +466,63 @@ static void collectTOCStats(PPCAsmPrinter::TOCEntryType Type) {
}
}
+static CodeModel::Model getCodeModel(const PPCSubtarget &S,
+ const TargetMachine &TM,
+ const MachineOperand &MO) {
+ assert(S.isAIXABI() && "ELF per global code model not supported yet");
+
+ CodeModel::Model ModuleModel = TM.getCodeModel();
+
+ // If the operand is not a global address then there is no
+ // global variable to carry an attribute.
+ if (!(MO.getType() == MachineOperand::MO_GlobalAddress))
+ return ModuleModel;
+
+ const GlobalValue *GV = MO.getGlobal();
+ assert(GV && "expected global for MO_GlobalAddress");
+
+ if (!isa<GlobalVariable>(GV))
+ return ModuleModel;
+
+ std::optional<CodeModel::Model> MaybeCodeModel =
+ dyn_cast<GlobalVariable>(GV)->getCodeModel();
----------------
diggerlin wrote:
dyn_cast maybe return a nullptr, do we need to check dyn_cast<GlobalVariable>(GV) not nullptr here ?
https://github.com/llvm/llvm-project/pull/79202
More information about the llvm-commits
mailing list