+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
/* 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
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* PR target/60072 */
+
+int c = 1;
+
+__attribute__ ((optimize (1)))
+static int *foo (int *p)
+{
+ return p;
+}
+
+int
+main ()
+{
+ *foo (&c) = 2;
+ return c - 2;
+}
|| 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. */