Skip to content

Commit 8b7cc93

Browse files
committed
[JITLink] Add comments, rename types for visitExistingEdges utility.
The "Fixers" name was a hangover from an earlier draft of the patch. "Visitors" fits the function name(s).
1 parent fa16329 commit 8b7cc93

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,28 +1709,34 @@ Error markAllSymbolsLive(LinkGraph &G);
17091709
Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B,
17101710
const Edge &E);
17111711

1712-
static inline void visitEdge(LinkGraph &G, Block *B, Edge &E) {}
1713-
1714-
template <typename FixerT, typename... FixerTs>
1715-
static void visitEdge(LinkGraph &G, Block *B, Edge &E, FixerT &&Fixer,
1716-
FixerTs &&...Fixers) {
1717-
if (!Fixer.visitEdge(G, B, E))
1718-
visitEdge(G, B, E, std::forward<FixerTs>(Fixers)...);
1712+
/// Base case for edge-visitors where the visitor-list is empty.
1713+
inline void visitEdge(LinkGraph &G, Block *B, Edge &E) {}
1714+
1715+
/// Applies the first visitor in the list to the given edge. If the visitor's
1716+
/// visitEdge method returns true then we return immediately, otherwise we
1717+
/// apply the next visitor.
1718+
template <typename VisitorT, typename... VisitorTs>
1719+
void visitEdge(LinkGraph &G, Block *B, Edge &E, VisitorT &&V,
1720+
VisitorTs &&...Vs) {
1721+
if (!V.visitEdge(G, B, E))
1722+
visitEdge(G, B, E, std::forward<VisitorTs>(Vs)...);
17191723
}
17201724

1721-
/// Visits edges exist in graph by Fixers.
1725+
/// For each edge in the given graph, apply a list of visitors to the edge,
1726+
/// stopping when the first visitor's visitEdge method returns true.
17221727
///
1723-
/// Note: that if a fixer fixes the edge successfully,
1724-
/// the rest of the fixers will not visit this edge.
1725-
template <typename... FixerTs>
1726-
void visitExistingEdges(LinkGraph &G, FixerTs &&...Fixers) {
1727-
// We're going to be adding new blocks, but we don't want to iterate over
1728-
// the new ones, so build a worklist.
1728+
/// Only visits edges that were in the graph at call time: if any visitor
1729+
/// adds new edges those will not be visited. Visitors are not allowed to
1730+
/// remove edges (though they can change their kind, target, and addend).
1731+
template <typename... VisitorTs>
1732+
void visitExistingEdges(LinkGraph &G, VisitorTs &&...Vs) {
1733+
// We may add new blocks during this process, but we don't want to iterate
1734+
// over them, so build a worklist.
17291735
std::vector<Block *> Worklist(G.blocks().begin(), G.blocks().end());
17301736

17311737
for (auto *B : Worklist)
17321738
for (auto &E : B->edges())
1733-
visitEdge(G, B, E, std::forward<FixerTs>(Fixers)...);
1739+
visitEdge(G, B, E, std::forward<VisitorTs>(Vs)...);
17341740
}
17351741

17361742
/// Create a LinkGraph from the given object buffer.

0 commit comments

Comments
 (0)