This is an archive of the discontinued LLVM Phabricator instance.

[JITLink][NFC] Add TableManager to replace PerGraph...Builder pass
ClosedPublic

Authored by StephenFan on Sep 23 2021, 11:15 PM.

Details

Summary

This patch add a TableManager which reponsible for fixing edges that need entries to reference the target symbol and constructing such entries.

In the past, the PerGraphGOTAndPLTStubsBuilder pass was used to build GOT and PLT entry, and the PerGraphTLSInfoEntryBuilder pass was used to build TLSInfo entry. By generalizing the behavior of building entry, I added a TableManager which could be reused when built GOT, PLT and TLSInfo entries.

If this patch makes sense and can be accepted, I will apply the TableManager to other targets(MachO_x86_64, MachO_arm64, ELF_riscv), and delete the file PerGraphGOTAndPLTStubsBuilder.h

Diff Detail

Event Timeline

StephenFan created this revision.Sep 23 2021, 11:15 PM
StephenFan requested review of this revision.Sep 23 2021, 11:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 23 2021, 11:15 PM
StephenFan edited the summary of this revision. (Show Details)Sep 23 2021, 11:17 PM

clang-format

lhames accepted this revision.Sep 24 2021, 1:39 PM

LGTM.

llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
165–168

I really like how this pattern worked out. Very neat!

llvm/lib/ExecutionEngine/JITLink/TableManager.h
25–45

It's just occurred to me that this is a kind of visitor pattern.

I think it makes sense to move these functions into their JITLink.h and rename them to visitEdge (from tryEdgeFixer) and visitExistingEdges (from runFixersOnGraph). The fixEdge method should be renamed to visitEdge and we should document that visitEdge should return 'true' (if the edge should be considered "dealt with", or 'false' (if we want the edge to also be acted on by any subsequent visitors).

These changes could be made either before you land the patch, or afterwards in-tree. Whichever you prefer.

This revision is now accepted and ready to land.Sep 24 2021, 1:39 PM

Address @lhames 's comments

  1. Move functions in TableManager.h to JITLink.h
  2. Rename these functions to make them looks like visitor pattern

clang-format

StephenFan added inline comments.Sep 29 2021, 1:05 AM
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
1686 ↗(On Diff #375800)

I use gcc to compile llvm-project. And this function will cause the defined but not used[-Wunused-function] warning. Is there ways to suppress this warning ?

lhames added inline comments.Oct 2 2021, 10:50 AM
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
1686 ↗(On Diff #375800)

That sounds like a broken warning. I would ignore it.

This revision was landed with ongoing or failed builds.Oct 6 2021, 6:28 AM
This revision was automatically updated to reflect the committed changes.
StephenFan added inline comments.Oct 6 2021, 6:49 AM
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
1686 ↗(On Diff #375800)

I tried to land this patch, but broke builds on some bots. See e.g. https://lab.llvm.org/buildbot#builders/77/builds/10218

StephenFan reopened this revision.Oct 14 2021, 6:34 AM
This revision is now accepted and ready to land.Oct 14 2021, 6:34 AM

Change to static inline

llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp