http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57698
--- Comment #7 from Sriraman Tallam <tmsriram at google dot com> --- Taking a stab at fixing this. Here is what is going on. In rev. 200179, this change to tree-inline.c Index: tree-inline.c =================================================================== --- tree-inline.c (revision 200178) +++ tree-inline.c (revision 200179) @@ -3905,8 +3905,6 @@ for inlining, but we can't do that because frontends overwrite the body. */ && !cg_edge->callee->local.redefined_extern_inline - /* Avoid warnings during early inline pass. */ - && cgraph_global_info_ready /* PR 20090218-1_0.c. Body can be provided by another module. */ && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto)) { made inline failure errors during early inlining reportable. Now, this function is called when the early_inliner calls optimize_inline_calls. The reason for the failure, CIF_INDIRECT_UNKNOWN_CALL, should not be reported because it is not a valid reason,(see can_inline_edge_p in ipa-inline.c for the list of reasons we intend to report) but it gets reported because of the above change. I have the following patch to tree-inline.c to fix this by enumerating all the early inliner failures that should be reported. I took this list by simply looking at can_inline_edge_p. Please see patch below. Comments please? Index: tree-inline.c =================================================================== --- tree-inline.c (revision 200912) +++ tree-inline.c (working copy) @@ -3838,6 +3838,32 @@ add_local_variables (struct function *callee, stru } } +/* Should an error be reported when early inliner fails to inline an + always_inline function? That depends on the REASON. */ + +static inline bool +report_early_inliner_always_inline_failure (cgraph_inline_failed_t reason) +{ + /* Only the following reasons need to be reported when the early inliner + fails to inline an always_inline function. Called from + expand_call_inline.*/ + switch (reason) + { + case CIF_BODY_NOT_AVAILABLE: + case CIF_FUNCTION_NOT_INLINABLE: + case CIF_OVERWRITABLE: + case CIF_MISMATCHED_ARGUMENTS: + case CIF_EH_PERSONALITY: + case CIF_UNSPECIFIED: + case CIF_NON_CALL_EXCEPTIONS: + case CIF_TARGET_OPTION_MISMATCH: + case CIF_OPTIMIZATION_MISMATCH: + return true; + default: + return false; + } +} + /* If STMT is a GIMPLE_CALL, replace it with its inline expansion. */ static bool @@ -3905,6 +3931,9 @@ expand_call_inline (basic_block bb, gimple stmt, c for inlining, but we can't do that because frontends overwrite the body. */ && !cg_edge->callee->local.redefined_extern_inline + /* During early inline pass, check if the reason is reportable. */ + && (cgraph_global_info_ready + || report_early_inliner_always_inline_failure (reason)) /* PR 20090218-1_0.c. Body can be provided by another module. */ && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto)) {