+2018-01-08 Monk Chiang <sh.chiang04@gmail.com>
+ Kito Cheng <kito.cheng@gmail.com>
+
+ * config/riscv/riscv.c (machine_function::is_leaf): Remove field.
+ (riscv_leaf_function_p): Delete.
+ (riscv_function_ok_for_sibcall): Return false when TARGET_SAVE_RESTORE.
+
2018-01-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/83677
This area is allocated by the callee at the very top of the frame. */
int varargs_size;
- /* Memoized return value of leaf_function_p. <0 if false, >0 if true. */
- int is_leaf;
-
/* The current frame information, calculated by riscv_compute_frame_info. */
struct riscv_frame_info frame;
};
emit_insn (gen_clear_cache (addr, end_addr));
}
-/* Return leaf_function_p () and memoize the result. */
-
-static bool
-riscv_leaf_function_p (void)
-{
- if (cfun->machine->is_leaf == 0)
- cfun->machine->is_leaf = leaf_function_p () ? 1 : -1;
-
- return cfun->machine->is_leaf > 0;
-}
-
/* Implement TARGET_FUNCTION_OK_FOR_SIBCALL. */
static bool
riscv_function_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED,
tree exp ATTRIBUTE_UNUSED)
{
- /* When optimzing for size, don't use sibcalls in non-leaf routines */
+ /* Don't use sibcalls when use save-restore routine. */
if (TARGET_SAVE_RESTORE)
- return riscv_leaf_function_p ();
+ return false;
return true;
}
+2018-01-08 Chih-Mao Chen <pkmx.tw@gmail.com>
+ Monk Chiang <sh.chiang04@gmail.com>
+
+ * gcc.target/riscv/save-restore-1.c: New.
+
2018-01-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/83677
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -msave-restore -fomit-frame-pointer" } */
+
+#include <stdlib.h>
+
+__attribute__((noinline)) int g(void) { return 42; }
+
+__attribute__((noinline)) int f(void) {
+ asm volatile ("li s0, 0x87654321" ::: "s0");
+ return g();
+}
+
+int main(void) {
+ asm volatile ("li s0, 0x12345678" ::: "s0");
+
+ f();
+
+ long s0;
+ asm volatile ("mv %0, s0" : "=r"(s0));
+
+ if (s0 == 0x12345678)
+ exit (0);
+ else
+ abort();
+}