[all-commits] [llvm/llvm-project] 3a5791: [SampleProf] Templatize longestCommonSequence (NFC...
Kazu Hirata via All-commits
all-commits at lists.llvm.org
Mon Nov 4 13:20:47 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3a5791e75c53234bb25cb7a427c990d3cb6a0883
https://github.com/llvm/llvm-project/commit/3a5791e75c53234bb25cb7a427c990d3cb6a0883
Author: Kazu Hirata <kazu at google.com>
Date: 2024-11-04 (Mon, 04 Nov 2024)
Changed paths:
M llvm/include/llvm/Transforms/IPO/SampleProfileMatcher.h
A llvm/include/llvm/Transforms/Utils/LongestCommonSequence.h
M llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp
Log Message:
-----------
[SampleProf] Templatize longestCommonSequence (NFC) (#114633)
This patch moves the implementation of longestCommonSequence to a new
header file.
I'm planning to implement a profile undrifting algorithm for MemProf
so that the compiler can ingest somewhat stale MemProf profile and
still deliver most of the benefits that would be delivered if the
profile were completely up to date (with no line number or column
number differences).
Since the core undrifting algorithm is the same between MemProf and
AutoFDO, this patch turns longestCommonSequence into a template. The
original longestCommonSequence implementation is repurposed and now
serves as a wrapper around a template specialization.
Note that the usage differences between MemProf and AutoFDO are minor.
For example, I'm planning to use line-column number pair instead of
LineLocation, which uses a discriminator. To identify a function, I'm
planning to use uint64_t GUID instead of FunctionId.
For now, I'm returning matches via a function object InsertMatching
because it's impossible to infer the map type from LineLocation alone.
Specifically:
std::unordered_map<LineLocation, LineLocation>
does not work because we cannot infer the hash functor
LineLocationHash. I could define std::hash<LineLocation>.
Alternatively, in the future, I might switch to DenseMap and define
DenseMapInfo<LineLocation>. This way:
DenseMap<LineLocation, LineLocation>
automatically picks up DenseMapInfo<LineLocation>.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list