# HG changeset patch # User anatofuz # Date 1520590694 -32400 # Node ID 49957f95a4d1bc6968e208a662ccd8095bded37e # Parent f93fa509107065661fa31e0b033c23ca1a3674fe fix fntype diff -r f93fa5091070 -r 49957f95a4d1 gcc/calls.c --- a/gcc/calls.c Thu Mar 08 14:53:42 2018 +0900 +++ b/gcc/calls.c Fri Mar 09 19:18:14 2018 +0900 @@ -3301,7 +3301,7 @@ // -O2オプションがないときも末尾最適化が行われるように(Code Segmentのみ) if (currently_expanding_call++ != 0 #ifndef noCbC - || ((!fndecl || !CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl))) && !flag_optimize_sibling_calls) + || ((!fntype|| !CbC_IS_CODE_SEGMENT (fntype)) && !flag_optimize_sibling_calls) #else || !flag_optimize_sibling_calls #endif @@ -3326,7 +3326,7 @@ /* Check if caller and callee disagree in promotion of function return value. */ #ifndef noCbC - if (try_tail_call && (!fndecl || !CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)))) + if (try_tail_call && (!fntype|| !CbC_IS_CODE_SEGMENT (fntype))) #else if (try_tail_call) #endif @@ -3421,18 +3421,6 @@ // when tail call optimization flag was down, warn about them. // and flag it to force a tail call optimize. -#ifndef noCbC - if (fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) - && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl)) - && try_tail_call == 0) - { - location_t loc = EXPR_LOCATION (exp); - const char *name_callee = IDENTIFIER_POINTER(DECL_NAME(fndecl)); - warning_at (loc, 0, "transition to code segment \"%s\" with CbC goto, but tail call optimization was cut.", - name_callee); - try_tail_call = 1; - } -#endif /* We want to make two insn chains; one for a sibling call, the other for a normal call. We will select one of the two chains after @@ -4311,9 +4299,13 @@ /* If something prevents making this a sibling call, zero out the sequence. */ - if (sibcall_failure) +#ifndef noCbC + if ((!fntype || !CbC_IS_CODE_SEGMENT (fntype)) && sibcall_failure) +#else + if (sibcall_failure) +#endif tail_call_insns = NULL; - else + else break; } @@ -4326,6 +4318,17 @@ } else { + +#ifndef noCbC + if (fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) + && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl))) + { + location_t loc = EXPR_LOCATION (exp); + const char *name_callee = IDENTIFIER_POINTER(DECL_NAME(fndecl)); + warning_at (loc, 0, "transition to code segment \"%s\" with CbC goto, but tail call optimization was cut.", + name_callee); + } +#endif emit_insn (normal_call_insns); if (try_tail_call) /* Ideally we'd emit a message for all of the ways that it could