[LLD][ELF] - Simplify. NFCI.
This makes getRISCVPCRelHi20 to be static local helper,
and rotates the 'if' condition.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@347497 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/ELF/InputSection.cpp b/ELF/InputSection.cpp
index 749f5fd..18414b6 100644
--- a/ELF/InputSection.cpp
+++ b/ELF/InputSection.cpp
@@ -545,7 +545,7 @@
//
// This function returns the R_RISCV_PCREL_HI20 relocation from
// R_RISCV_PCREL_LO12's symbol and addend.
-Relocation *lld::elf::getRISCVPCRelHi20(const Symbol *Sym, uint64_t Addend) {
+static Relocation *getRISCVPCRelHi20(const Symbol *Sym, uint64_t Addend) {
const Defined *D = cast<Defined>(Sym);
InputSection *IS = cast<InputSection>(D->Section);
@@ -677,11 +677,10 @@
return getAArch64Page(Val) - getAArch64Page(P);
}
case R_RISCV_PC_INDIRECT: {
- const Relocation *HiRel = getRISCVPCRelHi20(&Sym, A);
- if (!HiRel)
- return 0;
- return getRelocTargetVA(File, HiRel->Type, HiRel->Addend, Sym.getVA(),
- *HiRel->Sym, HiRel->Expr);
+ if (const Relocation *HiRel = getRISCVPCRelHi20(&Sym, A))
+ return getRelocTargetVA(File, HiRel->Type, HiRel->Addend, Sym.getVA(),
+ *HiRel->Sym, HiRel->Expr);
+ return 0;
}
case R_PC: {
uint64_t Dest;
diff --git a/ELF/InputSection.h b/ELF/InputSection.h
index 88dcadd..d4edc06 100644
--- a/ELF/InputSection.h
+++ b/ELF/InputSection.h
@@ -362,7 +362,6 @@
// The list of all input sections.
extern std::vector<InputSectionBase *> InputSections;
-Relocation *getRISCVPCRelHi20(const Symbol *Sym, const uint64_t Addend);
} // namespace elf
std::string toString(const elf::InputSectionBase *);