[llvm] [BOLT][NFC] Remove unneeded if (PR #88322)
Nathan Sidwell via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 14:39:43 PDT 2024
https://github.com/urnathan created https://github.com/llvm/llvm-project/pull/88322
In computing reloc section sh_info remapping we don't need to special-case zero. section 0 will map to section 0.
>From c6089e81c59f706ed6c089c75263e097cc3a6706 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Wed, 10 Apr 2024 15:39:46 -0400
Subject: [PATCH] [BOLT][NFC] Remove unneeded if
---
bolt/lib/Rewrite/RewriteInstance.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 0c8ee0d417233b..6491276cd54d28 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -4417,6 +4417,7 @@ void RewriteInstance::patchELFSectionHeaderTable(ELFObjectFile<ELFT> *File) {
raw_fd_ostream &OS = Out->os();
const ELFFile<ELFT> &Obj = File->getELFFile();
+ // Mapping from old section indices to new ones
std::vector<uint32_t> NewSectionIndex;
std::vector<ELFShdrTy> OutputSections =
getOutputSections(File, NewSectionIndex);
@@ -4434,10 +4435,8 @@ void RewriteInstance::patchELFSectionHeaderTable(ELFObjectFile<ELFT> *File) {
// Write all section header entries while patching section references.
for (ELFShdrTy &Section : OutputSections) {
Section.sh_link = NewSectionIndex[Section.sh_link];
- if (Section.sh_type == ELF::SHT_REL || Section.sh_type == ELF::SHT_RELA) {
- if (Section.sh_info)
- Section.sh_info = NewSectionIndex[Section.sh_info];
- }
+ if (Section.sh_type == ELF::SHT_REL || Section.sh_type == ELF::SHT_RELA)
+ Section.sh_info = NewSectionIndex[Section.sh_info];
OS.write(reinterpret_cast<const char *>(&Section), sizeof(Section));
}
More information about the llvm-commits
mailing list