-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[RISCV] Put Large Code Model Constant Pools in .text #151393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2a58a45
f74d1cb
82debbb
71c1056
d4391a3
73c32ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it actually possible for F to be null here? It looks like every caller passes in a Function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Especially as it is not the case that every There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
return SectionForGlobal(F, SectionKind::getText(), *TM); | ||
else | ||
return TextSection; | ||
} | ||
|
||
if (C && isConstantInSmallSection(DL, C)) { | ||
if (Kind.isMergeableConst4()) | ||
return SmallROData4Section; | ||
|
@@ -177,5 +189,5 @@ MCSection *RISCVELFTargetObjectFile::getSectionForConstant( | |
|
||
// Otherwise, we work the same as ELF. | ||
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C, | ||
Alignment); | ||
Alignment, F); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.