[PATCH] D149522: [JITLink] Add target features to LinkGraph

Job Noorman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 29 12:07:05 PDT 2023


jobnoorman created this revision.
jobnoorman added a reviewer: lhames.
Herald added subscribers: asb, luke, pmatos, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
jobnoorman requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

This patch adds SubtargetFeatures to LinkGraph. Similar to Triple, some
targets might use this information while linking.

One example, and the reason this patch was written, is linker relaxation
on RISC-V: different relaxations are possible depending on if the C
extension is enabled.

Note that I have chosen to store the features as SubtargetFeatures as
this seems the most idiomatic and is the type returned by
ObjectFile::getFeatures() which is used to initialize the value.
However, this introduces a dependency from JITLink on MC and I'm not
quite sure if this is warranted. If not, the features could be stored as
std::vector<std::string> (the underlying storage of SubtargetFeatures).

Also note that this patch moves LinkGraph's constructors to a .cpp file
to prevent linker errors when they are inlined into a component that
doesn't depend on MC (this happens in BUILD_SHARED_LIBS builds).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149522

Files:
  llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
  llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
  llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
  llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
  llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
  llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
  llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
  llvm/lib/ExecutionEngine/JITLink/ELF_loongarch.cpp
  llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
  llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
  llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
  llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149522.518219.patch
Type: text/x-patch
Size: 15828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230429/daea810b/attachment.bin>


More information about the llvm-commits mailing list