Index: ChangeLog.tm-merge =================================================================== --- ChangeLog.tm-merge (revision 181067) +++ ChangeLog.tm-merge (working copy) @@ -58,8 +58,10 @@ * calls.c (is_tm_builtin): New. (flags_from_decl_or_type): Add ECF_TM_OPS for TM clones. * cfgbuild.c (make_edges): Add edges for REG_TM notes. - * cfgexpand.c (expand_gimple_stmt): Add REG_TM notes. + * cfgexpand.c (expand_call_stmt): Call + mark_transaction_restart_calls. (gimple_expand_cfg): Free the tm_restart map. + (mark_transaction_restart_calls): New. * cfgrtl.c (purge_dead_edges): Look for REG_TM notes. * cgraph.c (dump_cgraph_node): Handle tm_clone. * cgraph.h (struct cgraph_node): Add tm_clone field. Index: cfgexpand.c =================================================================== --- cfgexpand.c (revision 181067) +++ cfgexpand.c (working copy) @@ -1802,6 +1802,38 @@ expand_gimple_cond (basic_block bb, gimp return new_bb; } +/* Mark all calls that can have a transaction restart. */ + +static void +mark_transaction_restart_calls (gimple stmt) +{ + struct tm_restart_node dummy; + void **slot; + + if (!cfun->gimple_df->tm_restart) + return; + + dummy.stmt = stmt; + slot = htab_find_slot (cfun->gimple_df->tm_restart, &dummy, NO_INSERT); + if (slot) + { + struct tm_restart_node *n = (struct tm_restart_node *) *slot; + tree list = n->label_or_list; + rtx insn; + + for (insn = next_real_insn (get_last_insn ()); + !CALL_P (insn); + insn = next_real_insn (insn)) + continue; + + if (TREE_CODE (list) == LABEL_DECL) + add_reg_note (insn, REG_TM, label_rtx (list)); + else + for (; list ; list = TREE_CHAIN (list)) + add_reg_note (insn, REG_TM, label_rtx (TREE_VALUE (list))); + } +} + /* A subroutine of expand_gimple_stmt_1, expanding one GIMPLE_CALL statement STMT. */ @@ -1812,6 +1844,8 @@ expand_call_stmt (gimple stmt) bool builtin_p; size_t i; + mark_transaction_restart_calls (stmt); + if (gimple_call_internal_p (stmt)) { expand_internal_call (stmt); @@ -2096,32 +2130,6 @@ expand_gimple_stmt (gimple stmt) } } - /* Mark all calls that can have a transaction restart. */ - if (cfun->gimple_df->tm_restart && is_gimple_call (stmt)) - { - struct tm_restart_node dummy; - void **slot; - - dummy.stmt = stmt; - slot = htab_find_slot (cfun->gimple_df->tm_restart, &dummy, NO_INSERT); - if (slot) - { - struct tm_restart_node *n = (struct tm_restart_node *) *slot; - tree list = n->label_or_list; - rtx insn; - - for (insn = next_real_insn (last); !CALL_P (insn); - insn = next_real_insn (insn)) - continue; - - if (TREE_CODE (list) == LABEL_DECL) - add_reg_note (insn, REG_TM, label_rtx (list)); - else - for (; list ; list = TREE_CHAIN (list)) - add_reg_note (insn, REG_TM, label_rtx (TREE_VALUE (list))); - } - } - return last; }