1 Star 0 Fork 128

Mingtai/gcc

forked from src-openEuler/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0036-StructReorg-Refactoring-reorder-fields-to-struct-lay.patch 46.17 KB
一键复制 编辑 原始数据 按行查看 历史
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
From 3c06a2cda7220a48866ae2dbe3f365e300cbaeca Mon Sep 17 00:00:00 2001
From: liyancheng <412998149@qq.com>
Date: Wed, 1 Jun 2022 17:22:12 +0800
Subject: [PATCH 02/12] [StructReorg] Refactoring reorder fields to struct
layout optimization
Refactor the reorder_fields optimization into struct layout optimization. Add
flag -fipa-struct-reorg=[0,1,2] to enable none, strcut reorg, reorder fields
optimizations.
---
gcc/common.opt | 6 +-
gcc/ipa-struct-reorg/ipa-struct-reorg.c | 167 +++++++++---------
gcc/ipa-struct-reorg/ipa-struct-reorg.h | 2 +-
gcc/opts.c | 12 ++
gcc/passes.def | 2 +-
gcc/symbol-summary.h | 4 +-
.../struct/rf_DTE_struct_instance_field.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_DTE_verify.c | 2 +-
.../gcc.dg/struct/rf_check_ptr_layers_bug.c | 2 +-
.../gcc.dg/struct/rf_create_fields_bug.c | 2 +-
.../gcc.dg/struct/rf_create_new_func_bug.c | 2 +-
.../gcc.dg/struct/rf_ele_minus_verify.c | 2 +-
.../gcc.dg/struct/rf_escape_by_base.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_int_cast_ptr.c | 2 +-
.../gcc.dg/struct/rf_mem_ref_offset.c | 2 +-
.../struct/rf_mul_layer_ptr_record_bug.c | 2 +-
.../gcc.dg/struct/rf_pass_conflict.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_ptr2void_lto.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_ptr_diff.c | 2 +-
.../gcc.dg/struct/rf_ptr_negate_expr.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_ptr_offset.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_ptr_ptr_ptr.c | 2 +-
.../gcc.dg/struct/rf_rescusive_type.c | 2 +-
.../struct/rf_rewrite_assign_more_cmp.c | 2 +-
.../gcc.dg/struct/rf_rewrite_cond_bug.c | 2 +-
.../gcc.dg/struct/rf_rewrite_cond_more_cmp.c | 2 +-
.../gcc.dg/struct/rf_rewrite_phi_bug.c | 2 +-
gcc/testsuite/gcc.dg/struct/rf_visible_func.c | 2 +-
.../gcc.dg/struct/rf_void_ptr_param_func.c | 2 +-
.../gcc.dg/struct/sr_pointer_minus.c | 2 +-
gcc/testsuite/gcc.dg/struct/struct-reorg.exp | 19 ++
gcc/timevar.def | 2 +-
gcc/tree-pass.h | 2 +-
gcc/tree.c | 4 +-
35 files changed, 153 insertions(+), 117 deletions(-)
diff --git a/gcc/common.opt b/gcc/common.opt
index 4dd566def..7fc075d35 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1876,13 +1876,17 @@ Common Ignore
Does nothing. Preserved for backward compatibility.
fipa-reorder-fields
-Common Report Var(flag_ipa_reorder_fields) Init(0) Optimization
+Common Report Var(flag_ipa_struct_layout) Init(0) Optimization
Perform structure fields reorder optimizations.
fipa-struct-reorg
Common Report Var(flag_ipa_struct_reorg) Init(0) Optimization
Perform structure layout optimizations.
+fipa-struct-reorg=
+Common RejectNegative Joined UInteger Var(struct_layout_optimize_level) Init(0) IntegerRange(0, 2)
+-fipa-struct-reorg=[0,1,2] adding none, struct-reorg, reorder-fields optimizations.
+
fipa-extend-auto-profile
Common Report Var(flag_ipa_extend_auto_profile)
Use sample profile information for source code.
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
index 2bf41e0d8..9214ee74a 100644
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
@@ -235,7 +235,7 @@ enum srmode
{
NORMAL = 0,
COMPLETE_STRUCT_RELAYOUT,
- STRUCT_REORDER_FIELDS
+ STRUCT_LAYOUT_OPTIMIZE
};
static bool is_result_of_mult (tree arg, tree *num, tree struct_size);
@@ -552,7 +552,7 @@ void
srtype::simple_dump (FILE *f)
{
print_generic_expr (f, type);
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
fprintf (f, "(%d)", TYPE_UID (type));
}
@@ -593,9 +593,9 @@ srfield::create_new_fields (tree newtype[max_split],
tree newfields[max_split],
tree newlast[max_split])
{
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
- create_new_reorder_fields (newtype, newfields, newlast);
+ create_new_optimized_fields (newtype, newfields, newlast);
return;
}
@@ -689,15 +689,15 @@ srfield::reorder_fields (tree newfields[max_split], tree newlast[max_split],
}
}
-/* Create the new reorder fields for this field.
+/* Create the new optimized fields for this field.
newtype[max_split]: srtype's member variable,
newfields[max_split]: created by create_new_type func,
newlast[max_split]: created by create_new_type func. */
void
-srfield::create_new_reorder_fields (tree newtype[max_split],
- tree newfields[max_split],
- tree newlast[max_split])
+srfield::create_new_optimized_fields (tree newtype[max_split],
+ tree newfields[max_split],
+ tree newlast[max_split])
{
/* newtype, corresponding to newtype[max_split] in srtype. */
tree nt = NULL_TREE;
@@ -794,7 +794,7 @@ srtype::create_new_type (void)
we are not splitting the struct into two clusters,
then just return false and don't change the type. */
if (!createnewtype && maxclusters == 0
- && current_mode != STRUCT_REORDER_FIELDS)
+ && current_mode != STRUCT_LAYOUT_OPTIMIZE)
{
newtype[0] = type;
return false;
@@ -822,8 +822,8 @@ srtype::create_new_type (void)
sprintf(id, "%d", i);
if (tname)
{
- name = concat (tname, current_mode == STRUCT_REORDER_FIELDS
- ? ".reorder." : ".reorg.", id, NULL);
+ name = concat (tname, current_mode == STRUCT_LAYOUT_OPTIMIZE
+ ? ".slo." : ".reorg.", id, NULL);
TYPE_NAME (newtype[i]) = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
get_identifier (name), newtype[i]);
free (name);
@@ -969,8 +969,8 @@ srfunction::create_new_decls (void)
sprintf(id, "%d", j);
if (tname)
{
- name = concat (tname, current_mode == STRUCT_REORDER_FIELDS
- ? ".reorder." : ".reorg.", id, NULL);
+ name = concat (tname, current_mode == STRUCT_LAYOUT_OPTIMIZE
+ ? ".slo." : ".reorg.", id, NULL);
new_name = get_identifier (name);
free (name);
}
@@ -2718,7 +2718,7 @@ escape_type escape_type_volatile_array_or_ptrptr (tree type)
return escape_volatile;
if (isarraytype (type))
return escape_array;
- if (isptrptr (type) && (current_mode != STRUCT_REORDER_FIELDS))
+ if (isptrptr (type) && (current_mode != STRUCT_LAYOUT_OPTIMIZE))
return escape_ptr_ptr;
return does_not_escape;
}
@@ -2740,13 +2740,13 @@ ipa_struct_reorg::record_field_type (tree field, srtype *base_srtype)
field_srtype->add_field_site (field_srfield);
}
if (field_srtype == base_srtype && current_mode != COMPLETE_STRUCT_RELAYOUT
- && current_mode != STRUCT_REORDER_FIELDS)
+ && current_mode != STRUCT_LAYOUT_OPTIMIZE)
{
base_srtype->mark_escape (escape_rescusive_type, NULL);
}
/* Types of non-pointer field are difficult to track the correctness
of the rewrite when it used by the escaped type. */
- if (current_mode == STRUCT_REORDER_FIELDS
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& TREE_CODE (field_type) == RECORD_TYPE)
{
field_srtype->mark_escape (escape_instance_field, NULL);
@@ -2781,7 +2781,7 @@ ipa_struct_reorg::record_struct_field_types (tree base_type,
}
/* Types of non-pointer field are difficult to track the correctness
of the rewrite when it used by the escaped type. */
- if (current_mode == STRUCT_REORDER_FIELDS
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& TREE_CODE (field_type) == RECORD_TYPE)
{
base_srtype->mark_escape (escape_instance_field, NULL);
@@ -2966,7 +2966,7 @@ ipa_struct_reorg::record_var (tree decl, escape_type escapes, int arg)
/* Separate instance is hard to trace in complete struct
relayout optimization. */
if ((current_mode == COMPLETE_STRUCT_RELAYOUT
- || current_mode == STRUCT_REORDER_FIELDS)
+ || current_mode == STRUCT_LAYOUT_OPTIMIZE)
&& TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE)
{
e = escape_separate_instance;
@@ -3071,7 +3071,7 @@ ipa_struct_reorg::find_vars (gimple *stmt)
/* Add a safe func mechanism. */
bool l_find = true;
bool r_find = true;
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
l_find = !(current_function->is_safe_func
&& TREE_CODE (lhs) == SSA_NAME
@@ -3117,7 +3117,7 @@ ipa_struct_reorg::find_vars (gimple *stmt)
}
}
}
- else if ((current_mode == STRUCT_REORDER_FIELDS)
+ else if ((current_mode == STRUCT_LAYOUT_OPTIMIZE)
&& (gimple_assign_rhs_code (stmt) == LE_EXPR
|| gimple_assign_rhs_code (stmt) == LT_EXPR
|| gimple_assign_rhs_code (stmt) == GE_EXPR
@@ -3128,7 +3128,7 @@ ipa_struct_reorg::find_vars (gimple *stmt)
find_var (gimple_assign_rhs2 (stmt), stmt);
}
/* find void ssa_name from stmt such as: _2 = _1 - old_arcs_1. */
- else if ((current_mode == STRUCT_REORDER_FIELDS)
+ else if ((current_mode == STRUCT_LAYOUT_OPTIMIZE)
&& gimple_assign_rhs_code (stmt) == POINTER_DIFF_EXPR
&& types_compatible_p (
TYPE_MAIN_VARIANT (TREE_TYPE (gimple_assign_rhs1 (stmt))),
@@ -3391,11 +3391,12 @@ is_result_of_mult (tree arg, tree *num, tree struct_size)
arg = gimple_assign_rhs1 (size_def_stmt);
size_def_stmt = SSA_NAME_DEF_STMT (arg);
}
- else if (rhs_code == NEGATE_EXPR && current_mode == STRUCT_REORDER_FIELDS)
+ else if (rhs_code == NEGATE_EXPR
+ && current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
return trace_calculate_negate (size_def_stmt, num, struct_size);
}
- else if (rhs_code == NOP_EXPR && current_mode == STRUCT_REORDER_FIELDS)
+ else if (rhs_code == NOP_EXPR && current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
return trace_calculate_diff (size_def_stmt, num);
}
@@ -3415,7 +3416,7 @@ is_result_of_mult (tree arg, tree *num, tree struct_size)
bool
ipa_struct_reorg::handled_allocation_stmt (gimple *stmt)
{
- if ((current_mode == STRUCT_REORDER_FIELDS)
+ if ((current_mode == STRUCT_LAYOUT_OPTIMIZE)
&& (gimple_call_builtin_p (stmt, BUILT_IN_REALLOC)
|| gimple_call_builtin_p (stmt, BUILT_IN_MALLOC)
|| gimple_call_builtin_p (stmt, BUILT_IN_CALLOC)))
@@ -3548,7 +3549,7 @@ ipa_struct_reorg::maybe_mark_or_record_other_side (tree side, tree other, gimple
/* x_1 = y.x_nodes; void *x;
Directly mark the structure pointer type assigned
to the void* variable as escape. */
- else if (current_mode == STRUCT_REORDER_FIELDS
+ else if (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& TREE_CODE (side) == SSA_NAME
&& VOID_POINTER_P (TREE_TYPE (side))
&& SSA_NAME_VAR (side)
@@ -3815,7 +3816,7 @@ ipa_struct_reorg::get_type_field (tree expr, tree &base, bool &indirect,
and doesn't mark escape follow.). */
/* _1 = MEM[(struct arc_t * *)a_1].
then base a_1: ssa_name - pointer_type - integer_type. */
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
bool is_int_ptr = POINTER_TYPE_P (TREE_TYPE (base))
&& (TREE_CODE (inner_type (TREE_TYPE (base)))
@@ -4031,7 +4032,7 @@ ipa_struct_reorg::maybe_record_call (cgraph_node *node, gcall *stmt)
/* callee_func (_1, _2);
Check the callee func, instead of current func. */
if (!(free_or_realloc
- || (current_mode == STRUCT_REORDER_FIELDS
+ || (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& safe_functions.contains (
node->get_edge (stmt)->callee)))
&& VOID_POINTER_P (argtypet))
@@ -4063,9 +4064,9 @@ ipa_struct_reorg::record_stmt_expr (tree expr, cgraph_node *node, gimple *stmt)
realpart, imagpart, address, escape_from_base))
return;
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
- if (!opt_for_fn (current_function_decl, flag_ipa_reorder_fields))
+ if (!opt_for_fn (current_function_decl, flag_ipa_struct_layout))
{
type->mark_escape (escape_non_optimize, stmt);
}
@@ -4287,7 +4288,7 @@ ipa_struct_reorg::check_definition_call (srdecl *decl, vec<srdecl*> &worklist)
check_type_and_push (gimple_call_arg (stmt, 0), decl, worklist, stmt);
}
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
if (!handled_allocation_stmt (stmt))
{
@@ -4341,7 +4342,7 @@ ipa_struct_reorg::check_definition (srdecl *decl, vec<srdecl*> &worklist)
}
return;
}
- if (current_mode == STRUCT_REORDER_FIELDS && SSA_NAME_VAR (ssa_name)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE && SSA_NAME_VAR (ssa_name)
&& VOID_POINTER_P (TREE_TYPE (SSA_NAME_VAR (ssa_name))))
{
type->mark_escape (escape_cast_void, SSA_NAME_DEF_STMT (ssa_name));
@@ -4442,7 +4443,7 @@ ipa_struct_reorg::check_other_side (srdecl *decl, tree other, gimple *stmt, vec<
if (!get_type_field (other, base, indirect, type1, field,
realpart, imagpart, address, escape_from_base))
{
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
/* release INTEGER_TYPE cast to struct pointer. */
bool cast_from_int_ptr = current_function->is_safe_func && base
@@ -4498,7 +4499,7 @@ get_base (tree &base, tree expr)
void
ipa_struct_reorg::check_ptr_layers (tree a_expr, tree b_expr, gimple* stmt)
{
- if (current_mode != STRUCT_REORDER_FIELDS || current_function->is_safe_func
+ if (current_mode != STRUCT_LAYOUT_OPTIMIZE || current_function->is_safe_func
|| !(POINTER_TYPE_P (TREE_TYPE (a_expr)))
|| !(POINTER_TYPE_P (TREE_TYPE (b_expr)))
|| !handled_type (TREE_TYPE (a_expr))
@@ -4579,7 +4580,7 @@ ipa_struct_reorg::check_use (srdecl *decl, gimple *stmt, vec<srdecl*> &worklist)
&& (code != EQ_EXPR && code != NE_EXPR
&& code != LT_EXPR && code != LE_EXPR
&& code != GT_EXPR && code != GE_EXPR))
- || (current_mode == STRUCT_REORDER_FIELDS
+ || (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& (code != EQ_EXPR && code != NE_EXPR
&& code != LT_EXPR && code != LE_EXPR
&& code != GT_EXPR && code != GE_EXPR)))
@@ -4618,7 +4619,7 @@ ipa_struct_reorg::check_use (srdecl *decl, gimple *stmt, vec<srdecl*> &worklist)
&& (code != EQ_EXPR && code != NE_EXPR
&& code != LT_EXPR && code != LE_EXPR
&& code != GT_EXPR && code != GE_EXPR))
- || (current_mode == STRUCT_REORDER_FIELDS
+ || (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& (code != EQ_EXPR && code != NE_EXPR
&& code != LT_EXPR && code != LE_EXPR
&& code != GT_EXPR && code != GE_EXPR)))
@@ -4740,11 +4741,11 @@ ipa_struct_reorg::record_function (cgraph_node *node)
escapes = escape_marked_as_used;
else if (!node->local)
{
- if (current_mode != STRUCT_REORDER_FIELDS)
+ if (current_mode != STRUCT_LAYOUT_OPTIMIZE)
{
escapes = escape_visible_function;
}
- if (current_mode == STRUCT_REORDER_FIELDS && node->externally_visible)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE && node->externally_visible)
{
escapes = escape_visible_function;
}
@@ -4754,9 +4755,9 @@ ipa_struct_reorg::record_function (cgraph_node *node)
else if (!tree_versionable_function_p (node->decl))
escapes = escape_noclonable_function;
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
- if (!opt_for_fn (node->decl, flag_ipa_reorder_fields))
+ if (!opt_for_fn (node->decl, flag_ipa_struct_layout))
{
escapes = escape_non_optimize;
}
@@ -4773,7 +4774,7 @@ ipa_struct_reorg::record_function (cgraph_node *node)
gimple_stmt_iterator si;
/* Add a safe func mechanism. */
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
current_function->is_safe_func = safe_functions.contains (node);
if (dump_file)
@@ -4989,7 +4990,7 @@ ipa_struct_reorg::record_accesses (void)
}
/* Add a safe func mechanism. */
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
record_safe_func_with_void_ptr_parm ();
}
@@ -5188,7 +5189,7 @@ void
ipa_struct_reorg::prune_escaped_types (void)
{
if (current_mode != COMPLETE_STRUCT_RELAYOUT
- && current_mode != STRUCT_REORDER_FIELDS)
+ && current_mode != STRUCT_LAYOUT_OPTIMIZE)
{
/* Detect recusive types and mark them as escaping. */
detect_cycles ();
@@ -5196,7 +5197,7 @@ ipa_struct_reorg::prune_escaped_types (void)
mark them as escaping. */
propagate_escape ();
}
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
propagate_escape_via_original ();
propagate_escape_via_empty_with_no_original ();
@@ -5256,7 +5257,7 @@ ipa_struct_reorg::prune_escaped_types (void)
if (function->args.is_empty ()
&& function->decls.is_empty ()
&& function->globals.is_empty ()
- && current_mode != STRUCT_REORDER_FIELDS)
+ && current_mode != STRUCT_LAYOUT_OPTIMIZE)
{
delete function;
functions.ordered_remove (i);
@@ -5281,10 +5282,10 @@ ipa_struct_reorg::prune_escaped_types (void)
/* Prune types that escape, all references to those types
will have been removed in the above loops. */
- /* The escape type is not deleted in STRUCT_REORDER_FIELDS,
+ /* The escape type is not deleted in STRUCT_LAYOUT_OPTIMIZE,
Then the type that contains the escaped type fields
can find complete information. */
- if (current_mode != STRUCT_REORDER_FIELDS)
+ if (current_mode != STRUCT_LAYOUT_OPTIMIZE)
{
for (unsigned i = 0; i < types.length ();)
{
@@ -5334,7 +5335,7 @@ ipa_struct_reorg::create_new_types (void)
for (unsigned i = 0; i < types.length (); i++)
newtypes += types[i]->create_new_type ();
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
for (unsigned i = 0; i < types.length (); i++)
{
@@ -5458,8 +5459,8 @@ ipa_struct_reorg::create_new_args (cgraph_node *new_node)
char *name = NULL;
if (tname)
{
- name = concat (tname, current_mode == STRUCT_REORDER_FIELDS
- ? ".reorder.0" : ".reorg.0", NULL);
+ name = concat (tname, current_mode == STRUCT_LAYOUT_OPTIMIZE
+ ? ".slo.0" : ".reorg.0", NULL);
new_name = get_identifier (name);
free (name);
}
@@ -5547,8 +5548,8 @@ ipa_struct_reorg::create_new_functions (void)
statistics_counter_event (NULL, "Create new function", 1);
new_node = node->create_version_clone_with_body (
vNULL, NULL, NULL, NULL, NULL,
- current_mode == STRUCT_REORDER_FIELDS
- ? "struct_reorder" : "struct_reorg");
+ current_mode == STRUCT_LAYOUT_OPTIMIZE
+ ? "slo" : "struct_reorg");
new_node->can_change_signature = node->can_change_signature;
new_node->make_local ();
f->newnode = new_node;
@@ -5666,13 +5667,13 @@ ipa_struct_reorg::rewrite_expr (tree expr, tree newexpr[max_split], bool ignore_
newbase1 = build_fold_addr_expr (newbase1);
if (indirect)
{
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
/* Supports the MEM_REF offset.
_1 = MEM[(struct arc *)ap_1 + 72B].flow;
- Old rewrite: _1 = ap.reorder.0_8->flow;
+ Old rewrite: _1 = ap.slo.0_8->flow;
New rewrite: _1
- = MEM[(struct arc.reorder.0 *)ap.reorder.0_8 + 64B].flow;
+ = MEM[(struct arc.slo.0 *)ap.slo.0_8 + 64B].flow;
*/
HOST_WIDE_INT offset_tmp = 0;
HOST_WIDE_INT mem_offset = 0;
@@ -5738,10 +5739,10 @@ ipa_struct_reorg::rewrite_assign (gassign *stmt, gimple_stmt_iterator *gsi)
return remove;
}
- if ((current_mode != STRUCT_REORDER_FIELDS
+ if ((current_mode != STRUCT_LAYOUT_OPTIMIZE
&& (gimple_assign_rhs_code (stmt) == EQ_EXPR
|| gimple_assign_rhs_code (stmt) == NE_EXPR))
- || (current_mode == STRUCT_REORDER_FIELDS
+ || (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& (TREE_CODE_CLASS (gimple_assign_rhs_code (stmt))
== tcc_comparison)))
{
@@ -5751,7 +5752,7 @@ ipa_struct_reorg::rewrite_assign (gassign *stmt, gimple_stmt_iterator *gsi)
tree newrhs2[max_split];
tree_code rhs_code = gimple_assign_rhs_code (stmt);
tree_code code = rhs_code == EQ_EXPR ? BIT_AND_EXPR : BIT_IOR_EXPR;
- if (current_mode == STRUCT_REORDER_FIELDS
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& rhs_code != EQ_EXPR && rhs_code != NE_EXPR)
{
code = rhs_code;
@@ -5798,8 +5799,8 @@ ipa_struct_reorg::rewrite_assign (gassign *stmt, gimple_stmt_iterator *gsi)
_6 = _4 + _5;
_5 = (long unsigned int) _3;
_3 = _1 - old_2. */
- if (current_mode != STRUCT_REORDER_FIELDS
- || (current_mode == STRUCT_REORDER_FIELDS && (num != NULL)))
+ if (current_mode != STRUCT_LAYOUT_OPTIMIZE
+ || (current_mode == STRUCT_LAYOUT_OPTIMIZE && (num != NULL)))
{
num = gimplify_build1 (gsi, NOP_EXPR, sizetype, num);
}
@@ -5827,7 +5828,7 @@ ipa_struct_reorg::rewrite_assign (gassign *stmt, gimple_stmt_iterator *gsi)
}
/* Support POINTER_DIFF_EXPR rewriting. */
- if (current_mode == STRUCT_REORDER_FIELDS
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& gimple_assign_rhs_code (stmt) == POINTER_DIFF_EXPR)
{
tree rhs1 = gimple_assign_rhs1 (stmt);
@@ -6014,7 +6015,7 @@ ipa_struct_reorg::rewrite_call (gcall *stmt, gimple_stmt_iterator *gsi)
srfunction *f = find_function (node);
/* Add a safe func mechanism. */
- if (current_mode == STRUCT_REORDER_FIELDS && f && f->is_safe_func)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE && f && f->is_safe_func)
{
tree expr = gimple_call_arg (stmt, 0);
tree newexpr[max_split];
@@ -6141,9 +6142,9 @@ ipa_struct_reorg::rewrite_cond (gcond *stmt, gimple_stmt_iterator *gsi)
tree_code rhs_code = gimple_cond_code (stmt);
/* Handle only equals or not equals conditionals. */
- if ((current_mode != STRUCT_REORDER_FIELDS
+ if ((current_mode != STRUCT_LAYOUT_OPTIMIZE
&& (rhs_code != EQ_EXPR && rhs_code != NE_EXPR))
- || (current_mode == STRUCT_REORDER_FIELDS
+ || (current_mode == STRUCT_LAYOUT_OPTIMIZE
&& TREE_CODE_CLASS (rhs_code) != tcc_comparison))
return false;
tree lhs = gimple_cond_lhs (stmt);
@@ -6171,10 +6172,10 @@ ipa_struct_reorg::rewrite_cond (gcond *stmt, gimple_stmt_iterator *gsi)
}
/* Old rewrite: if (x_1 != 0B)
- -> _1 = x.reorder.0_1 != 0B; if (_1 != 1)
+ -> _1 = x.slo.0_1 != 0B; if (_1 != 1)
The logic is incorrect.
New rewrite: if (x_1 != 0B)
- -> if (x.reorder.0_1 != 0B);*/
+ -> if (x.slo.0_1 != 0B);*/
for (unsigned i = 0; i < max_split && (newlhs[i] || newrhs[i]); i++)
{
if (newlhs[i])
@@ -6203,7 +6204,7 @@ ipa_struct_reorg::rewrite_cond (gcond *stmt, gimple_stmt_iterator *gsi)
bool
ipa_struct_reorg::rewrite_debug (gimple *stmt, gimple_stmt_iterator *)
{
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
/* Delete debug gimple now. */
return true;
@@ -6367,7 +6368,7 @@ ipa_struct_reorg::rewrite_functions (void)
then don't rewrite any accesses. */
if (!create_new_types ())
{
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
for (unsigned i = 0; i < functions.length (); i++)
{
@@ -6386,7 +6387,7 @@ ipa_struct_reorg::rewrite_functions (void)
return 0;
}
- if (current_mode == STRUCT_REORDER_FIELDS && dump_file)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE && dump_file)
{
fprintf (dump_file, "=========== all created newtypes: ===========\n\n");
dump_newtypes (dump_file);
@@ -6396,13 +6397,13 @@ ipa_struct_reorg::rewrite_functions (void)
{
retval = TODO_remove_functions;
create_new_functions ();
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
prune_escaped_types ();
}
}
- if (current_mode == STRUCT_REORDER_FIELDS)
+ if (current_mode == STRUCT_LAYOUT_OPTIMIZE)
{
for (unsigned i = 0; i < functions.length (); i++)
{
@@ -6572,7 +6573,7 @@ ipa_struct_reorg::execute (enum srmode mode)
{
unsigned int ret = 0;
- if (mode == NORMAL || mode == STRUCT_REORDER_FIELDS)
+ if (mode == NORMAL || mode == STRUCT_LAYOUT_OPTIMIZE)
{
current_mode = mode;
/* If there is a top-level inline-asm,
@@ -6660,12 +6661,12 @@ pass_ipa_struct_reorg::gate (function *)
&& (in_lto_p || flag_whole_program));
}
-const pass_data pass_data_ipa_reorder_fields =
+const pass_data pass_data_ipa_struct_layout =
{
SIMPLE_IPA_PASS, // type
- "reorder_fields", // name
+ "struct_layout", // name
OPTGROUP_NONE, // optinfo_flags
- TV_IPA_REORDER_FIELDS, // tv_id
+ TV_IPA_STRUCT_LAYOUT, // tv_id
0, // properties_required
0, // properties_provided
0, // properties_destroyed
@@ -6673,11 +6674,11 @@ const pass_data pass_data_ipa_reorder_fields =
0, // todo_flags_finish
};
-class pass_ipa_reorder_fields : public simple_ipa_opt_pass
+class pass_ipa_struct_layout : public simple_ipa_opt_pass
{
public:
- pass_ipa_reorder_fields (gcc::context *ctxt)
- : simple_ipa_opt_pass (pass_data_ipa_reorder_fields, ctxt)
+ pass_ipa_struct_layout (gcc::context *ctxt)
+ : simple_ipa_opt_pass (pass_data_ipa_struct_layout, ctxt)
{}
/* opt_pass methods: */
@@ -6685,17 +6686,17 @@ public:
virtual unsigned int execute (function *)
{
unsigned int ret = 0;
- ret = ipa_struct_reorg ().execute (STRUCT_REORDER_FIELDS);
+ ret = ipa_struct_reorg ().execute (STRUCT_LAYOUT_OPTIMIZE);
return ret;
}
-}; // class pass_ipa_reorder_fields
+}; // class pass_ipa_struct_layout
bool
-pass_ipa_reorder_fields::gate (function *)
+pass_ipa_struct_layout::gate (function *)
{
return (optimize >= 3
- && flag_ipa_reorder_fields
+ && flag_ipa_struct_layout
/* Don't bother doing anything if the program has errors. */
&& !seen_error ()
&& flag_lto_partition == LTO_PARTITION_ONE
@@ -6715,7 +6716,7 @@ make_pass_ipa_struct_reorg (gcc::context *ctxt)
}
simple_ipa_opt_pass *
-make_pass_ipa_reorder_fields (gcc::context *ctxt)
+make_pass_ipa_struct_layout (gcc::context *ctxt)
{
- return new pass_ipa_reorder_fields (ctxt);
+ return new pass_ipa_struct_layout (ctxt);
}
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.h b/gcc/ipa-struct-reorg/ipa-struct-reorg.h
index 8fb6ce9c4..54b0dc655 100644
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.h
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.h
@@ -187,7 +187,7 @@ struct srfield
tree newlast[max_split]);
void reorder_fields (tree newfields[max_split], tree newlast[max_split],
tree &field);
- void create_new_reorder_fields (tree newtype[max_split],
+ void create_new_optimized_fields (tree newtype[max_split],
tree newfields[max_split],
tree newlast[max_split]);
};
diff --git a/gcc/opts.c b/gcc/opts.c
index 479d726df..c3877c24e 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2695,6 +2695,18 @@ common_handle_option (struct gcc_options *opts,
}
break;
+ case OPT_fipa_struct_reorg_:
+ opts->x_struct_layout_optimize_level = value;
+ if (value > 1)
+ {
+ SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_struct_layout, value);
+ }
+ /* No break here - do -fipa-struct-reorg processing. */
+ /* FALLTHRU. */
+ case OPT_fipa_struct_reorg:
+ opts->x_flag_ipa_struct_reorg = value;
+ break;
+
case OPT_fprofile_generate_:
opts->x_profile_data_prefix = xstrdup (arg);
value = true;
diff --git a/gcc/passes.def b/gcc/passes.def
index e9c91d26e..eea4d7808 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -174,7 +174,7 @@ along with GCC; see the file COPYING3. If not see
INSERT_PASSES_AFTER (all_late_ipa_passes)
NEXT_PASS (pass_materialize_all_clones);
NEXT_PASS (pass_ipa_pta);
- NEXT_PASS (pass_ipa_reorder_fields);
+ NEXT_PASS (pass_ipa_struct_layout);
/* FIXME: this should a normal IP pass */
NEXT_PASS (pass_ipa_struct_reorg);
NEXT_PASS (pass_omp_simd_clone);
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index ddf5e3577..f62222a96 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -61,7 +61,7 @@ protected:
{
/* In structure optimizatons, we call new to ensure that
the allocated memory is initialized to 0. */
- if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
+ if (flag_ipa_struct_layout || flag_ipa_struct_reorg)
return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T ()
: new T ();
/* Call gcc_internal_because we do not want to call finalizer for
@@ -77,7 +77,7 @@ protected:
ggc_delete (item);
else
{
- if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
+ if (flag_ipa_struct_layout || flag_ipa_struct_reorg)
delete item;
else
m_allocator.remove (item);
diff --git a/gcc/testsuite/gcc.dg/struct/rf_DTE_struct_instance_field.c b/gcc/testsuite/gcc.dg/struct/rf_DTE_struct_instance_field.c
index b95be2dab..882a695b0 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_DTE_struct_instance_field.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_DTE_struct_instance_field.c
@@ -72,4 +72,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "No structures to transform." "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "No structures to transform." "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_DTE_verify.c b/gcc/testsuite/gcc.dg/struct/rf_DTE_verify.c
index 3d243313b..20ecee545 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_DTE_verify.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_DTE_verify.c
@@ -91,4 +91,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_check_ptr_layers_bug.c b/gcc/testsuite/gcc.dg/struct/rf_check_ptr_layers_bug.c
index a5477dcc9..ad879fc11 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_check_ptr_layers_bug.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_check_ptr_layers_bug.c
@@ -21,4 +21,4 @@ main()
{
g();
}
-/* { dg-final { scan-ipa-dump "No structures to transform." "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "No structures to transform." "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c b/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c
index 886706ae9..f0c9d8f39 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c
@@ -79,4 +79,4 @@ main()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_create_new_func_bug.c b/gcc/testsuite/gcc.dg/struct/rf_create_new_func_bug.c
index f3785f392..fa5e6c2d0 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_create_new_func_bug.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_create_new_func_bug.c
@@ -53,4 +53,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_ele_minus_verify.c b/gcc/testsuite/gcc.dg/struct/rf_ele_minus_verify.c
index 1415d759a..2966869e7 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_ele_minus_verify.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_ele_minus_verify.c
@@ -57,4 +57,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_escape_by_base.c b/gcc/testsuite/gcc.dg/struct/rf_escape_by_base.c
index 003da0b57..b74b9e5e9 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_escape_by_base.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_escape_by_base.c
@@ -80,4 +80,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_int_cast_ptr.c b/gcc/testsuite/gcc.dg/struct/rf_int_cast_ptr.c
index 10dcf098c..cf85c6109 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_int_cast_ptr.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_int_cast_ptr.c
@@ -69,4 +69,4 @@ main()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_mem_ref_offset.c b/gcc/testsuite/gcc.dg/struct/rf_mem_ref_offset.c
index 8d1a9a114..61fd9f755 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_mem_ref_offset.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_mem_ref_offset.c
@@ -55,4 +55,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_mul_layer_ptr_record_bug.c b/gcc/testsuite/gcc.dg/struct/rf_mul_layer_ptr_record_bug.c
index 23765fc56..2c115da02 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_mul_layer_ptr_record_bug.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_mul_layer_ptr_record_bug.c
@@ -27,4 +27,4 @@ main() {
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c b/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c
index 54e737ee8..c7646d8b7 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c
@@ -106,4 +106,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_ptr2void_lto.c b/gcc/testsuite/gcc.dg/struct/rf_ptr2void_lto.c
index 2ae46fb31..01c000375 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_ptr2void_lto.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_ptr2void_lto.c
@@ -84,4 +84,4 @@ main ()
return cnt;
}
-/* { dg-final { scan-ipa-dump "No structures to transform." "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "No structures to transform." "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_ptr_diff.c b/gcc/testsuite/gcc.dg/struct/rf_ptr_diff.c
index 3a3c10b70..f962163fe 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_ptr_diff.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_ptr_diff.c
@@ -68,4 +68,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 3" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 3" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_ptr_negate_expr.c b/gcc/testsuite/gcc.dg/struct/rf_ptr_negate_expr.c
index 7b7d110df..6558b1797 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_ptr_negate_expr.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_ptr_negate_expr.c
@@ -52,4 +52,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_ptr_offset.c b/gcc/testsuite/gcc.dg/struct/rf_ptr_offset.c
index 317aafa5f..6d528ed5b 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_ptr_offset.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_ptr_offset.c
@@ -31,4 +31,4 @@ main ()
printf (" Tree.\n");
}
-/* { dg-final { scan-ipa-dump "No structures to transform." "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "No structures to transform." "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c b/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c
index 01a33f669..e95cf2e5d 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c
@@ -52,4 +52,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr_ptr.c b/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr_ptr.c
index a38556533..cb4054522 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr_ptr.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr_ptr.c
@@ -55,4 +55,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_rescusive_type.c b/gcc/testsuite/gcc.dg/struct/rf_rescusive_type.c
index 5c17ee528..38bddbae5 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_rescusive_type.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_rescusive_type.c
@@ -54,4 +54,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_rewrite_assign_more_cmp.c b/gcc/testsuite/gcc.dg/struct/rf_rewrite_assign_more_cmp.c
index 710517ee9..86034f042 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_rewrite_assign_more_cmp.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_rewrite_assign_more_cmp.c
@@ -62,4 +62,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_bug.c b/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_bug.c
index 6ed0a5d2d..aae7c4bc9 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_bug.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_bug.c
@@ -69,4 +69,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 3" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 3" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c b/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c
index 5a2dd964f..8672e7552 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c
@@ -55,4 +55,4 @@ main()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_rewrite_phi_bug.c b/gcc/testsuite/gcc.dg/struct/rf_rewrite_phi_bug.c
index faa90b42d..2d67434a0 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_rewrite_phi_bug.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_rewrite_phi_bug.c
@@ -78,4 +78,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 3" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 3" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_visible_func.c b/gcc/testsuite/gcc.dg/struct/rf_visible_func.c
index 8f2da99cc..a8cf2b63c 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_visible_func.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_visible_func.c
@@ -89,4 +89,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/rf_void_ptr_param_func.c b/gcc/testsuite/gcc.dg/struct/rf_void_ptr_param_func.c
index 723142c59..b6cba3c34 100644
--- a/gcc/testsuite/gcc.dg/struct/rf_void_ptr_param_func.c
+++ b/gcc/testsuite/gcc.dg/struct/rf_void_ptr_param_func.c
@@ -51,4 +51,4 @@ main()
return 0;
}
-/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "reorder_fields" } } */
\ No newline at end of file
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "struct_layout" } } */
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/struct/sr_pointer_minus.c b/gcc/testsuite/gcc.dg/struct/sr_pointer_minus.c
index 9a82da0d6..a0614a1ba 100644
--- a/gcc/testsuite/gcc.dg/struct/sr_pointer_minus.c
+++ b/gcc/testsuite/gcc.dg/struct/sr_pointer_minus.c
@@ -30,4 +30,4 @@ main ()
return 0;
}
-/* { dg-final { scan-ipa-dump "struct node has escaped: \"Type escapes via a unhandled rewrite stmt\"" "struct_reorg" } } */
+/* { dg-final { scan-ipa-dump "has escaped: \"Type escapes via a unhandled rewrite stmt\"" "struct_reorg" } } */
diff --git a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp
index c8db4675f..67b3ac2d5 100644
--- a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp
+++ b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp
@@ -47,6 +47,25 @@ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/complete_struct_relayout
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/rf*.c]] \
"" "-fipa-reorder-fields -fdump-ipa-all -flto-partition=one -fwhole-program"
+# -fipa-struct-reorg=1
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/wo_prof_*.c]] \
+ "" "-fipa-struct-reorg=1 -fdump-ipa-all -flto-partition=one -fwhole-program"
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/w_ratio_*.c]] \
+ "" "-fipa-struct-reorg=1 -fdump-ipa-all -flto-partition=one -fwhole-program"
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/w_prof_*.c]] \
+ "" "-fipa-struct-reorg=1 -fdump-ipa-all -flto-partition=one -fwhole-program"
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/struct_reorg*.c]] \
+ "" "-fipa-struct-reorg=1 -fdump-ipa-all -flto-partition=one -fwhole-program"
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/sr_*.c]] \
+ "" "-fipa-struct-reorg=1 -fdump-ipa-all -flto-partition=one -fwhole-program"
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/csr_*.c]] \
+ "" "-fipa-struct-reorg=1 -fdump-ipa-all -flto-partition=one -fwhole-program"
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/complete_struct_relayout.c]] \
+ "" "-fipa-struct-reorg=1 -fdump-ipa-all -flto-partition=one -fwhole-program"
+
+# -fipa-struct-reorg=2
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] \
+ "" "-fipa-struct-reorg=2 -fdump-ipa-all -flto-partition=one -fwhole-program"
# All done.
torture-finish
dg-finish
diff --git a/gcc/timevar.def b/gcc/timevar.def
index e873747a8..b179f62bb 100644
--- a/gcc/timevar.def
+++ b/gcc/timevar.def
@@ -80,7 +80,7 @@ DEFTIMEVAR (TV_IPA_CONSTANT_PROP , "ipa cp")
DEFTIMEVAR (TV_IPA_INLINING , "ipa inlining heuristics")
DEFTIMEVAR (TV_IPA_FNSPLIT , "ipa function splitting")
DEFTIMEVAR (TV_IPA_COMDATS , "ipa comdats")
-DEFTIMEVAR (TV_IPA_REORDER_FIELDS , "ipa struct reorder fields optimization")
+DEFTIMEVAR (TV_IPA_STRUCT_LAYOUT , "ipa struct layout optimization")
DEFTIMEVAR (TV_IPA_STRUCT_REORG , "ipa struct reorg optimization")
DEFTIMEVAR (TV_IPA_EXTEND_AUTO_PROFILE, "ipa extend auto profile")
DEFTIMEVAR (TV_IPA_OPT , "ipa various optimizations")
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index be6387768..187f1a85c 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -509,7 +509,7 @@ extern ipa_opt_pass_d *make_pass_ipa_odr (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_reference (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_hsa (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_pure_const (gcc::context *ctxt);
-extern simple_ipa_opt_pass *make_pass_ipa_reorder_fields (gcc::context *ctxt);
+extern simple_ipa_opt_pass *make_pass_ipa_struct_layout (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_ipa_struct_reorg (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_ipa_extend_auto_profile (gcc::context
*ctxt);
diff --git a/gcc/tree.c b/gcc/tree.c
index 89fa469c3..c2075d735 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5219,7 +5219,7 @@ fld_simplified_type_name (tree type)
/* Simplify type will cause that struct A and struct A within
struct B are different type pointers, so skip it in structure
optimizations. */
- if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
+ if (flag_ipa_struct_layout || flag_ipa_struct_reorg)
return TYPE_NAME (type);
if (!TYPE_NAME (type) || TREE_CODE (TYPE_NAME (type)) != TYPE_DECL)
@@ -5463,7 +5463,7 @@ fld_simplified_type (tree t, class free_lang_data_d *fld)
/* Simplify type will cause that struct A and struct A within
struct B are different type pointers, so skip it in structure
optimizations. */
- if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
+ if (flag_ipa_struct_layout || flag_ipa_struct_reorg)
return t;
if (POINTER_TYPE_P (t))
return fld_incomplete_type_of (t, fld);
--
2.27.0.windows.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yangmingtaip/gcc.git
git@gitee.com:yangmingtaip/gcc.git
yangmingtaip
gcc
gcc
master

搜索帮助