https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87885

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-11-06
                 CC|                            |hubicka at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well, obviously the profile-consistency checking requires up-to-date IL but
that cannot be ensured before TODO of a pass was run.  So I'm not sure why it
is
run twice?

  if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
    check_profile_consistency (pass->static_pass_number, 0, true);

  /* Run post-pass cleanup and verification.  */
  execute_todo (todo_after | pass->todo_flags_finish | TODO_verify_il);
  if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
    check_profile_consistency (pass->static_pass_number, 1, true);

docs say

/* Do profile consistency book-keeping for the pass with static number INDEX.
   If SUBPASS is zero, we run _before_ the pass, and if SUBPASS is one, then
   we run _after_ the pass.  RUN is true if the pass really runs, or FALSE

but the first call above isn't before the pass, it is before the TODO of
the pass?!

That is, the following fixes the ICE and placement according to docs.

Honza?

diff --git a/gcc/passes.c b/gcc/passes.c
index d838d909941..4d600eeb7b9 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -2163,15 +2163,15 @@ execute_one_ipa_transform_pass (struct cgraph_node
*node,
   if (pass->tv_id != TV_NONE)
     timevar_push (pass->tv_id);

+  if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
+    check_profile_consistency (pass->static_pass_number, 0, true);
+
   /* Run pre-pass verification.  */
   execute_todo (ipa_pass->function_transform_todo_flags_start);

   /* Do it!  */
   todo_after = ipa_pass->function_transform (node);

-  if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
-    check_profile_consistency (pass->static_pass_number, 0, true);
-
   /* Run post-pass cleanup and verification.  */
   execute_todo (todo_after);
   verify_interpass_invariants ();
@@ -2417,6 +2417,9 @@ execute_one_pass (opt_pass *pass)
   if (pass->tv_id != TV_NONE)
     timevar_push (pass->tv_id);

+  if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
+    check_profile_consistency (pass->static_pass_number, 0, true);
+
   /* Run pre-pass verification.  */
   execute_todo (pass->todo_flags_start);

@@ -2461,9 +2464,6 @@ execute_one_pass (opt_pass *pass)

   do_per_function (update_properties_after_pass, pass);

-  if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))
-    check_profile_consistency (pass->static_pass_number, 0, true);
-
   /* Run post-pass cleanup and verification.  */
   execute_todo (todo_after | pass->todo_flags_finish | TODO_verify_il);
   if (profile_report && cfun && (cfun->curr_properties & PROP_cfg))

Reply via email to