From 0fc5dcd1c8826fcbf68348cb0081518eb5411480 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Fri, 23 Nov 2018 15:13:26 +0000 Subject: [PATCH] [LLD][ELF] - Simplify. NFCI. This makes getRISCVPCRelHi20 to be static local helper, and rotates the 'if' condition. llvm-svn: 347497 --- lld/ELF/InputSection.cpp | 11 +++++------ lld/ELF/InputSection.h | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 749f5fd..18414b6 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -545,7 +545,7 @@ static uint64_t getARMStaticBase(const Symbol &Sym) { // // 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(Sym); InputSection *IS = cast(D->Section); @@ -677,11 +677,10 @@ static uint64_t getRelocTargetVA(const InputFile *File, RelType Type, int64_t A, 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/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 88dcadd..d4edc06 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -362,7 +362,6 @@ private: // The list of all input sections. extern std::vector InputSections; -Relocation *getRISCVPCRelHi20(const Symbol *Sym, const uint64_t Addend); } // namespace elf std::string toString(const elf::InputSectionBase *); -- 2.7.4