aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-01-22 09:25:22 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-01-22 09:25:22 +0000
commit0c3068e0068c5850939c83c6719e8905db0342b1 (patch)
treeaee50b2d3af85d215c9b2c8b549d88150943d16f
parentcce93c76bac0718cd084410797c38734b5649156 (diff)
downloadgcc-0c3068e0068c5850939c83c6719e8905db0342b1.zip
gcc-0c3068e0068c5850939c83c6719e8905db0342b1.tar.gz
gcc-0c3068e0068c5850939c83c6719e8905db0342b1.tar.bz2
ipa-inline.c (can_inline_edge_p): Disable inlining of edges with IL incompatible options.
2015-01-22 Richard Biener <rguenther@suse.de> * ipa-inline.c (can_inline_edge_p): Disable inlining of edges with IL incompatible options. Properly honor user optimize attributes. From-SVN: r219989
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-inline.c59
2 files changed, 55 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c292bfc..520b03d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-22 Richard Biener <rguenther@suse.de>
+
+ * ipa-inline.c (can_inline_edge_p): Disable inlining of edges
+ with IL incompatible options. Properly honor user optimize
+ attributes.
+
2015-01-21 Segher Boessenkool <segher@kernel.crashing.org>
PR rtl-optimization/64682
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index c0ff329..da1afc6 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -404,17 +404,56 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
optimization attribute. */
else if (caller_tree != callee_tree)
{
- /* gcc.dg/pr43564.c. Look at forced inline even in -O0. */
- if (DECL_DISREGARD_INLINE_LIMITS (callee->decl))
+ /* There are some options that change IL semantics which means
+ we cannot inline in these cases for correctness reason.
+ Not even for always_inline declared functions. */
+ /* Strictly speaking only when the callee contains signed integer
+ math where overflow is undefined. */
+ if ((opt_for_fn (e->caller->decl, flag_strict_overflow)
+ != opt_for_fn (e->caller->decl, flag_strict_overflow))
+ || (opt_for_fn (e->caller->decl, flag_wrapv)
+ != opt_for_fn (e->caller->decl, flag_wrapv))
+ || (opt_for_fn (e->caller->decl, flag_trapv)
+ != opt_for_fn (e->caller->decl, flag_trapv))
+ /* Strictly speaking only when the callee contains memory
+ accesses that are not using alias-set zero anyway. */
+ || (opt_for_fn (e->caller->decl, flag_strict_aliasing)
+ != opt_for_fn (e->caller->decl, flag_strict_aliasing))
+ /* Strictly speaking only when the callee uses FP math. */
+ || (opt_for_fn (e->caller->decl, flag_rounding_math)
+ != opt_for_fn (e->caller->decl, flag_rounding_math))
+ || (opt_for_fn (e->caller->decl, flag_trapping_math)
+ != opt_for_fn (e->caller->decl, flag_trapping_math))
+ || (opt_for_fn (e->caller->decl, flag_unsafe_math_optimizations)
+ != opt_for_fn (e->caller->decl, flag_unsafe_math_optimizations))
+ || (opt_for_fn (e->caller->decl, flag_finite_math_only)
+ != opt_for_fn (e->caller->decl, flag_finite_math_only))
+ || (opt_for_fn (e->caller->decl, flag_signaling_nans)
+ != opt_for_fn (e->caller->decl, flag_signaling_nans))
+ || (opt_for_fn (e->caller->decl, flag_cx_limited_range)
+ != opt_for_fn (e->caller->decl, flag_cx_limited_range))
+ || (opt_for_fn (e->caller->decl, flag_signed_zeros)
+ != opt_for_fn (e->caller->decl, flag_signed_zeros))
+ || (opt_for_fn (e->caller->decl, flag_associative_math)
+ != opt_for_fn (e->caller->decl, flag_associative_math))
+ || (opt_for_fn (e->caller->decl, flag_reciprocal_math)
+ != opt_for_fn (e->caller->decl, flag_reciprocal_math))
+ /* Strictly speaking only when the callee contains function
+ calls that may end up setting errno. */
+ || (opt_for_fn (e->caller->decl, flag_errno_math)
+ != opt_for_fn (e->caller->decl, flag_errno_math)))
+ {
+ e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
+ inlinable = false;
+ }
+ /* gcc.dg/pr43564.c. Apply user-forced inline even at -O0. */
+ else if (DECL_DISREGARD_INLINE_LIMITS (callee->decl)
+ && lookup_attribute ("always_inline",
+ DECL_ATTRIBUTES (callee->decl)))
;
- /* When user added an attribute, honnor it. */
- else if ((lookup_attribute ("optimize", DECL_ATTRIBUTES (caller->decl))
- || lookup_attribute ("optimize",
- DECL_ATTRIBUTES (callee->decl)))
- && ((opt_for_fn (caller->decl, optimize)
- > opt_for_fn (callee->decl, optimize))
- || (opt_for_fn (caller->decl, optimize_size)
- != opt_for_fn (callee->decl, optimize_size))))
+ /* When user added an attribute to the callee honor it. */
+ else if (lookup_attribute ("optimize", DECL_ATTRIBUTES (callee->decl))
+ && opts_for_fn (caller->decl) != opts_for_fn (callee->decl))
{
e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
inlinable = false;