Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 547672
Collapse All | Expand All

(-)a/gcc/ipa-inline.c (-39 / +56 lines)
Lines 427-475 can_inline_edge_p (struct cgraph_edge *e, bool report, Link Here
427
	      && lookup_attribute ("always_inline",
427
	      && lookup_attribute ("always_inline",
428
				   DECL_ATTRIBUTES (callee->decl)));
428
				   DECL_ATTRIBUTES (callee->decl)));
429
429
430
     /* Until GCC 4.9 we did not check the semantics alterning flags
431
	bellow and inline across optimization boundry.
432
	Enabling checks bellow breaks several packages by refusing
433
	to inline library always_inline functions. See PR65873.
434
	Disable the check for early inlining for now until better solution
435
	is found.  */
436
     if (always_inline && early)
437
	;
430
      /* There are some options that change IL semantics which means
438
      /* There are some options that change IL semantics which means
431
         we cannot inline in these cases for correctness reason.
439
         we cannot inline in these cases for correctness reason.
432
	 Not even for always_inline declared functions.  */
440
	 Not even for always_inline declared functions.  */
433
      /* Strictly speaking only when the callee contains signed integer
441
      /* Strictly speaking only when the callee contains signed integer
434
         math where overflow is undefined.  */
442
         math where overflow is undefined.  */
435
      if ((check_maybe_up (flag_strict_overflow)
443
     else if ((check_maybe_up (flag_strict_overflow)
436
	   /* this flag is set by optimize.  Allow inlining across
444
	       /* this flag is set by optimize.  Allow inlining across
437
	      optimize boundary.  */
445
		  optimize boundary.  */
438
	   && (!opt_for_fn (caller->decl, optimize)
446
	       && (!opt_for_fn (caller->decl, optimize)
439
	       == !opt_for_fn (callee->decl, optimize) || !always_inline))
447
		   == !opt_for_fn (callee->decl, optimize) || !always_inline))
440
	  || check_match (flag_wrapv)
448
	      || check_match (flag_wrapv)
441
	  || check_match (flag_trapv)
449
	      || check_match (flag_trapv)
442
	  /* Strictly speaking only when the callee contains memory
450
	      /* Strictly speaking only when the callee uses FP math.  */
443
	     accesses that are not using alias-set zero anyway.  */
451
	      || check_maybe_up (flag_rounding_math)
444
	  || check_maybe_down (flag_strict_aliasing)
452
	      || check_maybe_up (flag_trapping_math)
445
	  /* Strictly speaking only when the callee uses FP math.  */
453
	      || check_maybe_down (flag_unsafe_math_optimizations)
446
	  || check_maybe_up (flag_rounding_math)
454
	      || check_maybe_down (flag_finite_math_only)
447
	  || check_maybe_up (flag_trapping_math)
455
	      || check_maybe_up (flag_signaling_nans)
448
	  || check_maybe_down (flag_unsafe_math_optimizations)
456
	      || check_maybe_down (flag_cx_limited_range)
449
	  || check_maybe_down (flag_finite_math_only)
457
	      || check_maybe_up (flag_signed_zeros)
450
	  || check_maybe_up (flag_signaling_nans)
458
	      || check_maybe_down (flag_associative_math)
451
	  || check_maybe_down (flag_cx_limited_range)
459
	      || check_maybe_down (flag_reciprocal_math)
452
	  || check_maybe_up (flag_signed_zeros)
460
	      /* We do not want to make code compiled with exceptions to be
453
	  || check_maybe_down (flag_associative_math)
461
		 brought into a non-EH function unless we know that the callee
454
	  || check_maybe_down (flag_reciprocal_math)
462
		 does not throw.
455
	  /* We do not want to make code compiled with exceptions to be brought
463
		 This is tracked by DECL_FUNCTION_PERSONALITY.  */
456
	     into a non-EH function unless we know that the callee does not
464
	      || (check_match (flag_non_call_exceptions)
457
	     throw.  This is tracked by DECL_FUNCTION_PERSONALITY.  */
465
		  /* TODO: We also may allow bringing !flag_non_call_exceptions
458
	  || (check_match (flag_non_call_exceptions)
466
		     to flag_non_call_exceptions function, but that may need
459
	      /* TODO: We also may allow bringing !flag_non_call_exceptions
467
		     extra work in tree-inline to add the extra EH edges.  */
460
		 to flag_non_call_exceptions function, but that may need
468
		  && (!opt_for_fn (callee->decl, flag_non_call_exceptions)
461
		 extra work in tree-inline to add the extra EH edges.  */
469
		      || DECL_FUNCTION_PERSONALITY (callee->decl)))
462
	      && (!opt_for_fn (callee->decl, flag_non_call_exceptions)
470
	      || (check_maybe_up (flag_exceptions)
463
		  || DECL_FUNCTION_PERSONALITY (callee->decl)))
471
		  && DECL_FUNCTION_PERSONALITY (callee->decl))
464
	  || (check_maybe_up (flag_exceptions)
472
	      /* Strictly speaking only when the callee contains function
465
	      && DECL_FUNCTION_PERSONALITY (callee->decl))
473
		 calls that may end up setting errno.  */
466
	  /* Strictly speaking only when the callee contains function
474
	      || check_maybe_up (flag_errno_math)
467
	     calls that may end up setting errno.  */
475
	      /* When devirtualization is diabled for callee, it is not safe
468
	  || check_maybe_up (flag_errno_math)
476
		 to inline it as we possibly mangled the type info.
469
	  /* When devirtualization is diabled for callee, it is not safe
477
		 Allow early inlining of always inlines.  */
470
	     to inline it as we possibly mangled the type info.
478
	      || (!early && check_maybe_down (flag_devirtualize)))
471
	     Allow early inlining of always inlines.  */
472
	  || (!early && check_maybe_down (flag_devirtualize)))
473
	{
479
	{
474
	  e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
480
	  e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
475
	  inlinable = false;
481
	  inlinable = false;
Lines 484-489 can_inline_edge_p (struct cgraph_edge *e, bool report, Link Here
484
	  e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
490
	  e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
485
	  inlinable = false;
491
	  inlinable = false;
486
	}
492
	}
493
      /* If explicit optimize attribute are not used, the mismatch is caused
494
	 by different command line options used to build different units.
495
	 Do not care about COMDAT functions - those are intended to be
496
         optimized with the optimization flags of module they are used in.
497
	 Also do not care about mixing up size/speed optimization when
498
	 DECL_DISREGARD_INLINE_LIMITS is set.  */
499
      else if ((callee->merged
500
	        && !lookup_attribute ("optimize",
501
				      DECL_ATTRIBUTES (caller->decl)))
502
	       || DECL_DISREGARD_INLINE_LIMITS (callee->decl))
503
	;
487
      /* If mismatch is caused by merging two LTO units with different
504
      /* If mismatch is caused by merging two LTO units with different
488
	 optimizationflags we want to be bit nicer.  However never inline
505
	 optimizationflags we want to be bit nicer.  However never inline
489
	 if one of functions is not optimized at all.  */
506
	 if one of functions is not optimized at all.  */
Lines 515-521 can_inline_edge_p (struct cgraph_edge *e, bool report, Link Here
515
      else if (opt_for_fn (callee->decl, optimize_size)
532
      else if (opt_for_fn (callee->decl, optimize_size)
516
	       < opt_for_fn (caller->decl, optimize_size)
533
	       < opt_for_fn (caller->decl, optimize_size)
517
	       || (opt_for_fn (callee->decl, optimize)
534
	       || (opt_for_fn (callee->decl, optimize)
518
		   >= opt_for_fn (caller->decl, optimize)))
535
		   > opt_for_fn (caller->decl, optimize)))
519
	{
536
	{
520
	  if (estimate_edge_time (e)
537
	  if (estimate_edge_time (e)
521
	      >= 20 + inline_edge_summary (e)->call_stmt_time)
538
	      >= 20 + inline_edge_summary (e)->call_stmt_time)

Return to bug 547672