diff options
author | Martin Liska <mliska@suse.cz> | 2022-12-28 09:11:40 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2023-01-11 13:06:28 +0100 |
commit | 8221efae233e2d5992a79600071dd0a52f1b3c74 (patch) | |
tree | 7632985ef19c9920b01087b347956e9c81d896f8 /gcc | |
parent | 7c9f20fcfdc2d8453df88ceb7e693debfcd678c0 (diff) | |
download | gcc-8221efae233e2d5992a79600071dd0a52f1b3c74.zip gcc-8221efae233e2d5992a79600071dd0a52f1b3c74.tar.gz gcc-8221efae233e2d5992a79600071dd0a52f1b3c74.tar.bz2 |
switch expansion: limit JT growth param values
Currently, one can request a huge jump table creation which
leads to a non-sensual huge output. Moreover, use auto_vec rather
than a stack-allocated array.
PR middle-end/107976
gcc/ChangeLog:
* params.opt: Limit JT params.
* stmt.cc (emit_case_dispatch_table): Use auto_vec.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/params.opt | 4 | ||||
-rw-r--r-- | gcc/stmt.cc | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/gcc/params.opt b/gcc/params.opt index 9291312..8a128c3 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -323,11 +323,11 @@ Common Joined UInteger Var(param_iv_max_considered_uses) Init(250) Param Optimiz Bound on number of iv uses in loop optimized in iv optimizations. -param=jump-table-max-growth-ratio-for-size= -Common Joined UInteger Var(param_jump_table_max_growth_ratio_for_size) Init(300) Param Optimization +Common Joined UInteger Var(param_jump_table_max_growth_ratio_for_size) Init(300) IntegerRange(0, 10000) Param Optimization The maximum code size growth ratio when expanding into a jump table (in percent). The parameter is used when optimizing for size. -param=jump-table-max-growth-ratio-for-speed= -Common Joined UInteger Var(param_jump_table_max_growth_ratio_for_speed) Init(800) Param Optimization +Common Joined UInteger Var(param_jump_table_max_growth_ratio_for_speed) Init(800) IntegerRange(0, 10000) Param Optimization The maximum code size growth ratio when expanding into a jump table (in percent). The parameter is used when optimizing for speed. -param=l1-cache-line-size= diff --git a/gcc/stmt.cc b/gcc/stmt.cc index 82a3e103..b239c02 100644 --- a/gcc/stmt.cc +++ b/gcc/stmt.cc @@ -746,7 +746,7 @@ emit_case_dispatch_table (tree index_expr, tree index_type, tree range, basic_block stmt_bb) { int i, ncases; - rtx *labelvec; + auto_vec<rtx> labelvec; rtx_insn *fallback_label = label_rtx (case_list[0].m_code_label); rtx_code_label *table_label = gen_label_rtx (); bool has_gaps = false; @@ -779,8 +779,7 @@ emit_case_dispatch_table (tree index_expr, tree index_type, /* Get table of labels to jump to, in order of case index. */ ncases = tree_to_shwi (range) + 1; - labelvec = XALLOCAVEC (rtx, ncases); - memset (labelvec, 0, ncases * sizeof (rtx)); + labelvec.safe_grow_cleared (ncases); for (unsigned j = 0; j < case_list.length (); j++) { @@ -860,11 +859,11 @@ emit_case_dispatch_table (tree index_expr, tree index_type, emit_jump_table_data (gen_rtx_ADDR_DIFF_VEC (CASE_VECTOR_MODE, gen_rtx_LABEL_REF (Pmode, table_label), - gen_rtvec_v (ncases, labelvec), + gen_rtvec_v (ncases, labelvec.address ()), const0_rtx, const0_rtx)); else emit_jump_table_data (gen_rtx_ADDR_VEC (CASE_VECTOR_MODE, - gen_rtvec_v (ncases, labelvec))); + gen_rtvec_v (ncases, labelvec.address ()))); /* Record no drop-through after the table. */ emit_barrier (); |