[llvm] [PowerPC][AIX] Emit PowerPC version for XCOFF (PR #95510)
David Tenty via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 09:22:19 PDT 2024
================
@@ -517,6 +517,11 @@ bool AsmPrinter::doInitialization(Module &M) {
// On AIX, emit bytes for llvm.commandline metadata after .file so that the
// C_INFO symbol is preserved if any csect is kept by the linker.
if (TM.getTargetTriple().isOSBinFormatXCOFF()) {
+ // Emit .machine directive on AIX.
+ StringRef TargetCPU =
+ TM.getTargetCPU().empty() ? "pwr7" : TM.getTargetCPU();
----------------
daltenty wrote:
> We should use the "target-cpu" function attribute which is controlled by the clang frontend. No `-mcpu` case is also handled well in "target-cpu" function attribute. We
Yeah, "target-cpu" is something we ideally should be handling here, but I think there are some he tricky parts to this. "target-cpu" is a function level attribute and we are emitting a module level attribute. To do this right, we'd need to know the newest level we saw in the whole module (there definitely could be a mix, for example if we got LTO involved).
Then it's also possible that we have no "target-cpu" attr (since I don't believe frontends are required to emit it) and and ` TM.getTargetCPU().empty()`. Looking into it, in that case I believe we will already get something unexpected on AIX, since in seems like the backend will fallback to the "generic" ppc CPU (which is well below `PWR7`):
https://github.com/llvm/llvm-project/blob/8fe376f5ecf908856a4e817015c5796ca5307dae/llvm/lib/Target/PowerPC/PPCSubtarget.cpp#L76
https://github.com/llvm/llvm-project/blob/8fe376f5ecf908856a4e817015c5796ca5307dae/llvm/lib/Target/PowerPC/PPC.td#L554
so maybe we should be returning something more appropriate for that "generic" CPU here (not `PWR7`) if we want to be consistent with the actual codegen?
https://github.com/llvm/llvm-project/pull/95510
More information about the llvm-commits
mailing list