[llvm] [AIX] Support per global code model. (PR #79202)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 10:28:47 PST 2024
================
@@ -466,6 +466,64 @@ static void collectTOCStats(PPCAsmPrinter::TOCEntryType Type) {
}
}
+static CodeModel::Model getCodeModel(const PPCSubtarget &S,
+ const TargetMachine &TM,
+ const MachineOperand &MO) {
+ CodeModel::Model ModuleModel = TM.getCodeModel();
+ // Per global code model is only support on AIX.
+ if (!S.isAIXABI())
+ return ModuleModel;
+
+ // 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 =
+ cast<GlobalVariable>(GV)->getCodeModel();
+ if (MaybeCodeModel)
+ return *MaybeCodeModel;
+
+ return ModuleModel;
+}
+
+static void checkPerGlobalCodeModel(const GlobalValue *GV, MCSymbol *Sym) {
+ // ELF per global code model not supported yet.
+ if (!isa<MCSymbolXCOFF>(Sym))
+ return;
+
+ // Symbols that aren't global variables cannot have the attribute.
+ if (!isa<GlobalVariable>(GV))
+ return;
+
+ const GlobalVariable *GVar = cast<GlobalVariable>(GV);
+ std::optional<CodeModel::Model> MaybeCM = GVar->getCodeModel();
----------------
diggerlin wrote:
nit: do not need to introduce a new variable GVar, since it only be used once
https://github.com/llvm/llvm-project/pull/79202
More information about the llvm-commits
mailing list