[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:11:19 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:
Especially as it is not the case that every `Constant` has a `Function`, at the conceptual level in LLVM
https://github.com/llvm/llvm-project/pull/151393
More information about the llvm-commits
mailing list