14#ifndef LLVM_TRANSFORMS_UTILS_LONGESTCOMMONSEQEUNCE_H
15#define LLVM_TRANSFORMS_UTILS_LONGESTCOMMONSEQEUNCE_H
34template <
typename Loc,
typename Function,
35 typename AnchorList = ArrayRef<std::pair<Loc, Function>>>
39 FunctionMatchesProfile,
41 int32_t Size1 = AnchorList1.size(), Size2 = AnchorList2.size(),
51 int32_t
X = Size1,
Y = Size2;
61 int32_t PrevX =
P[
Index(PrevK)];
62 int32_t PrevY = PrevX - PrevK;
63 while (
X > PrevX &&
Y > PrevY) {
66 InsertMatching(AnchorList1[
X].first, AnchorList2[
Y].first);
84 std::vector<int32_t> V(2 *
MaxDepth + 1, -1);
87 std::vector<std::vector<int32_t>>
Trace;
98 X < Size1 &&
Y < Size2 &&
99 FunctionMatchesProfile(AnchorList1[
X].second, AnchorList2[
Y].second))
104 if (
X >= Size1 &&
Y >= Size2) {
106 Backtrack(
Trace, AnchorList1, AnchorList2);
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static const unsigned MaxDepth
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
std::vector< std::pair< LineLocation, FunctionId > > AnchorList
void longestCommonSequence(AnchorList AnchorList1, AnchorList AnchorList2, llvm::function_ref< bool(const Function &, const Function &)> FunctionMatchesProfile, llvm::function_ref< void(Loc, Loc)> InsertMatching)