[llvm] [AIX] Support per global code model. (PR #79202)
Sean Fertile via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 20:36:17 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();
----------------
mandlebug wrote:
We have an early return on `!isa<GlobalVariable>(GV))` so we know dyn_cast must not fail - and because of that I should be using cast<> instead. I'll update it.
https://github.com/llvm/llvm-project/pull/79202
More information about the llvm-commits
mailing list