Assign hierarchical copyids automatically on CFG duplication
Improves profile accuracy by automatically assigning unique identifiers to duplicated code regions.
This commit enhances AutoFDO by automatically assigning hierarchical copy identifiers to duplicated Control Flow Graph (CFG) regions and statements. Previously, manual updates were required, which was error-prone. The new system assigns a unique identifier based on the location of the first block or statement in the duplicated region. This allows sample profiles to more accurately distinguish between copies of the same source line, leading to better profile-guided optimizations.
In Details
This patch introduces automatic assignment of hierarchical copyids during CFG and statement duplication for AutoFDO. It assigns a copyid to each duplicated region, keyed by the location of the first block/statement, and removes manual discriminator updates handled by copy_bbs. New functions like copyid_location_from_bb are introduced, and duplicate_block and copy_bbs are updated to manage copyids. This change ensures that sample profiles can differentiate between identical source lines that have been duplicated during compilation.
- AutoFDO
- Automatic Feedback-Driven Optimization. A technique that uses runtime profiling data to guide compiler optimizations.
- CFG
- Control Flow Graph. A representation of all execution paths through a function or program.
- copyid
- An identifier used to track duplicated code regions, especially for profile-guided optimization.
- hierarchical discriminator
- A mechanism for uniquely identifying code locations, particularly useful when code is duplicated or structured hierarchically, to improve profile accuracy.