[BOLT] LongJmp: Check for shouldEmit

Check that the function will be emitted in the final binary. Preserving
old function address is needed in case it is PLT trampiline, that is
currently not moved by the BOLT.

Differential Revision: https://reviews.llvm.org/D122098
This commit is contained in:
Vladislav Khmelevsky 2022-03-20 16:10:27 +03:00
parent fed958c6cc
commit 4c14519ecb
2 changed files with 8 additions and 0 deletions

View File

@ -1534,6 +1534,9 @@ void BinaryContext::preprocessDebugInfo() {
}
bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
if (Function.isPseudo())
return false;
if (opts::processAllFunctions())
return true;

View File

@ -345,6 +345,11 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
CurrentIndex = 0;
bool ColdLayoutDone = false;
for (BinaryFunction *Func : SortedFunctions) {
if (!BC.shouldEmit(*Func)) {
HotAddresses[Func] = Func->getAddress();
continue;
}
if (!ColdLayoutDone && CurrentIndex >= LastHotIndex) {
DotAddress =
tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress);