diff options
author | Gary Oblock <gary@amperecomputing.com> | 2020-08-19 20:28:35 -0700 |
---|---|---|
committer | Gary Oblock <gary@amperecomputing.com> | 2020-08-19 20:28:35 -0700 |
commit | 794043859c5795f20fb860459f72cf507862a628 (patch) | |
tree | 880da9d66f7d5320fb71dae578214299e3f02c14 | |
parent | 748b3cbc17d48520ba503f245c3356c7eaf3e494 (diff) |
Cleaned up the transformations so I can better base the
ones to follow on them.
-rw-r--r-- | gcc/ipa-str-reorg-instance-interleave.c | 106 |
1 files changed, 44 insertions, 62 deletions
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c index 7a9dd3ee559..fb08824f04f 100644 --- a/gcc/ipa-str-reorg-instance-interleave.c +++ b/gcc/ipa-str-reorg-instance-interleave.c @@ -378,7 +378,7 @@ str_reorg_instance_interleave_trans ( Info *info) gsi_insert_before( &gsi, get_index, GSI_SAME_STMT); gsi_insert_before( &gsi, get_offset, GSI_SAME_STMT); gsi_insert_before( &gsi, get_field_addr, GSI_SAME_STMT); - gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT); // << malformed??? + gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT); gsi_insert_before( &gsi, final_set, GSI_SAME_STMT); @@ -458,6 +458,7 @@ str_reorg_instance_interleave_trans ( Info *info) gimple *gPPI = gimple_build_assign ( ptrplusint, PLUS_EXPR, PPI_rhs1_cast, PPI_adj); SSA_NAME_DEF_STMT ( ptrplusint) = gPPI; + gimple *gPPI_cast = gimple_build_assign ( PPI_orig_lhs, CONVERT_EXPR, ptrplusint); SSA_NAME_DEF_STMT ( PPI_orig_lhs) = gPPI_cast; @@ -797,7 +798,6 @@ str_reorg_instance_interleave_trans ( Info *info) gcall *malloc_call = gimple_build_call( fndecl_malloc, 1, mem_size); gimple_call_set_lhs( malloc_call, res); SSA_NAME_DEF_STMT ( res) = malloc_call; - //gsi_insert_after( &gsi, malloc_call, GSI_SAME_STMT); cgraph_node::get ( cfun->decl)-> create_edge ( cgraph_node::get_create ( fndecl_malloc), @@ -820,15 +820,13 @@ str_reorg_instance_interleave_trans ( Info *info) NULL, NULL ); - // Last is first - gsi_insert_before ( &gsi, gcond, GSI_NEW_STMT); - - // The rest in order before the last - gsi_insert_before ( &gsi, gfield_size, GSI_SAME_STMT); - gsi_insert_before ( &gsi, gsize, GSI_SAME_STMT); - gsi_insert_before ( &gsi, malloc_call, GSI_SAME_STMT); - gsi_insert_before ( &gsi, gcast_res, GSI_SAME_STMT); - gsi_insert_before ( &gsi, gset_field, GSI_SAME_STMT); + // In execution order + gsi_insert_after ( &gsi, gfield_size, GSI_NEW_STMT); + gsi_insert_after ( &gsi, gsize, GSI_CONTINUE_LINKING); + gsi_insert_after ( &gsi, malloc_call, GSI_CONTINUE_LINKING); + gsi_insert_after ( &gsi, gcast_res, GSI_CONTINUE_LINKING); + gsi_insert_after ( &gsi, gset_field, GSI_CONTINUE_LINKING); + gsi_insert_after ( &gsi, gcond, GSI_CONTINUE_LINKING); prev_bb = new_bb; prev_order = new_bb; @@ -865,16 +863,13 @@ str_reorg_instance_interleave_trans ( Info *info) gsi = gsi_start_bb ( success_bb); // used to be failure_bb - // TBD Rewrite to not emit a nop here. - gimple *dummy = gimple_build_nop (); - gsi_insert_after ( &gsi, dummy, GSI_NEW_STMT); - gimple *set_succ = gimple_build_assign ( success_val, build_int_cst ( reorg_pointer_type, 0)); SSA_NAME_DEF_STMT ( success_val) = set_succ; - gsi_insert_after( &gsi, set_succ, GSI_SAME_STMT); + gsi_insert_after( &gsi, set_succ, GSI_NEW_STMT); + // FROM gsi_insert_after( &gsi, new_ok_field ) //gimple *gnew_ok_field = gimple_build_label ( new_ok_field_L); //gsi_insert_after ( &gsi, gnew_ok_field, GSI_SAME_STMT); @@ -910,8 +905,6 @@ str_reorg_instance_interleave_trans ( Info *info) // failure_bb code here - // if defed on here... moved this - // code in failure_bb // // FROM fail_val is new SSA //tree return_type = TREE_TYPE ( arg); @@ -920,18 +913,14 @@ str_reorg_instance_interleave_trans ( Info *info) // FROM gsi = gsi_start_bb ( failure_bb) gsi = gsi_start_bb ( failure_bb); - // TBD Rewrite to not emit nops! - gimple *dummy_fail = gimple_build_nop (); - gsi_insert_after ( &gsi, dummy_fail, GSI_NEW_STMT); + // FROM gsi_insert_after( &gsi, "fail_val = minint") + gimple *gretnull = + gimple_build_assign ( fail_val, CONVERT_EXPR, + TYPE_MIN_VALUE ( TREE_TYPE ( fail_val))); + SSA_NAME_DEF_STMT ( fail_val) = gretnull; + + gsi_insert_after( &gsi, gretnull, GSI_NEW_STMT); - // (per field) { - //tree field; // defined above - //tree reorg_type = ri->gcc_type; // is this useful here? - //tree reorg_pointer_type = ri->pointer_rep; - - // Don't use the builtin! - //tree fndecl_free = builtin_decl_explicit( BUILT_IN_FREE); - for( field = TYPE_FIELDS( reorg_type); field; field = DECL_CHAIN( field)) { @@ -940,54 +929,47 @@ str_reorg_instance_interleave_trans ( Info *info) find_coresponding_field ( base, field); tree base_field_type = TREE_TYPE( base_field); - tree lhs_ass = build3( COMPONENT_REF, - base_field_type, - base, - base_field, NULL_TREE); - - gimple *gzero = gimple_build_assign( lhs_ass, null_pointer_node); - gsi_insert_after( &gsi, gzero, GSI_SAME_STMT); - - gcc_assert ( ptr_type_node); - tree m_cast2free = - make_temp_ssa_name( ptr_type_node, NULL, "m_cast2free"); - - // Tried reorg_pointer_type gcc_assert ( base_field_type); tree m_to_free = make_temp_ssa_name( base_field_type, NULL, "malloc_to_free"); - gcall *free_call = gimple_build_call( fndecl_free, 1, m_cast2free); - gsi_insert_after( &gsi, free_call, GSI_SAME_STMT); - cgraph_node::get ( cfun->decl)-> - create_edge ( cgraph_node::get_create ( fndecl_free), - free_call, - failure_bb->count - ); - tree rhs_ass = build3( COMPONENT_REF, base_field_type, base, base_field, NULL_TREE); + + gimple *gaddr2free = gimple_build_assign( m_to_free, rhs_ass); + SSA_NAME_DEF_STMT ( m_to_free) = gaddr2free; + + gsi_insert_after( &gsi, gaddr2free, GSI_CONTINUE_LINKING); + gcc_assert ( ptr_type_node); + tree m_cast2free = + make_temp_ssa_name( ptr_type_node, NULL, "m_cast2free"); + gimple *gm_cast2free = gimple_build_assign( m_cast2free, CONVERT_EXPR, m_to_free); SSA_NAME_DEF_STMT ( m_cast2free) = gm_cast2free; - gsi_insert_after( &gsi, gm_cast2free, GSI_SAME_STMT); + gsi_insert_after( &gsi, gm_cast2free, GSI_CONTINUE_LINKING); - gimple *gaddr2free = gimple_build_assign( m_to_free, rhs_ass); - SSA_NAME_DEF_STMT ( m_to_free) = gaddr2free; + gcall *free_call = gimple_build_call( fndecl_free, 1, m_cast2free); + gsi_insert_after( &gsi, free_call, GSI_CONTINUE_LINKING); - gsi_insert_after( &gsi, gaddr2free, GSI_SAME_STMT); + cgraph_node::get ( cfun->decl)-> + create_edge ( cgraph_node::get_create ( fndecl_free), + free_call, + failure_bb->count + ); + + tree lhs_ass = build3( COMPONENT_REF, + base_field_type, + base, + base_field, NULL_TREE); + + gimple *gzero = gimple_build_assign( lhs_ass, null_pointer_node); + gsi_insert_after( &gsi, gzero, GSI_CONTINUE_LINKING); } - // FROM gsi_insert_after( &gsi, "fail_val = minint") - gimple *gretnull = - gimple_build_assign ( fail_val, CONVERT_EXPR, - TYPE_MIN_VALUE ( TREE_TYPE ( fail_val))); - SSA_NAME_DEF_STMT ( fail_val) = gretnull; - - gsi_insert_after( &gsi, gretnull, GSI_SAME_STMT); //// FROM gsi_insert_after( &gsi, bad_field ) @@ -1197,7 +1179,7 @@ str_reorg_instance_interleave_trans ( Info *info) DEBUG_L("ReorgT_Convert\n"); break; case ReorgT_Return: - // TBD The type must be adjusted (maybe.) + // TBD This case probably is unnecessary. DEBUG_L("ReorgT_Return\n"); break; default: |