[BOLT] Never emit "large" functions (#115974)
"Large" functions are functions that are too big to fit into their original slots after code modifications. CheckLargeFunctions pass is designed to prevent such functions from emission. Extend this pass to work with functions with constant islands. Now that CheckLargeFunctions covers all functions, it guarantees that we will never see such functions after code emission on all platforms (previously it was guaranteed on x86 only). Hence, we can get rid of RewriteInstance extensions that were meant to support "large" functions.
This commit is contained in:
@@ -3807,7 +3807,6 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
|
||||
if (!Function.isEmitted())
|
||||
continue;
|
||||
|
||||
bool TooLarge = false;
|
||||
ErrorOr<BinarySection &> FuncSection = Function.getCodeSection();
|
||||
assert(FuncSection && "cannot find section for function");
|
||||
FuncSection->setOutputAddress(Function.getAddress());
|
||||
@@ -3818,11 +3817,8 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
|
||||
MapSection(*FuncSection, Function.getAddress());
|
||||
Function.setImageAddress(FuncSection->getAllocAddress());
|
||||
Function.setImageSize(FuncSection->getOutputSize());
|
||||
if (Function.getImageSize() > Function.getMaxSize()) {
|
||||
assert(!BC->isX86() && "Unexpected large function.");
|
||||
TooLarge = true;
|
||||
FailedAddresses.emplace_back(Function.getAddress());
|
||||
}
|
||||
assert(Function.getImageSize() <= Function.getMaxSize() &&
|
||||
"Unexpected large function");
|
||||
|
||||
// Map jump tables if updating in-place.
|
||||
if (opts::JumpTables == JTS_BASIC) {
|
||||
@@ -3852,19 +3848,11 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
|
||||
assert(ColdSection && "cannot find section for cold part");
|
||||
// Cold fragments are aligned at 16 bytes.
|
||||
NextAvailableAddress = alignTo(NextAvailableAddress, 16);
|
||||
if (TooLarge) {
|
||||
// The corresponding FDE will refer to address 0.
|
||||
FF.setAddress(0);
|
||||
FF.setImageAddress(0);
|
||||
FF.setImageSize(0);
|
||||
FF.setFileOffset(0);
|
||||
} else {
|
||||
FF.setAddress(NextAvailableAddress);
|
||||
FF.setImageAddress(ColdSection->getAllocAddress());
|
||||
FF.setImageSize(ColdSection->getOutputSize());
|
||||
FF.setFileOffset(getFileOffsetForAddress(NextAvailableAddress));
|
||||
ColdSection->setOutputAddress(FF.getAddress());
|
||||
}
|
||||
FF.setAddress(NextAvailableAddress);
|
||||
FF.setImageAddress(ColdSection->getAllocAddress());
|
||||
FF.setImageSize(ColdSection->getOutputSize());
|
||||
FF.setFileOffset(getFileOffsetForAddress(NextAvailableAddress));
|
||||
ColdSection->setOutputAddress(FF.getAddress());
|
||||
|
||||
LLVM_DEBUG(
|
||||
dbgs() << formatv(
|
||||
@@ -3872,9 +3860,6 @@ void RewriteInstance::mapCodeSections(BOLTLinker::SectionMapper MapSection) {
|
||||
FF.getImageAddress(), FF.getAddress(), FF.getImageSize()));
|
||||
MapSection(*ColdSection, FF.getAddress());
|
||||
|
||||
if (TooLarge)
|
||||
BC->deregisterSection(*ColdSection);
|
||||
|
||||
NextAvailableAddress += FF.getImageSize();
|
||||
}
|
||||
|
||||
@@ -5814,7 +5799,7 @@ void RewriteInstance::writeEHFrameHeader() {
|
||||
getFileOffsetForAddress(NextAvailableAddress);
|
||||
|
||||
std::vector<char> NewEHFrameHdr = CFIRdWrt->generateEHFrameHeader(
|
||||
RelocatedEHFrame, NewEHFrame, EHFrameHdrOutputAddress, FailedAddresses);
|
||||
RelocatedEHFrame, NewEHFrame, EHFrameHdrOutputAddress);
|
||||
|
||||
Out->os().seek(EHFrameHdrFileOffset);
|
||||
Out->os().write(NewEHFrameHdr.data(), NewEHFrameHdr.size());
|
||||
|
||||
Reference in New Issue
Block a user