aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorMichael Meissner <meissner@gcc.gnu.org>2008-07-23 10:28:06 +0000
committerMichael Meissner <meissner@gcc.gnu.org>2008-07-23 10:28:06 +0000
commitab442df7fb453434d80a779844fe1a10c0c802ab (patch)
treeefd8e61a3d2ff9dcff5eb5bf03e25922191f7df5 /gcc/tree-inline.c
parent5295185c3150a8d31685dc44248aa058246bbe73 (diff)
downloadgcc-ab442df7fb453434d80a779844fe1a10c0c802ab.zip
gcc-ab442df7fb453434d80a779844fe1a10c0c802ab.tar.gz
gcc-ab442df7fb453434d80a779844fe1a10c0c802ab.tar.bz2
Add ability to set target options (ix86 only) and optimization options on a function specific basis
From-SVN: r138075
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index c0f4c88..9d827ff 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);
+}