diff options
Diffstat (limited to 'gcc/ipa-structure-reorg.c')
-rw-r--r-- | gcc/ipa-structure-reorg.c | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c index 58e7578a8c8..68865afbb19 100644 --- a/gcc/ipa-structure-reorg.c +++ b/gcc/ipa-structure-reorg.c @@ -76,7 +76,7 @@ static void reorg_forbidden ( gimple *, Info *); //static ReorgTransformation reorg_recognize ( gimple *, Info *); //static bool is_reorg_type ( tree, Info *); //static tree base_type_of ( tree); -static bool is_user_function ( gimple *, Info *); +static bool is_user_function ( gimple *, cgraph_node *, Info *); static bool is_reorg_alloc_trigger ( gimple *); static ReorgType_t *find_struct_type_ptr_to_struct ( tree, Info *); //static ReorgType_t *get_reorgtype_info ( tree, Info *); @@ -917,7 +917,7 @@ transformation_legality ( Info *info) int num = num_reorgtypes ( stmt, info); if ( num != 0 ) { - if ( reorg_recognize( stmt, info) == Not_Supported ) + if ( reorg_recognize( stmt, node, info) == Not_Supported ) { int i; for ( i = 0; i < num; i++ ) @@ -1034,7 +1034,7 @@ undelete_reorgtype ( ReorgType_t *rt, Info *info ) } ReorgTransformation -reorg_recognize ( gimple *stmt, Info *info ) +reorg_recognize ( gimple *stmt, cgraph_node* node, Info_t *info ) { DEBUG_L ( "ReorgTransformation reorg_recognize for: "); DEBUG_F ( print_gimple_stmt, stderr, stmt, 0); @@ -1115,6 +1115,7 @@ reorg_recognize ( gimple *stmt, Info *info ) INDENT(-4); switch ( recognize_op( rhs, info) ) { + case ReorgOpT_Scalar: // "z" case ReorgOpT_Temp: // "t" case ReorgOpT_Indirect: // "a->f" case ReorgOpT_AryDir: // "x[i].f" @@ -1190,13 +1191,15 @@ reorg_recognize ( gimple *stmt, Info *info ) { DEBUG_L("GIMPLE_COND:\n"); INDENT(-2); - tree op1 = gimple_assign_rhs1 ( stmt); - tree op2 = gimple_assign_rhs2( stmt); + //tree op1 = gimple_assign_rhs1 ( stmt); + //tree op2 = gimple_assign_rhs2( stmt); + tree op1 = gimple_cond_lhs ( stmt); + tree op2 = gimple_cond_rhs ( stmt); enum tree_code cond_code = gimple_cond_code (stmt); - // TBD The parenthesis where a disaster here in the HL Design so + // TBD The parenthesis were a disaster here in the HL Design so // double check this! bool zero_case = - ( POINTER_TYPE_P ( TREE_TYPE ( op1)) && integer_zerop ( op2)) + ( POINTER_TYPE_P ( TREE_TYPE ( op1)) && integer_zerop ( op2)) || ( POINTER_TYPE_P ( TREE_TYPE ( op2)) && integer_zerop ( op1)); switch ( cond_code ) { @@ -1219,6 +1222,10 @@ reorg_recognize ( gimple *stmt, Info *info ) case GIMPLE_CALL: { DEBUG_L("GIMPLE_CALL:\n"); + struct cgraph_edge *edge = node->get_edge ( stmt); + gcc_assert( edge); + DEBUG_L("called function %s gimple_body\n", + edge->callee->has_gimple_body_p() ? "has a" : "has no"); INDENT(-2); if ( gimple_call_builtin_p( stmt, BUILT_IN_CALLOC ) ) return ReorgT_Calloc; if ( gimple_call_builtin_p( stmt, BUILT_IN_MALLOC ) ) return ReorgT_Malloc; @@ -1230,7 +1237,7 @@ reorg_recognize ( gimple *stmt, Info *info ) // transformation is meaningless but the type still needs to be // adjusted (does transform really do this?) - if ( is_user_function ( stmt, info) ) + if ( is_user_function ( stmt, node, info) ) { return ReorgT_UserFunc; } @@ -1253,35 +1260,15 @@ reorg_recognize ( gimple *stmt, Info *info ) } static bool -is_user_function ( gimple *call_stmt, Info *info) +is_user_function ( gimple *call_stmt, cgraph_node* node, Info *info) { - tree fndecl = gimple_call_fndecl ( call_stmt); - - DEBUG_L("is_user_function: decl in: %p,", fndecl); - DEBUG_F( print_generic_decl, stderr, fndecl, (dump_flags_t)-1); - DEBUG("\n"); - INDENT(2); - - gcc_assert ( fndecl); - - cgraph_node* node; - bool ret_val = false; - FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) - { - DEBUG_L("decl %p,", node->decl); - DEBUG_F( print_generic_decl, stderr, node->decl, (dump_flags_t)-1); - DEBUG("\n"); - - if ( node->decl == fndecl ) - { - ret_val = true; - break; - } - } - - INDENT(-2); - return true; // <==== Evil work around!!!!!! - return ret_val; + // I'm not 100% sure this is a great idea but it means that + // if we know nothing about the contents of a function + // then it shouldn't be considered a user written function + // that is part of our program. + struct cgraph_edge *ce; + ce = node->get_edge ( call_stmt); + return ce->callee->has_gimple_body_p(); } void |