diff options
author | Lang Hames <lhames@gmail.com> | 2019-10-04 03:55:26 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2019-10-04 03:55:26 +0000 |
commit | 4e920e58e6bc3bf4450b0aae6e225943957de195 (patch) | |
tree | 34397c4c9f6d3162922d7c3e1c9ac6e5946fb264 /llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp | |
parent | ff55e2e0476b72f456dbb37c247ae9ffef7a4f8d (diff) | |
download | bcm5719-llvm-4e920e58e6bc3bf4450b0aae6e225943957de195.tar.gz bcm5719-llvm-4e920e58e6bc3bf4450b0aae6e225943957de195.zip |
[JITLink] Switch from an atom-based model to a "blocks and symbols" model.
In the Atom model the symbols, content and relocations of a relocatable object
file are represented as a graph of atoms, where each Atom represents a
contiguous block of content with a single name (or no name at all if the
content is anonymous), and where edges between Atoms represent relocations.
If more than one symbol is associated with a contiguous block of content then
the content is broken into multiple atoms and layout constraints (represented by
edges) are introduced to ensure that the content remains effectively contiguous.
These layout constraints must be kept in mind when examining the content
associated with a symbol (it may be spread over multiple atoms) or when applying
certain relocation types (e.g. MachO subtractors).
This patch replaces the Atom model in JITLink with a blocks-and-symbols model.
The blocks-and-symbols model represents relocatable object files as bipartite
graphs, with one set of nodes representing contiguous content (Blocks) and
another representing named or anonymous locations (Symbols) within a Block.
Relocations are represented as edges from Blocks to Symbols. This scheme
removes layout constraints (simplifying handling of MachO alt-entry symbols,
and hopefully ELF sections at some point in the future) and simplifies some
relocation logic.
llvm-svn: 373689
Diffstat (limited to 'llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp')
-rw-r--r-- | llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp b/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp index 23f8a691c8f..c5d7dc2fdc9 100644 --- a/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp +++ b/llvm/unittests/ExecutionEngine/JITLink/JITLinkTestCommon.cpp @@ -145,7 +145,7 @@ void JITLinkTestCommon::TestJITLinkContext::notifyFailed(Error Err) { void JITLinkTestCommon::TestJITLinkContext::lookup( const DenseSet<StringRef> &Symbols, - JITLinkAsyncLookupContinuation LookupContinuation) { + std::unique_ptr<JITLinkAsyncLookupContinuation> LC) { jitlink::AsyncLookupResult LookupResult; DenseSet<StringRef> MissingSymbols; for (const auto &Symbol : Symbols) { @@ -157,7 +157,7 @@ void JITLinkTestCommon::TestJITLinkContext::lookup( } if (MissingSymbols.empty()) - LookupContinuation(std::move(LookupResult)); + LC->run(std::move(LookupResult)); else { std::string ErrMsg; { @@ -167,12 +167,12 @@ void JITLinkTestCommon::TestJITLinkContext::lookup( ErrMsgStream << " " << Sym; ErrMsgStream << " ]\n"; } - LookupContinuation( + LC->run( make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode())); } } -void JITLinkTestCommon::TestJITLinkContext::notifyResolved(AtomGraph &G) { +void JITLinkTestCommon::TestJITLinkContext::notifyResolved(LinkGraph &G) { if (NotifyResolved) NotifyResolved(G); } @@ -186,7 +186,7 @@ void JITLinkTestCommon::TestJITLinkContext::notifyFinalized( Error JITLinkTestCommon::TestJITLinkContext::modifyPassConfig( const Triple &TT, PassConfiguration &Config) { if (TestCase) - Config.PostFixupPasses.push_back([&](AtomGraph &G) -> Error { + Config.PostFixupPasses.push_back([&](LinkGraph &G) -> Error { TestCase(G); return Error::success(); }); @@ -196,11 +196,11 @@ Error JITLinkTestCommon::TestJITLinkContext::modifyPassConfig( JITLinkTestCommon::JITLinkTestCommon() { initializeLLVMTargets(); } Expected<std::pair<MCInst, size_t>> -JITLinkTestCommon::disassemble(const MCDisassembler &Dis, - jitlink::DefinedAtom &Atom, size_t Offset) { +JITLinkTestCommon::disassemble(const MCDisassembler &Dis, jitlink::Block &B, + size_t Offset) { ArrayRef<uint8_t> InstBuffer( - reinterpret_cast<const uint8_t *>(Atom.getContent().data()) + Offset, - Atom.getContent().size() - Offset); + reinterpret_cast<const uint8_t *>(B.getContent().data()) + Offset, + B.getContent().size() - Offset); MCInst Inst; uint64_t InstSize; @@ -214,11 +214,9 @@ JITLinkTestCommon::disassemble(const MCDisassembler &Dis, return std::make_pair(Inst, InstSize); } -Expected<int64_t> -JITLinkTestCommon::decodeImmediateOperand(const MCDisassembler &Dis, - jitlink::DefinedAtom &Atom, - size_t OpIdx, size_t Offset) { - auto InstAndSize = disassemble(Dis, Atom, Offset); +Expected<int64_t> JITLinkTestCommon::decodeImmediateOperand( + const MCDisassembler &Dis, jitlink::Block &B, size_t OpIdx, size_t Offset) { + auto InstAndSize = disassemble(Dis, B, Offset); if (!InstAndSize) return InstAndSize.takeError(); |