[llvm] [RISCV] Put Large Code Model Constant Pools in .text (PR #151393)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 11:25:39 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)
----------------
efriedma-quic wrote:
Generally, if you actually need a constant, either you're emitting a function, or you're emitting a global. Otherwise, what's actually going to use the constant?
But I guess it's not a big deal either way.
https://github.com/llvm/llvm-project/pull/151393
More information about the llvm-commits
mailing list