AutoFDO can assign an IPA count to an inline clone. When LTRANS
materializes the clone, tree_function_versioning initializes the new function
from the original entry count. New local edges can then be incompatible with
the clone count.
SPEC CPU2026 710.omnetpp_r exposed this as:
expression.y:275:39: error: edge count is not compatible with function count
1073741824 (estimated locally, incompatible with entry block count)
23372044704 (guessed, freq 0.1296)
expression.y:275:39: internal compiler error: in to_sreal_scale,
at profile-count.cc:353
Use an initialized clone IPA count when materializing its body so new local
call edges remain compatible with the function count.
Bootstrapped and regression tested on aarch64-linux-gnu.
gcc/ChangeLog:
* tree-inline.cc (tree_function_versioning): Use an initialized AutoFDO
inline clone IPA count when initializing the new function.
Signed-off-by: Kugan Vivekanandarajah <[email protected]>
---
gcc/tree-inline.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 8162b1f5051..48848fa76e5 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -6410,8 +6410,15 @@ tree_function_versioning (tree old_decl, tree new_decl,
old_entry_block = ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (old_decl));
DECL_RESULT (new_decl) = DECL_RESULT (old_decl);
DECL_ARGUMENTS (new_decl) = DECL_ARGUMENTS (old_decl);
+ profile_count count = old_entry_block->count;
+ /* Use an AutoFDO inline clone IPA count when materializing its body so new
+ local edges remain compatible. */
+ if (new_version_node->inlined_to
+ && flag_auto_profile
+ && new_version_node->count.ipa ().initialized_p ())
+ count = new_version_node->count;
initialize_cfun (new_decl, old_decl,
- new_entry ? new_entry->count : old_entry_block->count);
+ new_entry ? new_entry->count : count);
new_version_node->has_omp_variant_constructs
= old_version_node->has_omp_variant_constructs;
if (DECL_STRUCT_FUNCTION (new_decl)->gimple_df)
--
2.34.1