IPA: fix profile handling in IRA
authorMartin Liska <mliska@suse.cz>
Tue, 13 Oct 2020 14:44:47 +0000 (16:44 +0200)
committerMartin Liska <mliska@suse.cz>
Thu, 15 Oct 2020 07:56:55 +0000 (09:56 +0200)
gcc/ChangeLog:

PR ipa/97295
* profile-count.c (profile_count::to_frequency): Move part of
gcc_assert to STATIC_ASSERT.
* regs.h (REG_FREQ_FROM_BB): Do not use count.to_frequency for
a function that does not have count_max initialized.

gcc/profile-count.c
gcc/regs.h

index c89914ff8a064b340f85bee45ff99b8c8fd06711..aaefc11ff3df00df74876c7fb7176b9b3b200269 100644 (file)
@@ -270,8 +270,8 @@ profile_count::to_frequency (struct function *fun) const
     return BB_FREQ_MAX;
   if (*this == zero ())
     return 0;
-  gcc_assert (REG_BR_PROB_BASE == BB_FREQ_MAX
-             && fun->cfg->count_max.initialized_p ());
+  STATIC_ASSERT (REG_BR_PROB_BASE == BB_FREQ_MAX);
+  gcc_assert (fun->cfg->count_max.initialized_p ());
   profile_probability prob = probability_in (fun->cfg->count_max);
   if (!prob.initialized_p ())
     return REG_BR_PROB_BASE;
index 1decd2c2d2adf75f766f5fca9b1ba4ac54776b99..11416c47f6f81c8c8f197bde3752422de6f2d9ae 100644 (file)
@@ -128,7 +128,8 @@ extern size_t reg_info_p_size;
    or profile driven feedback is available and the function is never executed,
    frequency is always equivalent.  Otherwise rescale the basic block
    frequency.  */
-#define REG_FREQ_FROM_BB(bb) (optimize_function_for_size_p (cfun)            \
+#define REG_FREQ_FROM_BB(bb) ((optimize_function_for_size_p (cfun)           \
+                              || !cfun->cfg->count_max.initialized_p ())     \
                              ? REG_FREQ_MAX                                  \
                              : ((bb)->count.to_frequency (cfun)              \
                                * REG_FREQ_MAX / BB_FREQ_MAX)                 \