[all-commits] [llvm/llvm-project] 37a129: [ELF] Add RelocationScanner. NFC

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jan 11 09:55:06 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 37a1291885c1056721f20cf63dd2df42bb9a0574
      https://github.com/llvm/llvm-project/commit/37a1291885c1056721f20cf63dd2df42bb9a0574
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-01-11 (Tue, 11 Jan 2022)

  Changed paths:
    M lld/ELF/Relocations.cpp

  Log Message:
  -----------
  [ELF] Add RelocationScanner. NFC

Currently the way some relocation-related static functions pass around
states is clumsy. Add a Resolver class to store some states as member
variables.

Advantages:

* Avoid the parameter `InputSectionBase &sec` (this offsets the cost passing around `this` paramemter)
* Avoid the parameter `end` (Mips and PowerPC hacks)
* `config` and `target` can be cached as member variables to reduce global state accesses. (potential speedup because the compiler didn't know `config`/`target` were not changed across function calls)
* If we ever want to reduce if-else costs (e.g. `config->emachine==EM_MIPS` for non-Mips) or introduce parallel relocation scan not handling some tricky arches (PPC/Mips), we can templatize Resolver

`target` isn't used as much as `config`, so I change it to a const reference
during the migration.

There is a minor performance inprovement for elf::scanRelocations.

Reviewed By: ikudrin, peter.smith

Differential Revision: https://reviews.llvm.org/D116881




More information about the All-commits mailing list