This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR39954
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Jan 2010 13:56:56 +0100 (CET)
- Subject: [PATCH] Fix PR39954
This fixes PR39954, due to missing TER we regress compared to 4.4
and generate misaligned accesses which is bad on strict-align targets.
The following fix restores 4.4 behavior and fixes the particular
regression (by visual inspection of assembler).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2010-01-18 Richard Guenther <rguenther@suse.de>
PR middle-end/39954
* cfgexpand.c (expand_call_stmt): TER pointer arguments in
builtin calls.
Index: gcc/cfgexpand.c
===================================================================
*** gcc/cfgexpand.c (revision 156006)
--- gcc/cfgexpand.c (working copy)
*************** expand_call_stmt (gimple stmt)
*** 1746,1760 ****
tree exp;
tree lhs = gimple_call_lhs (stmt);
size_t i;
exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
TREE_TYPE (exp) = gimple_call_return_type (stmt);
CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
for (i = 0; i < gimple_call_num_args (stmt); i++)
! CALL_EXPR_ARG (exp, i) = gimple_call_arg (stmt, i);
if (gimple_has_side_effects (stmt))
TREE_SIDE_EFFECTS (exp) = 1;
--- 1746,1776 ----
tree exp;
tree lhs = gimple_call_lhs (stmt);
size_t i;
+ bool builtin_p;
+ tree decl;
exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
+ decl = gimple_call_fndecl (stmt);
+ builtin_p = decl && DECL_BUILT_IN (decl);
+
TREE_TYPE (exp) = gimple_call_return_type (stmt);
CALL_EXPR_STATIC_CHAIN (exp) = gimple_call_chain (stmt);
for (i = 0; i < gimple_call_num_args (stmt); i++)
! {
! tree arg = gimple_call_arg (stmt, i);
! gimple def;
! /* TER addresses into arguments of builtin functions so we have a
! chance to infer more correct alignment information. See PR39954. */
! if (builtin_p
! && TREE_CODE (arg) == SSA_NAME
! && (def = get_gimple_for_ssa_name (arg))
! && gimple_assign_rhs_code (def) == ADDR_EXPR)
! arg = gimple_assign_rhs1 (def);
! CALL_EXPR_ARG (exp, i) = arg;
! }
if (gimple_has_side_effects (stmt))
TREE_SIDE_EFFECTS (exp) = 1;