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>.
36 KiB
36 KiB