diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 613a7b28942..570dbe5d8e3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2000-11-14 Jakub Jelinek + + * builtins.c (expand_builtin_setjmp): Set + current_function_calls_setjmp. + (expand_builtin_longjmp): Set current_function_calls_longjmp. + + * config/sparc/sparc.md (builtin_setjmp_setup): New expand. + (do_builtin_setjmp_setup): New insn. + Tue Nov 14 12:34:56 2000 Richard Kenner * tree.c (get_unwidened): Use host_integerp and tree_low_cst. diff --git a/gcc/builtins.c b/gcc/builtins.c index 68677b52950..8daf963a6b2 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -446,6 +446,7 @@ expand_builtin_setjmp (buf_addr, target, first_label, next_label) calls may traverse the arc back to this label. */ current_function_has_nonlocal_label = 1; + current_function_calls_setjmp = 1; nonlocal_goto_handler_labels = gen_rtx_EXPR_LIST (VOIDmode, lab1, nonlocal_goto_handler_labels); @@ -547,6 +548,8 @@ expand_builtin_longjmp (buf_addr, value) if (value != const1_rtx) abort (); + current_function_calls_longjmp = 1; + #ifdef HAVE_builtin_longjmp if (HAVE_builtin_longjmp) emit_insn (gen_builtin_longjmp (buf_addr)); diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index 93734f9d386..861a9f32faf 100644 --- a/gcc/config/sparc/sparc.md +++ b/gcc/config/sparc/sparc.md @@ -50,6 +50,7 @@ ;; 2 goto_handler_and_restore ;; 3 goto_handler_and_restore_v9* ;; 4 flush +;; 5 do_builtin_setjmp_setup ;; ;; The upper 32 fp regs on the v9 can't hold SFmode values. To deal with this @@ -9014,6 +9015,32 @@ ;; [(set_attr "type" "misc") ;; (set_attr "length" "2,3")]) +;; For __builtin_setjmp we need to flush register windows iff the function +;; calls alloca as well, because otherwise the register window might be +;; saved after %sp adjustement and thus setjmp would crash +(define_expand "builtin_setjmp_setup" + [(match_operand 0 "register_operand" "r")] + "" + " +{ + emit_insn (gen_do_builtin_setjmp_setup ()); + DONE; +}") + +(define_insn "do_builtin_setjmp_setup" + [(unspec_volatile [(const_int 0)] 5)] + "" + "* +{ + if (!current_function_calls_alloca) + return \"\"; + if (TARGET_V9) + return \"flushw\"; + return \"ta\\t3\"; +}" + [(set_attr "type" "misc") + (set_attr "length" "1")]) + ;; Pattern for use after a setjmp to store FP and the return register ;; into the stack area.