[lld] r347497 - [LLD][ELF] - Simplify. NFCI.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 23 07:13:26 PST 2018
Author: grimar
Date: Fri Nov 23 07:13:26 2018
New Revision: 347497
URL: http://llvm.org/viewvc/llvm-project?rev=347497&view=rev
Log:
[LLD][ELF] - Simplify. NFCI.
This makes getRISCVPCRelHi20 to be static local helper,
and rotates the 'if' condition.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=347497&r1=347496&r2=347497&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Fri Nov 23 07:13:26 2018
@@ -545,7 +545,7 @@ static uint64_t getARMStaticBase(const S
//
// 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 @@ static uint64_t getRelocTargetVA(const I
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;
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=347497&r1=347496&r2=347497&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Fri Nov 23 07:13:26 2018
@@ -362,7 +362,6 @@ private:
// 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 *);
More information about the llvm-commits
mailing list