Commit 251901a0 by Jakub Jelinek Committed by Jakub Jelinek

re PR target/60062 (wrong code (for code with the optimize attribute) at -O1 and…

re PR target/60062 (wrong code (for code with the optimize attribute) at -O1 and above on x86_64-linux-gnu in 32-bit mode)

	PR target/60062
	* tree.h (opts_for_fn): New inline function.
	(opt_for_fn): Define.
	* config/i386/i386.c (ix86_function_regparm): Use
	opt_for_fn (decl, optimize) instead of optimize.

	* gcc.c-torture/execute/pr60062.c: New test.
	* gcc.c-torture/execute/pr60072.c: New test.

From-SVN: r207549
parent 79b49b87
2014-02-06 Jakub Jelinek <jakub@redhat.com>
PR target/60062
* tree.h (opts_for_fn): New inline function.
(opt_for_fn): Define.
* config/i386/i386.c (ix86_function_regparm): Use
opt_for_fn (decl, optimize) instead of optimize.
2014-02-06 Marcus Shawcroft <marcus.shawcroft@arm.com>
* config/aarch64/aarch64.c (aarch64_classify_symbol): Fix logic
......
......@@ -5608,7 +5608,12 @@ ix86_function_regparm (const_tree type, const_tree decl)
/* Use register calling convention for local functions when possible. */
if (decl
&& TREE_CODE (decl) == FUNCTION_DECL
&& optimize
/* Caller and callee must agree on the calling convention, so
checking here just optimize means that with
__attribute__((optimize (...))) caller could use regparm convention
and callee not, or vice versa. Instead look at whether the callee
is optimized or not. */
&& opt_for_fn (decl, optimize)
&& !(profile_flag && !flag_fentry))
{
/* FIXME: remove this CONST_CAST when cgraph.[ch] is constified. */
2014-02-06 Jakub Jelinek <jakub@redhat.com>
PR target/60062
* gcc.c-torture/execute/pr60062.c: New test.
* gcc.c-torture/execute/pr60072.c: New test.
2014-02-06 Ian Bolton <ian.bolton@arm.com>
* gcc.dg/tree-ssa/pr59597.c: Make called function static
......
/* PR target/60062 */
int a;
static void
foo (const char *p1, int p2)
{
if (__builtin_strcmp (p1, "hello") != 0)
__builtin_abort ();
}
static void
bar (const char *p1)
{
if (__builtin_strcmp (p1, "hello") != 0)
__builtin_abort ();
}
__attribute__((optimize (0))) int
main ()
{
foo ("hello", a);
bar ("hello");
return 0;
}
/* PR target/60072 */
int c = 1;
__attribute__ ((optimize (1)))
static int *foo (int *p)
{
return p;
}
int
main ()
{
*foo (&c) = 2;
return c - 2;
}
......@@ -4470,6 +4470,20 @@ may_be_aliased (const_tree var)
|| TREE_ADDRESSABLE (var)));
}
/* Return pointer to optimization flags of FNDECL. */
static inline struct cl_optimization *
opts_for_fn (const_tree fndecl)
{
tree fn_opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
if (fn_opts == NULL_TREE)
fn_opts = optimization_default_node;
return TREE_OPTIMIZATION (fn_opts);
}
/* opt flag for function FNDECL, e.g. opts_for_fn (fndecl, optimize) is
the optimization level of function fndecl. */
#define opt_for_fn(fndecl, opt) (opts_for_fn (fndecl)->x_##opt)
/* For anonymous aggregate types, we need some sort of name to
hold on to. In practice, this should not appear, but it should
not be harmful if it does. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment