[Bug ipa/91988] Inlining fails with LTO enabled

2019-10-04 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91988

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #5 from Richard Biener  ---
Duplicate.

*** This bug has been marked as a duplicate of bug 70929 ***

[Bug ipa/91988] Inlining fails with LTO enabled

2019-10-04 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91988

--- Comment #4 from Richard Biener  ---
The failure is triggered by compile-time(!)

Breakpoint 6, symbol_table::create_edge (this=0x76810100, 
caller=, 
callee=, call_stmt=0x77fefea0, 
count=..., indir_unknown_callee=false)
at /space/rguenther/src/svn/gcc-9-branch/gcc/cgraph.c:884
884   edge->inline_failed = CIF_MISMATCHED_ARGUMENTS;

and also

Breakpoint 7, early_inliner (fun=0x7696b210)
at /space/rguenther/src/svn/gcc-9-branch/gcc/ipa-inline.c:2841
2841  edge->inline_failed = CIF_MISMATCHED_ARGUMENTS;

we ultimatively call

types_compatible_p (type1=, 
type2=)

from

static bool
gimple_check_call_args (gimple *stmt, tree fndecl, bool args_count_match)
{
...
  if (TREE_VALUE (p) == error_mark_node
  || arg == error_mark_node
  || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
  || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg))
  && !fold_convertible_p (TREE_VALUE (p), arg)))
return false;

we're looking at TYPE_ARG_TYPES here because we don't have a PARM_DECL
and as we know TYPE_ARG_TYPES do _not_ reflect by-reference semantics.
But we could take TREE_ADDRESSABLE as a hint.

Index: gcc/cgraph.c
===
--- gcc/cgraph.c(revision 276396)
+++ gcc/cgraph.c(working copy)
@@ -3728,7 +3728,10 @@ gimple_check_call_args (gimple *stmt, tr
  || arg == error_mark_node
  || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
  || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg))
- && !fold_convertible_p (TREE_VALUE (p), arg)))
+ && !fold_convertible_p (TREE_VALUE (p), arg)
+ /* TREE_ADDRESSABLE types are passed by reference.  */
+ && !(POINTER_TYPE_P (TREE_TYPE (arg))
+  && TREE_ADDRESSABLE (TREE_VALUE (p)
 return false;
}
 }

fixes that (comparing the pointed-do type is probably too strict here).

[Bug ipa/91988] Inlining fails with LTO enabled

2019-10-04 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91988

--- Comment #3 from Richard Biener  ---
(In reply to Richard Biener from comment #2)
> I see IPA-CP being applied and that function not inlined.
> 
> Deciding on inlining of small functions.  Starting with size 9.
> Enqueueing calls in fun.constprop/9.
> Enqueueing calls in main/3.
> missed:   not inlinable: main/3 -> fun.constprop/9, mismatched arguments
> Unit growth for small function inlining: 9->9 (0%)
> 
> looks like the inliner predicate needs to consider IPA-CP transform
> being applied somehow?

hmm, w/o LTO and early inlining disabled a single-TU testcase is fine:

Deciding on inlining of small functions.  Starting with size 12.
Enqueueing calls in fun.constprop/6.
Enqueueing calls in int main()/4.
   Estimating body: fun.constprop/6
   Known to be false: not inlined
   size:0 time:0.00 nonspec time:2.00
   Estimating body: fun.constprop/6
   Known to be false: not inlined
   size:0 time:0.00 nonspec time:2.00
  enqueuing call int main()/4 -> fun.constprop/6, badness -inf
Enqueueing calls in int fun(A)/3.
   Estimating body: fun.constprop/6
   Known to be false: not inlined
   size:0 time:0.00 nonspec time:2.00
...
t3.C:6:13: optimized:  Inlined fun.constprop/6 into int main()/4 which now has
time 2.00 and size 3, net change of -6.

[Bug ipa/91988] Inlining fails with LTO enabled

2019-10-04 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91988

Richard Biener  changed:

   What|Removed |Added

   Keywords||missed-optimization
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-10-04
 CC||jamborm at gcc dot gnu.org,
   ||rguenth at gcc dot gnu.org
  Component|lto |ipa
 Ever confirmed|0   |1
  Known to fail||9.2.0

--- Comment #2 from Richard Biener  ---
I see IPA-CP being applied and that function not inlined.

Deciding on inlining of small functions.  Starting with size 9.
Enqueueing calls in fun.constprop/9.
Enqueueing calls in main/3.
missed:   not inlinable: main/3 -> fun.constprop/9, mismatched arguments
Unit growth for small function inlining: 9->9 (0%)

looks like the inliner predicate needs to consider IPA-CP transform
being applied somehow?