diff options
author | meissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-23 10:28:06 +0000 |
---|---|---|
committer | meissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-23 10:28:06 +0000 |
commit | 46f8e3b0dc1cbb88c7dde984d0f0c2ce8935011d (patch) | |
tree | efd8e61a3d2ff9dcff5eb5bf03e25922191f7df5 /gcc/tree-inline.c | |
parent | e22d2ad745ca3d2ac08936833a802ffc161fc89b (diff) | |
download | gcc-46f8e3b0dc1cbb88c7dde984d0f0c2ce8935011d.tar.gz |
Add ability to set target options (ix86 only) and optimization options on a function specific basis
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138075 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index c0f4c880f7f..9d827ff9261 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3683,3 +3683,34 @@ build_duplicate_type (tree type) return type; } + +/* Return whether it is safe to inline a function because it used different + target specific options or different optimization options. */ +bool +tree_can_inline_p (tree caller, tree callee) +{ + /* Don't inline a function with a higher optimization level than the + caller, or with different space constraints (hot/cold functions). */ + tree caller_tree = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (caller); + tree callee_tree = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (callee); + + if (caller_tree != callee_tree) + { + struct cl_optimization *caller_opt + = TREE_OPTIMIZATION ((caller_tree) + ? caller_tree + : optimization_default_node); + + struct cl_optimization *callee_opt + = TREE_OPTIMIZATION ((callee_tree) + ? callee_tree + : optimization_default_node); + + if ((caller_opt->optimize > callee_opt->optimize) + || (caller_opt->optimize_size != callee_opt->optimize_size)) + return false; + } + + /* Allow the backend to decide if inlining is ok. */ + return targetm.target_option.can_inline_p (caller, callee); +} |