On 2020-11-13 09:41, Richard Biener wrote:
> On Thu, Mar 12, 2020 at 1:41 AM J.W. Jagersma via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>> diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
>> index 2a409dcaffe..58b16aa763a 100644
>> --- a/gcc/tree-eh.c
>> +++ b/gcc/tree-eh.c
>> @@ -2077,6 +2077,8 @@ lower_eh_constructs_2 (struct leh_state *state, 
>> gimple_stmt_iterator *gsi)
>>             DECL_GIMPLE_REG_P (tmp) = 1;
>>           gsi_insert_after (gsi, s, GSI_SAME_STMT);
>>         }
>> +
>> +record_throwing_stmt:
>>        /* Look for things that can throw exceptions, and record them.  */
>>        if (state->cur_region && stmt_could_throw_p (cfun, stmt))
>>         {
>> @@ -2085,6 +2087,36 @@ lower_eh_constructs_2 (struct leh_state *state, 
>> gimple_stmt_iterator *gsi)
>>         }
>>        break;
>>
>> +    case GIMPLE_ASM:
>> +      {
>> +       /* As above with GIMPLE_ASSIGN.  Change each register output operand
>> +          to a temporary and insert a new stmt to assign this to the 
>> original
>> +          operand.  */
>> +       gasm *asm_stmt = as_a <gasm *> (stmt);
>> +       if (stmt_could_throw_p (cfun, stmt)
>> +           && gimple_asm_noutputs (asm_stmt) > 0
>> +           && gimple_stmt_may_fallthru (stmt))
>> +         {
>> +           for (unsigned i = 0; i < gimple_asm_noutputs (asm_stmt); ++i)
>> +             {
>> +               tree op = gimple_asm_output_op (asm_stmt, i);
>> +               tree opval = TREE_VALUE (op);
>> +               if (tree_could_throw_p (opval)
>> +                   || !is_gimple_reg_type (TREE_TYPE (opval))
>> +                   || !is_gimple_reg (get_base_address (opval)))
>> +                 continue;
>> +
>> +               tree tmp = create_tmp_reg (TREE_TYPE (opval));
>> +               gimple *s = gimple_build_assign (opval, tmp);
>> +               gimple_set_location (s, gimple_location (stmt));
>> +               gimple_set_block (s, gimple_block (stmt));
>> +               TREE_VALUE (op) = tmp;
>> +               gsi_insert_after (gsi, s, GSI_SAME_STMT);
>> +             }
>> +         }
>> +      }
>> +      goto record_throwing_stmt;
> 
> Can you avoid the ugly goto by simply duplicating the common code please?
> 
> Otherwise OK.
> 
> As you say volatile asms are already considered throwing in some pieces of
> code so this is a step towards fulfilling that promise.
> 
> Thanks,
> Richard.
> 

Hi Richard,

Thanks for your feedback.  I'll have to check again if I made any other
changes since this.  If not, and if there are no further objections, I will
resubmit this patch soon with this goto removed.

Reply via email to