Re: [PATCH] Partial Transition fix attempt
On Wed, Mar 21, 2012 at 6:44 PM, redbrain wrote: > in tree-mudflap.c to change usage of fold_conver to build_int_cst > http://gcc.gnu.org/wiki/Partial_Transitions. I am not 100% sure this is > correct but maybe someone can shed some light. Doesn't look ok - how do you know you even have constants here? Remember that fold_convert handles non-constants just fine. Richard. > --- > gcc/tree-mudflap.c | 38 -- > 1 files changed, 20 insertions(+), 18 deletions(-) > > diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c > index e4f6ec0..684b7b4 100644 > --- a/gcc/tree-mudflap.c > +++ b/gcc/tree-mudflap.c > @@ -567,8 +567,7 @@ mf_build_check_statement_for (tree base, tree limit, > > /* Build: __mf_base = (uintptr_t) . */ > seq = gimple_seq_alloc (); > - t = fold_convert_loc (location, mf_uintptr_type, > - unshare_expr (base)); > + t = build_int_cst_type (mf_uintptr_type, TREE_INT_CST_LOW (unshare_expr > (base))); > t = force_gimple_operand (t, &stmts, false, NULL_TREE); > gimple_seq_add_seq (&seq, stmts); > g = gimple_build_assign (mf_base, t); > @@ -576,8 +575,7 @@ mf_build_check_statement_for (tree base, tree limit, > gimple_seq_add_stmt (&seq, g); > > /* Build: __mf_limit = (uintptr_t) . */ > - t = fold_convert_loc (location, mf_uintptr_type, > - unshare_expr (limit)); > + t = build_int_cst_type (mf_uintptr_type, TREE_INT_CST_LOW (unshare_expr > (limit))); > t = force_gimple_operand (t, &stmts, false, NULL_TREE); > gimple_seq_add_seq (&seq, stmts); > g = gimple_build_assign (mf_limit, t); > @@ -853,18 +851,21 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, > if (elt) > elt = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (elt)), > elt); > - addr = fold_convert_loc (location, ptr_type_node, elt ? elt : > base); > + addr = build_int_cst_type (ptr_type_node, elt ? TREE_INT_CST_LOW > (elt) : > + TREE_INT_CST_LOW (base)); > addr = fold_build_pointer_plus_loc (location, > addr, byte_position (field)); > } > else > addr = build1 (ADDR_EXPR, build_pointer_type (type), t); > - > + > limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type, > - fold_build2_loc (location, PLUS_EXPR, > mf_uintptr_type, > - fold_convert (mf_uintptr_type, > addr), > - size), > - integer_one_node); > + fold_build2_loc (location, PLUS_EXPR, > mf_uintptr_type, > + build_int_cst_type > (mf_uintptr_type, > + > TREE_INT_CST_LOW (addr)), > + > + size), > + integer_one_node); > } > break; > > @@ -908,17 +909,17 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, > return; > > bpu = bitsize_int (BITS_PER_UNIT); > - ofs = fold_convert (bitsizetype, TREE_OPERAND (t, 2)); > + ofs = build_int_cst_type (bitsizetype, TREE_INT_CST_LOW (TREE_OPERAND > (t, 2))); > rem = size_binop_loc (location, TRUNC_MOD_EXPR, ofs, bpu); > ofs = size_binop_loc (location, TRUNC_DIV_EXPR, ofs, bpu); > > - size = fold_convert (bitsizetype, TREE_OPERAND (t, 1)); > + size = build_int_cst_type (bitsizetype, TREE_INT_CST_LOW > (TREE_OPERAND (t, 1))); > size = size_binop_loc (location, PLUS_EXPR, size, rem); > size = size_binop_loc (location, CEIL_DIV_EXPR, size, bpu); > - size = fold_convert (sizetype, size); > + size = build_int_cst_type (sizetype, TREE_INT_CST_LOW (size)); > > addr = TREE_OPERAND (TREE_OPERAND (t, 0), 0); > - addr = fold_convert (ptr_type_node, addr); > + addr = build_int_cst_type (ptr_type_node, TREE_INT_CST_LOW (addr)); > addr = fold_build_pointer_plus_loc (location, addr, ofs); > > base = addr; > @@ -1048,8 +1049,8 @@ mx_register_decls (tree decl, gimple_seq seq, > location_t location) > > /* Variable-sized objects should have sizes already been > gimplified when we got here. */ > - size = fold_convert (size_type_node, > - TYPE_SIZE_UNIT (TREE_TYPE (decl))); > + size = build_int_cst_type (size_type_node, > + TREE_INT_CST_LOW (TYPE_SIZE_UNIT > (TREE_TYPE (decl; > gcc_assert (is_gimple_val (size)); > > > @@ -1233,11 +1234,12 @@ mudflap_register_call (tree obj, tree object_size, > tree varname) > tree arg, call_stmt; > > arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (obj)), obj); > - arg =
[PATCH] Partial Transition fix attempt
in tree-mudflap.c to change usage of fold_conver to build_int_cst http://gcc.gnu.org/wiki/Partial_Transitions. I am not 100% sure this is correct but maybe someone can shed some light. --- gcc/tree-mudflap.c | 38 -- 1 files changed, 20 insertions(+), 18 deletions(-) diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c index e4f6ec0..684b7b4 100644 --- a/gcc/tree-mudflap.c +++ b/gcc/tree-mudflap.c @@ -567,8 +567,7 @@ mf_build_check_statement_for (tree base, tree limit, /* Build: __mf_base = (uintptr_t) . */ seq = gimple_seq_alloc (); - t = fold_convert_loc (location, mf_uintptr_type, - unshare_expr (base)); + t = build_int_cst_type (mf_uintptr_type, TREE_INT_CST_LOW (unshare_expr (base))); t = force_gimple_operand (t, &stmts, false, NULL_TREE); gimple_seq_add_seq (&seq, stmts); g = gimple_build_assign (mf_base, t); @@ -576,8 +575,7 @@ mf_build_check_statement_for (tree base, tree limit, gimple_seq_add_stmt (&seq, g); /* Build: __mf_limit = (uintptr_t) . */ - t = fold_convert_loc (location, mf_uintptr_type, - unshare_expr (limit)); + t = build_int_cst_type (mf_uintptr_type, TREE_INT_CST_LOW (unshare_expr (limit))); t = force_gimple_operand (t, &stmts, false, NULL_TREE); gimple_seq_add_seq (&seq, stmts); g = gimple_build_assign (mf_limit, t); @@ -853,18 +851,21 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, if (elt) elt = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (elt)), elt); -addr = fold_convert_loc (location, ptr_type_node, elt ? elt : base); + addr = build_int_cst_type (ptr_type_node, elt ? TREE_INT_CST_LOW (elt) : + TREE_INT_CST_LOW (base)); addr = fold_build_pointer_plus_loc (location, addr, byte_position (field)); } else addr = build1 (ADDR_EXPR, build_pointer_type (type), t); - + limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type, - fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type, - fold_convert (mf_uintptr_type, addr), - size), - integer_one_node); +fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type, + build_int_cst_type (mf_uintptr_type, + TREE_INT_CST_LOW (addr)), + + size), +integer_one_node); } break; @@ -908,17 +909,17 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, return; bpu = bitsize_int (BITS_PER_UNIT); -ofs = fold_convert (bitsizetype, TREE_OPERAND (t, 2)); + ofs = build_int_cst_type (bitsizetype, TREE_INT_CST_LOW (TREE_OPERAND (t, 2))); rem = size_binop_loc (location, TRUNC_MOD_EXPR, ofs, bpu); ofs = size_binop_loc (location, TRUNC_DIV_EXPR, ofs, bpu); -size = fold_convert (bitsizetype, TREE_OPERAND (t, 1)); +size = build_int_cst_type (bitsizetype, TREE_INT_CST_LOW (TREE_OPERAND (t, 1))); size = size_binop_loc (location, PLUS_EXPR, size, rem); size = size_binop_loc (location, CEIL_DIV_EXPR, size, bpu); -size = fold_convert (sizetype, size); +size = build_int_cst_type (sizetype, TREE_INT_CST_LOW (size)); addr = TREE_OPERAND (TREE_OPERAND (t, 0), 0); -addr = fold_convert (ptr_type_node, addr); +addr = build_int_cst_type (ptr_type_node, TREE_INT_CST_LOW (addr)); addr = fold_build_pointer_plus_loc (location, addr, ofs); base = addr; @@ -1048,8 +1049,8 @@ mx_register_decls (tree decl, gimple_seq seq, location_t location) /* Variable-sized objects should have sizes already been gimplified when we got here. */ - size = fold_convert (size_type_node, - TYPE_SIZE_UNIT (TREE_TYPE (decl))); + size = build_int_cst_type (size_type_node, +TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (decl; gcc_assert (is_gimple_val (size)); @@ -1233,11 +1234,12 @@ mudflap_register_call (tree obj, tree object_size, tree varname) tree arg, call_stmt; arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (obj)), obj); - arg = fold_convert (ptr_type_node, arg); + arg = build_int_cst_type (ptr_type_node, TREE_INT_CST_LOW (arg)); call_stmt = build_call_expr (mf_register_fndecl, 4, arg, - fold_convert (size_type_node, object_size), +