[gcc(refs/users/kubaneko/heads/histogram)] fixed vector allocation

Ondrej Kubanek kubaneko@gcc.gnu.org
Thu Feb 23 23:22:43 GMT 2023


https://gcc.gnu.org/g:98d59dcdebb492055ca7d648abc475bfafdfd3e5

commit 98d59dcdebb492055ca7d648abc475bfafdfd3e5
Author: kubaneko <kubanek0ondrej@gmail.com>
Date:   Sat Jan 14 22:04:29 2023 +0000

    fixed vector allocation

Diff:
---
 gcc/cfgloop.h  | 2 +-
 gcc/profile.cc | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index b6a005450a8..14945bc967d 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -97,7 +97,7 @@ struct loop_exit_hasher : ggc_ptr_hash<loop_exit>
 struct GTY(()) histogram_counters{
     gcov_type sum;
     int histogram_size;
-    vec<gcov_type, va_heap> * GTY((skip)) hist;
+    vec<gcov_type, va_heap, vl_embed> * GTY((skip)) hist;
 };
 
 // quantil function for the distribution
diff --git a/gcc/profile.cc b/gcc/profile.cc
index f4dfe575c61..dbe005a1d39 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -930,13 +930,14 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum,
         if (act_count[t]){
            lp->counters=ggc_alloc<histogram_counters>();
            gcov_type sum=0;
+           lp->counters->hist=NULL;
+           vec_safe_grow_cleared(lp->counters->hist,param_profile_histogram_size);
            for (int i=0;i<param_profile_histogram_size;++i){
                auto hst=lp->counters->hist;
                (*hst)[i]=act_count[t][i];
                sum+=act_count[t][i];
            }
            lp->counters->sum=sum;
-           vec_safe_grow_cleared(lp->counters->hist,param_profile_histogram_size);
         }
         continue;
       }


More information about the Gcc-cvs mailing list