Skip to content

Commit

Permalink
[BOLT] Fix jump table placement for non-simple functions
Browse files Browse the repository at this point in the history
Summary:
When we move a jump table to either hot or cold new section
(-jump-tables=move), we rely on a number of taken branches from the table
to decide if it's hot or cold. However, if the function is non-simple, we
always get 0 count, and always move the table to the cold section.
Instead, we should make a conservative decision based on the execution
count of the function.

(cherry picked from FBD7058127)
  • Loading branch information
maksfb committed Feb 22, 2018
1 parent e156230 commit 6744f0d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bolt/BinaryFunction.cpp
Expand Up @@ -3287,8 +3287,14 @@ void BinaryFunction::emitJumpTables(MCStreamer *Streamer) {
ELF::SHF_ALLOC);
ColdSection = HotSection;
} else {
HotSection = BC.MOFI->getReadOnlySection();
ColdSection = BC.MOFI->getReadOnlyColdSection();
if (isSimple()) {
HotSection = BC.MOFI->getReadOnlySection();
ColdSection = BC.MOFI->getReadOnlyColdSection();
} else {
HotSection = hasProfile() ? BC.MOFI->getReadOnlySection()
: BC.MOFI->getReadOnlyColdSection();
ColdSection = HotSection;
}
}
JT.emit(Streamer, HotSection, ColdSection);
}
Expand Down

0 comments on commit 6744f0d

Please sign in to comment.