Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lld/MachO/ICF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,25 @@ static Symbol *getThunkTargetSymbol(ConcatInputSection *isec) {
// direct branch thunk rather than containing a full copy of the actual function
// body.
void ICF::applySafeThunksToRange(size_t begin, size_t end) {
// When creating a unique ICF thunk, use the first section as the section that
// all thunks will branch to.
ConcatInputSection *masterIsec = icfInputs[begin];

// If the first section is not address significant, sorting guarantees that
// there are no address significant functions. So we can skip this range.
if (!masterIsec->keepUnique)
return;

// Skip anything that is not a code section.
if (!isCodeSection(masterIsec))
return;

// If the functions we're dealing with are smaller than the thunk size, then
// just leave them all as-is - creating thunks would be a net loss.
uint32_t thunkSize = target->getICFSafeThunkSize();
if (icfInputs[begin]->data.size() <= thunkSize)
if (masterIsec->data.size() <= thunkSize)
return;

// When creating a unique ICF thunk, use the first section as the section that
// all thunks will branch to.
ConcatInputSection *masterIsec = icfInputs[begin];

// Get the symbol that all thunks will branch to.
Symbol *masterSym = getThunkTargetSymbol(masterIsec);

Expand Down
Loading