From: Richard Guenther Date: Mon, 18 Jan 2010 12:59:50 +0000 (+0000) Subject: re PR middle-end/39954 (Revision 146817 caused unaligned access in gcc.dg/torture... X-Git-Tag: releases/gcc-4.5.0~1164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e23817b3baa23024360b795044220db46d612809;p=thirdparty%2Fgcc.git re PR middle-end/39954 (Revision 146817 caused unaligned access in gcc.dg/torture/pr26565.c) 2010-01-18 Richard Guenther PR middle-end/39954 * cfgexpand.c (expand_call_stmt): TER pointer arguments in builtin calls. From-SVN: r156008 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2ad9c06d356a..795b89c29f12 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-01-18 Richard Guenther + + PR middle-end/39954 + * cfgexpand.c (expand_call_stmt): TER pointer arguments in + builtin calls. + 2010-01-18 Richard Guenther PR tree-optimization/42781 diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 70d2b355aa1d..788242c3d82f 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -1746,15 +1746,31 @@ expand_call_stmt (gimple stmt) 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++) - CALL_EXPR_ARG (exp, i) = gimple_call_arg (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;