]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix profiledbootstrap
authorJan Hubicka <jh@suse.cz>
Thu, 3 Aug 2023 20:42:27 +0000 (22:42 +0200)
committerJan Hubicka <jh@suse.cz>
Thu, 3 Aug 2023 20:42:27 +0000 (22:42 +0200)
Profiledbootstrap fails with ICE in update_loop_exit_probability_scale_dom_bbs
called from loop unroling.
The reason is that under relatively rare situations, we may run into case where
loop has multiple exits and all are considered as likely but then we scale down
the profile and one of the exits becomes unlikely.

We pass around unadjusted_exit_count to scale exit probability correctly.  In this
case we may end up using uninitialized value and profile-count type intentionally
bombs on that.

gcc/ChangeLog:

PR bootstrap/110857
* cfgloopmanip.cc (scale_loop_profile): (Un)initialize
unadjusted_exit_count.

gcc/cfgloopmanip.cc

index 86360b5f3806535a35d00341fb016ea633777d33..b237ad4e8ac2db5a6baa93ec90a97864c57d1d2e 100644 (file)
@@ -742,7 +742,7 @@ scale_loop_profile (class loop *loop, profile_probability p,
   /* In a consistent profile unadjusted_exit_count should be same as count_in,
      however to preserve as much of the original info, avoid recomputing
      it.  */
-  profile_count unadjusted_exit_count;
+  profile_count unadjusted_exit_count = profile_count::uninitialized ();
   if (exit_edge)
     unadjusted_exit_count = exit_edge->count ();
   scale_loop_frequencies (loop, scale_prob);