[llvm] [RISCV] Put Large Code Model Constant Pools in .text (PR #151393)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 10:10:55 PDT 2025
================
@@ -159,8 +159,20 @@ bool RISCVELFTargetObjectFile::isConstantInSmallSection(
}
MCSection *RISCVELFTargetObjectFile::getSectionForConstant(
- const DataLayout &DL, SectionKind Kind, const Constant *C,
- Align &Alignment) const {
+ const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment,
+ const Function *F) const {
+
+ // The large code model has to put constant pools close to the program, so we
+ // put them in the .text section. Large code model doesn't support PIC, so
+ // there should be no dynamic relocations that would require `.data.rel.ro`
+ // (which could be too far away anyway).
+ if (TM->getCodeModel() == CodeModel::Large) {
+ if (F)
----------------
lenary wrote:
It will never make it from the call-site to here, but the X86 Asm Printer makes a call without a function, which is why I chose a pointer rather than a reference, and pointers need to be checked for null-ness. It won't be hit, but I'd prefer it to cope with nullptr in case there are more call-sites in the future.
https://github.com/llvm/llvm-project/pull/151393
More information about the llvm-commits
mailing list