[PATCH] D134600: [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation

Xinlong Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 25 04:27:41 PDT 2022


VincentWu created this revision.
VincentWu added reviewers: MaskRay, jrtc27, craig.topper, HsiangKai, asb, kito-cheng.
Herald added subscribers: sunshaoce, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, mgrang, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, arichardson, emaste.
Herald added a project: All.
VincentWu requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD.
Herald added a project: LLVM.

This patch implements optimizations for the zcmt extension in lld.

A new `TableJumpSectio` has been added.

Scans each `R_RISCV_CALL/R_RISCV_CALL_PLT` relocType in each section before the linker relaxation, recording the name of the symbol.

In `finalizeContents` the recorded symbol names are sorted in descending order by the number of jumps.

Optimise and insert a new `cm.jt/cm.jalt` during the relax process. in the process, we reused the`R_RISCV_JAL` relocType

co-author: @ScottEgerton


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134600

Files:
  lld/ELF/Arch/RISCV.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.h
  lld/ELF/Options.td
  lld/ELF/SyntheticSections.cpp
  lld/ELF/SyntheticSections.h
  lld/ELF/Target.h
  lld/ELF/Writer.cpp
  lld/test/ELF/riscv-tbljal-call.s
  lld/test/ELF/riscv-tbljal-syms.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134600.462714.patch
Type: text/x-patch
Size: 20175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220925/46931fda/attachment.bin>


More information about the llvm-commits mailing list