Skip to content

Commit aa27bab

Browse files
committed
[ELF] InputSection::writeTo: reorder type checks and add LLVM_UNLIKELY
1 parent 64f694a commit aa27bab

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lld/ELF/InputSection.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,27 +1225,26 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *buf,
12251225
}
12261226

12271227
template <class ELFT> void InputSection::writeTo(uint8_t *buf) {
1228-
if (type == SHT_NOBITS)
1229-
return;
1230-
12311228
if (auto *s = dyn_cast<SyntheticSection>(this)) {
12321229
s->writeTo(buf + outSecOff);
12331230
return;
12341231
}
12351232

1233+
if (LLVM_UNLIKELY(type == SHT_NOBITS))
1234+
return;
12361235
// If -r or --emit-relocs is given, then an InputSection
12371236
// may be a relocation section.
1238-
if (type == SHT_RELA) {
1237+
if (LLVM_UNLIKELY(type == SHT_RELA)) {
12391238
copyRelocations<ELFT>(buf + outSecOff, getDataAs<typename ELFT::Rela>());
12401239
return;
12411240
}
1242-
if (type == SHT_REL) {
1241+
if (LLVM_UNLIKELY(type == SHT_REL)) {
12431242
copyRelocations<ELFT>(buf + outSecOff, getDataAs<typename ELFT::Rel>());
12441243
return;
12451244
}
12461245

12471246
// If -r is given, we may have a SHT_GROUP section.
1248-
if (type == SHT_GROUP) {
1247+
if (LLVM_UNLIKELY(type == SHT_GROUP)) {
12491248
copyShtGroup<ELFT>(buf + outSecOff);
12501249
return;
12511250
}

0 commit comments

Comments
 (0)