[llvm] 6c348c1 - [JITLink] Move AllocActions and associated types out of JITLinkMemoryManager.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 2 20:08:51 PST 2022
Author: Lang Hames
Date: 2022-01-03T14:37:18+11:00
New Revision: 6c348c1d3f5a1c36cec7b8360bd986549eee62ba
URL: https://github.com/llvm/llvm-project/commit/6c348c1d3f5a1c36cec7b8360bd986549eee62ba
DIFF: https://github.com/llvm/llvm-project/commit/6c348c1d3f5a1c36cec7b8360bd986549eee62ba.diff
LOG: [JITLink] Move AllocActions and associated types out of JITLinkMemoryManager.
They're shared with LinkGraph, so having them as top-level types makes sense,
and saves users from qualifying the names everywhere.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index 83d85953fce69..69106fcb4c282 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -1377,7 +1377,7 @@ class LinkGraph {
///
/// Accessing this object after finalization will result in undefined
/// behavior.
- JITLinkMemoryManager::AllocActions &allocActions() { return AAs; }
+ AllocActions &allocActions() { return AAs; }
/// Dump the graph.
void dump(raw_ostream &OS);
@@ -1395,7 +1395,7 @@ class LinkGraph {
SectionList Sections;
ExternalSymbolSet ExternalSymbols;
ExternalSymbolSet AbsoluteSymbols;
- JITLinkMemoryManager::AllocActions AAs;
+ AllocActions AAs;
};
inline MutableArrayRef<char> Block::getMutableContent(LinkGraph &G) {
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
index 62c271dfc0b2e..7dd382facde8a 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
@@ -33,52 +33,53 @@ class Block;
class LinkGraph;
class Section;
+/// Represents a call to a graph-memory-management support function in the
+/// executor.
+///
+/// Support functions are called as:
+///
+/// auto *Result =
+/// ((char*(*)(const void*, size_t))FnAddr)(
+/// (const void*)CtxAddr, (size_t)CtxSize)
+///
+/// A null result is interpreted as success.
+///
+/// A non-null result is interpreted as a heap-allocated string containing
+/// an error message to report to the allocator (the allocator's
+/// executor-side implementation code is responsible for freeing the error
+/// string).
+struct AllocActionCall {
+ JITTargetAddress FnAddr = 0;
+ JITTargetAddress CtxAddr = 0;
+ JITTargetAddress CtxSize = 0;
+};
+
+/// A pair of AllocActionCalls, one to be run at finalization time, one to be
+/// run at deallocation time.
+///
+/// AllocActionCallPairs should be constructed for paired operations (e.g.
+/// __register_ehframe and __deregister_ehframe for eh-frame registration).
+/// See comments for AllocActions for execution ordering.
+///
+/// For unpaired operations one or the other member can be left unused, as
+/// AllocationActionCalls with an FnAddr of zero will be skipped.
+struct AllocActionCallPair {
+ AllocActionCall Finalize;
+ AllocActionCall Dealloc;
+};
+
+/// A vector of allocation actions to be run for this allocation.
+///
+/// Finalize allocations will be run in order at finalize time. Dealloc
+/// actions will be run in reverse order at deallocation time.
+using AllocActions = std::vector<AllocActionCallPair>;
+
/// Manages allocations of JIT memory.
///
/// Instances of this class may be accessed concurrently from multiple threads
/// and their implemetations should include any necessary synchronization.
class JITLinkMemoryManager {
public:
- /// Represents a call to a graph-memory-management support function in the
- /// executor.
- ///
- /// Support functions are called as:
- ///
- /// auto *Result =
- /// ((char*(*)(const void*, size_t))FnAddr)(
- /// (const void*)CtxAddr, (size_t)CtxSize)
- ///
- /// A null result is interpreted as success.
- ///
- /// A non-null result is interpreted as a heap-allocated string containing
- /// an error message to report to the allocator (the allocator's
- /// executor-side implementation code is responsible for freeing the error
- /// string).
- struct AllocActionCall {
- JITTargetAddress FnAddr = 0;
- JITTargetAddress CtxAddr = 0;
- JITTargetAddress CtxSize = 0;
- };
-
- /// A pair of AllocActionCalls, one to be run at finalization time, one to be
- /// run at deallocation time.
- ///
- /// AllocActionCallPairs should be constructed for paired operations (e.g.
- /// __register_ehframe and __deregister_ehframe for eh-frame registration).
- /// See comments for AllocActions for execution ordering.
- ///
- /// For unpaired operations one or the other member can be left unused, as
- /// AllocationActionCalls with an FnAddr of zero will be skipped.
- struct AllocActionCallPair {
- AllocActionCall Finalize;
- AllocActionCall Dealloc;
- };
-
- /// A vector of allocation actions to be run for this allocation.
- ///
- /// Finalize allocations will be run in order at finalize time. Dealloc
- /// actions will be run in reverse order at deallocation time.
- using AllocActions = std::vector<AllocActionCallPair>;
/// Represents a finalized allocation.
///
@@ -312,7 +313,7 @@ class BasicLayout {
/// Returns a reference to the AllocActions in the graph.
/// This convenience function saves callers from having to #include
/// LinkGraph.h if all they need are allocation actions.
- JITLinkMemoryManager::AllocActions &graphAllocActions();
+ AllocActions &graphAllocActions();
private:
LinkGraph &G;
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
index 831b9b26d2fde..67fe6287e3882 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
@@ -64,7 +64,7 @@ namespace jitlink {
JITLinkMemoryManager::~JITLinkMemoryManager() = default;
JITLinkMemoryManager::InFlightAlloc::~InFlightAlloc() = default;
-static Error runAllocAction(JITLinkMemoryManager::AllocActionCall &C) {
+static Error runAllocAction(AllocActionCall &C) {
using WrapperFnTy = CWrapperFunctionResult (*)(const void *, size_t);
auto *Fn = jitTargetAddressToPointer<WrapperFnTy>(C.FnAddr);
@@ -189,9 +189,7 @@ Error BasicLayout::apply() {
return Error::success();
}
-JITLinkMemoryManager::AllocActions &BasicLayout::graphAllocActions() {
- return G.allocActions();
-}
+AllocActions &BasicLayout::graphAllocActions() { return G.allocActions(); }
void SimpleSegmentAlloc::Create(JITLinkMemoryManager &MemMgr,
const JITLinkDylib *JD, SegmentMap Segments,
More information about the llvm-commits
mailing list