[lld] 1eaa9b4 - [ELF] initializeSections: move SHT_LLVM_CALL_GRAPH_PROFILE check into SHF_EXCLUDE && !relocatable. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 12 20:05:27 PST 2021
Author: Fangrui Song
Date: 2021-12-12T20:05:21-08:00
New Revision: 1eaa9b4374f5559a2332b056ae66ddf78ad8bfff
URL: https://github.com/llvm/llvm-project/commit/1eaa9b4374f5559a2332b056ae66ddf78ad8bfff
DIFF: https://github.com/llvm/llvm-project/commit/1eaa9b4374f5559a2332b056ae66ddf78ad8bfff.diff
LOG: [ELF] initializeSections: move SHT_LLVM_CALL_GRAPH_PROFILE check into SHF_EXCLUDE && !relocatable. NFC
Avoid a comparison in the majority of cases.
Added:
Modified:
lld/ELF/InputFiles.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 12ff5f167776..90a4eb018b4d 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -555,13 +555,12 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats) {
continue;
const Elf_Shdr &sec = objSections[i];
- if (sec.sh_type == ELF::SHT_LLVM_CALL_GRAPH_PROFILE)
- cgProfileSectionIndex = i;
-
// SHF_EXCLUDE'ed sections are discarded by the linker. However,
// if -r is given, we'll let the final link discard such sections.
// This is compatible with GNU.
if ((sec.sh_flags & SHF_EXCLUDE) && !config->relocatable) {
+ if (sec.sh_type == SHT_LLVM_CALL_GRAPH_PROFILE)
+ cgProfileSectionIndex = i;
if (sec.sh_type == SHT_LLVM_ADDRSIG) {
// We ignore the address-significance table if we know that the object
// file was created by objcopy or ld -r. This is because these tools
More information about the llvm-commits
mailing list