Commit 84f5e1b1 by Richard Henderson Committed by Richard Henderson

re PR rtl-optimization/4382 (__builtin_{set,long}jmp with -O3 can crash the compiler)

        PR optimization/4382
        * tree-inline.c (find_builtin_longjmp_call_1): New.
        (find_builtin_longjmp_call): New.
        (inlinable_function_p): Use it.

From-SVN: r61732
parent 09b2e78d
2003-01-24 Richard Henderson <rth@redhat.com>
PR optimization/4382
* tree-inline.c (find_builtin_longjmp_call_1): New.
(find_builtin_longjmp_call): New.
(inlinable_function_p): Use it.
2003-01-24 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> 2003-01-24 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* config/i386/i386-protos.h (function_arg_pass_by_reference): Declare. * config/i386/i386-protos.h (function_arg_pass_by_reference): Declare.
......
...@@ -125,6 +125,8 @@ static tree add_stmt_to_compound PARAMS ((tree, tree, tree)); ...@@ -125,6 +125,8 @@ static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
#endif /* INLINER_FOR_JAVA */ #endif /* INLINER_FOR_JAVA */
static tree find_alloca_call_1 PARAMS ((tree *, int *, void *)); static tree find_alloca_call_1 PARAMS ((tree *, int *, void *));
static tree find_alloca_call PARAMS ((tree)); static tree find_alloca_call PARAMS ((tree));
static tree find_builtin_longjmp_call_1 PARAMS ((tree *, int *, void *));
static tree find_builtin_longjmp_call PARAMS ((tree));
/* The approximate number of instructions per statement. This number /* The approximate number of instructions per statement. This number
need not be particularly accurate; it is used only to make need not be particularly accurate; it is used only to make
...@@ -873,7 +875,7 @@ tree_inlinable_function_p (fn) ...@@ -873,7 +875,7 @@ tree_inlinable_function_p (fn)
return inlinable_function_p (fn, NULL); return inlinable_function_p (fn, NULL);
} }
/* if *TP is possibly call to alloca, return nonzero. */ /* If *TP is possibly call to alloca, return nonzero. */
static tree static tree
find_alloca_call_1 (tp, walk_subtrees, data) find_alloca_call_1 (tp, walk_subtrees, data)
tree *tp; tree *tp;
...@@ -885,8 +887,7 @@ find_alloca_call_1 (tp, walk_subtrees, data) ...@@ -885,8 +887,7 @@ find_alloca_call_1 (tp, walk_subtrees, data)
return NULL; return NULL;
} }
/* Return subexpression representing possible alloca call, /* Return subexpression representing possible alloca call, if any. */
if any. */
static tree static tree
find_alloca_call (exp) find_alloca_call (exp)
tree exp; tree exp;
...@@ -894,6 +895,32 @@ find_alloca_call (exp) ...@@ -894,6 +895,32 @@ find_alloca_call (exp)
return walk_tree (&exp, find_alloca_call_1, NULL, NULL); return walk_tree (&exp, find_alloca_call_1, NULL, NULL);
} }
static tree
find_builtin_longjmp_call_1 (tp, walk_subtrees, data)
tree *tp;
int *walk_subtrees ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
{
tree exp = *tp, decl;
if (TREE_CODE (exp) == CALL_EXPR
&& TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
&& (decl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
TREE_CODE (decl) == FUNCTION_DECL)
&& DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
&& DECL_FUNCTION_CODE (decl) == BUILT_IN_LONGJMP)
return decl;
return NULL;
}
static tree
find_builtin_longjmp_call (exp)
tree exp;
{
return walk_tree (&exp, find_builtin_longjmp_call_1, NULL, NULL);
}
/* Returns nonzero if FN is a function that can be inlined into the /* Returns nonzero if FN is a function that can be inlined into the
inlining context ID_. If ID_ is NULL, check whether the function inlining context ID_. If ID_ is NULL, check whether the function
can be inlined at all. */ can be inlined at all. */
...@@ -934,6 +961,14 @@ inlinable_function_p (fn, id) ...@@ -934,6 +961,14 @@ inlinable_function_p (fn, id)
else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn) else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
&& currfn_insns > MAX_INLINE_INSNS_SINGLE) && currfn_insns > MAX_INLINE_INSNS_SINGLE)
; ;
/* We can't inline functions that call __builtin_longjmp at all.
The non-local goto machenery really requires the destination
be in a different function. If we allow the function calling
__builtin_longjmp to be inlined into the function calling
__builtin_setjmp, Things will Go Awry. */
/* ??? Need front end help to identify "regular" non-local goto. */
else if (find_builtin_longjmp_call (DECL_SAVED_TREE (fn)))
;
/* Refuse to inline alloca call unless user explicitly forced so as this may /* Refuse to inline alloca call unless user explicitly forced so as this may
change program's memory overhead drastically when the function using alloca change program's memory overhead drastically when the function using alloca
is called in loop. In GCC present in SPEC2000 inlining into schedule_block is called in loop. In GCC present in SPEC2000 inlining into schedule_block
......
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