From ceb5bd59ccba4b3ae9b6ea31fedb5d50435b1a88 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 27 Mar 2017 03:41:00 +0000 Subject: [PATCH] Simplify. NFC. This patch calls getAddend on a relocation only when the relocation is RELA. That doesn't really improve runtime performance but should improve readability as the code now matches the function description. llvm-svn: 298828 --- lld/ELF/Relocations.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 15caba0..9a1da23 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -554,11 +554,11 @@ static RelExpr adjustExpr(SymbolBody &Body, RelExpr Expr, uint32_t Type, // input section. template static int64_t computeAddend(const RelTy &Rel, const uint8_t *Buf) { - int64_t A = getAddend(Rel); uint32_t Type = Rel.getType(Config->IsMips64EL); + int64_t A = RelTy::IsRela + ? getAddend(Rel) + : Target->getImplicitAddend(Buf + Rel.r_offset, Type); - if (!RelTy::IsRela) - A += Target->getImplicitAddend(Buf + Rel.r_offset, Type); if (Config->EMachine == EM_PPC64 && Config->Pic && Type == R_PPC64_TOC) A += getPPC64TocBase(); return A; -- 2.7.4