[lld] aa27bab - [ELF] InputSection::writeTo: reorder type checks and add LLVM_UNLIKELY
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 16 23:42:55 PST 2021
Author: Fangrui Song
Date: 2021-12-16T23:42:50-08:00
New Revision: aa27bab5a1a17e9c4168a741a6298ecaa92c1ecb
URL: https://github.com/llvm/llvm-project/commit/aa27bab5a1a17e9c4168a741a6298ecaa92c1ecb
DIFF: https://github.com/llvm/llvm-project/commit/aa27bab5a1a17e9c4168a741a6298ecaa92c1ecb.diff
LOG: [ELF] InputSection::writeTo: reorder type checks and add LLVM_UNLIKELY
Added:
Modified:
lld/ELF/InputSection.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 820ddae74124..61654b95704f 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -1225,27 +1225,26 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *buf,
}
template <class ELFT> void InputSection::writeTo(uint8_t *buf) {
- if (type == SHT_NOBITS)
- return;
-
if (auto *s = dyn_cast<SyntheticSection>(this)) {
s->writeTo(buf + outSecOff);
return;
}
+ if (LLVM_UNLIKELY(type == SHT_NOBITS))
+ return;
// If -r or --emit-relocs is given, then an InputSection
// may be a relocation section.
- if (type == SHT_RELA) {
+ if (LLVM_UNLIKELY(type == SHT_RELA)) {
copyRelocations<ELFT>(buf + outSecOff, getDataAs<typename ELFT::Rela>());
return;
}
- if (type == SHT_REL) {
+ if (LLVM_UNLIKELY(type == SHT_REL)) {
copyRelocations<ELFT>(buf + outSecOff, getDataAs<typename ELFT::Rel>());
return;
}
// If -r is given, we may have a SHT_GROUP section.
- if (type == SHT_GROUP) {
+ if (LLVM_UNLIKELY(type == SHT_GROUP)) {
copyShtGroup<ELFT>(buf + outSecOff);
return;
}
More information about the llvm-commits
mailing list