[PATCH tree-inline] Do not say "called from here" with UNKNOWN_LOCATION

In https://sourceware.org/ml/libc-alpha/2014-12/msg00300.html, we give a
"called from here" note without actually having a location, which looks
strange. I haven't been able to generate such a testcase. If this happens,
try to at least point to the current function being called. If that location is
also unknown, skip the extra note.

gcc/ChangeLog:

2015-09-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* tree-inline.c (expand_call_inline): Use inform for extra note.
	Do not give a note with UNKNOWN_LOCATION.
	Replace input_location with gimple_location (stmt).
	Use true/false instead of TRUE/FALSE.

gcc/testsuite/ChangeLog:

2015-09-22  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* gcc.target/i386/inline_error.c (int bar): Use dg-message for note.
	* gcc.target/i386/pr57756.c (static __inline int caller): Likewise.
	* gcc.target/i386/pr59789.c (f1): Likewise.
	* gcc.target/i386/intrinsics_5.c (__m128i foo): Likewise.
	* gcc.target/i386/intrinsics_6.c: Likewise.
	* gcc.dg/winline-5.c (int t): Likewise.
	* gcc.dg/winline-9.c (t): Likewise.
	* gcc.dg/always_inline2.c (q): Likewise.
	* gcc.dg/winline-2.c (inline int t): Likewise.
	* gcc.dg/winline-6.c: Likewise.
	* gcc.dg/winline-10.c (void g): Likewise.
	* gcc.dg/pr49243.c (void parse): Likewise.
	* gcc.dg/always_inline3.c (q2): Likewise.
	* gcc.dg/winline-3.c: Likewise.
	* gcc.dg/winline-7.c (inline void *t): Likewise.

From-SVN: r227997
parent 50b4b446
2015-09-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
* tree-inline.c (expand_call_inline): Use inform for extra note.
Do not give a note with UNKNOWN_LOCATION.
Replace input_location with gimple_location (stmt).
Use true/false instead of TRUE/FALSE.
2015-09-22 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/67666
2015-09-22 Manuel López-Ibáñez <manu@gcc.gnu.org>
* gcc.target/i386/inline_error.c (int bar): Use dg-message for note.
* gcc.target/i386/pr57756.c (static __inline int caller): Likewise.
* gcc.target/i386/pr59789.c (f1): Likewise.
* gcc.target/i386/intrinsics_5.c (__m128i foo): Likewise.
* gcc.target/i386/intrinsics_6.c: Likewise.
* gcc.dg/winline-5.c (int t): Likewise.
* gcc.dg/winline-9.c (t): Likewise.
* gcc.dg/always_inline2.c (q): Likewise.
* gcc.dg/winline-2.c (inline int t): Likewise.
* gcc.dg/winline-6.c: Likewise.
* gcc.dg/winline-10.c (void g): Likewise.
* gcc.dg/pr49243.c (void parse): Likewise.
* gcc.dg/always_inline3.c (q2): Likewise.
* gcc.dg/winline-3.c: Likewise.
* gcc.dg/winline-7.c (inline void *t): Likewise.
2015-09-22 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/67666
......
......@@ -4,5 +4,5 @@ inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not ava
void
q(void)
{
t(); /* { dg-error "called from here" } */
t(); /* { dg-message "called from here" } */
}
......@@ -6,6 +6,6 @@ q2(void) /* { dg-error "recursive inlining" } */
{
if (do_something_evil ())
return;
q2(); /* { dg-error "called from here" } */
q2(); /* { dg-message "called from here" } */
q2(); /* With -O2 we don't warn here, it is eliminated by tail recursion. */
}
......@@ -20,6 +20,6 @@ static inline int wrapper(const char **s_ptr) /* { dg-warning "(inlining failed|
void parse(const char *data)
{
const char *s = data;
if (!(wrapper(&s) == -1 && (s - data) == 1)) /* { dg-warning "called from here" } */
if (!(wrapper(&s) == -1 && (s - data) == 1)) /* { dg-message "called from here" } */
__builtin_abort();
}
......@@ -11,7 +11,7 @@ inline void f (x) /* { dg-warning "inlining .* mismatched arg" "" } */
void g (struct s x)
{
f (x); /* { dg-warning "called from here" "" } */
f (x); /* { dg-message "called from here" } */
}
void f (int x); /* { dg-warning "follows non-prototype definition" } */
......@@ -4,5 +4,5 @@
inline int q(void); /* { dg-warning "body not available" "" } */
inline int t(void)
{
return q(); /* { dg-warning "called from here" "" } */
return q(); /* { dg-message "called from here" } */
}
......@@ -17,5 +17,5 @@ inline int q(void) /* { dg-warning "max-inline-insns-single" "" } */
}
inline int t (void)
{
return q (); /* { dg-warning "called from here" "" } */
return q (); /* { dg-message "called from here" } */
}
......@@ -17,5 +17,5 @@ inline int q(void) /* { dg-warning "inline-unit-growth" } */
}
int t (void)
{
return q (); /* { dg-warning "called from here" } */
return q (); /* { dg-message "called from here" } */
}
......@@ -17,5 +17,5 @@ inline int q(void) /* { dg-warning "large-function-growth" } */
}
inline int t (void)
{
return q () + 1; /* { dg-warning "called from here" } */
return q () + 1; /* { dg-message "called from here" } */
}
......@@ -11,5 +11,5 @@ inline void *q (void) /* { dg-warning "(function not inlinable|alloca)" } */
}
inline void *t (void)
{
return q (); /* { dg-warning "called from here" } */
return q (); /* { dg-message "called from here" } */
}
......@@ -22,5 +22,5 @@ t()
if (a)
aa();
if (b)
bb(); /* { dg-warning "called from here" "" } */
bb(); /* { dg-message "called from here" } */
}
......@@ -9,5 +9,5 @@ foo () /* { dg-error "inlining failed in call to always_inline .* target specifi
int bar()
{
return foo (); /* { dg-error "called from here" } */
return foo (); /* { dg-message "called from here" } */
}
......@@ -10,7 +10,7 @@
__m128i foo(__m128i *V)
{
return _mm_stream_load_si128(V); /* { dg-error "called from here" } */
return _mm_stream_load_si128(V); /* { dg-message "called from here" } */
}
/* { dg-prune-output ".*inlining failed.*" } */
......@@ -10,7 +10,7 @@
__m128i foo(__m128i *V)
{
return _mm_stream_load_si128(V); /* { dg-error "called from here" } */
return _mm_stream_load_si128(V); /* { dg-message "called from here" } */
}
/* { dg-prune-output ".*inlining failed.*" } */
......@@ -11,7 +11,7 @@ __inline int callee () /* { dg-error "inlining failed in call to always_inline"
__attribute__((target("sse")))
static __inline int caller ()
{
return callee(); /* { dg-error "called from here" } */
return callee(); /* { dg-message "called from here" } */
}
int main ()
......
......@@ -18,5 +18,5 @@ _mm_set_epi32 (int __q3, int __q2, int __q1, int __q0) /* { dg-error "target spe
__m128i
f1(void)
{ /* { dg-message "warning: SSE vector return without SSE enabled changes the ABI" } */
return _mm_set_epi32 (0, 0, 0, 0); /* { dg-error "called from here" } */
return _mm_set_epi32 (0, 0, 0, 0); /* { dg-message "called from here" } */
}
......@@ -4384,21 +4384,19 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
tree return_slot;
tree modify_dest;
tree return_bounds = NULL;
location_t saved_location;
struct cgraph_edge *cg_edge;
cgraph_inline_failed_t reason;
basic_block return_block;
edge e;
gimple_stmt_iterator gsi, stmt_gsi;
bool successfully_inlined = FALSE;
bool successfully_inlined = false;
bool purge_dead_abnormal_edges;
gcall *call_stmt;
unsigned int i;
/* Set input_location here so we get the right instantiation context
if we call instantiate_decl from inlinable_function_p. */
/* FIXME: instantiate_decl isn't called by inlinable_function_p. */
saved_location = input_location;
/* The gimplifier uses input_location in too many places, such as
internal_get_tmp_var (). */
location_t saved_location = input_location;
input_location = gimple_location (stmt);
/* From here on, we're only interested in CALL_EXPRs. */
......@@ -4454,7 +4452,11 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
{
error ("inlining failed in call to always_inline %q+F: %s", fn,
cgraph_inline_failed_string (reason));
error ("called from here");
if (gimple_location (stmt) != UNKNOWN_LOCATION)
inform (gimple_location (stmt), "called from here");
else if (DECL_SOURCE_LOCATION (cfun->decl) != UNKNOWN_LOCATION)
inform (DECL_SOURCE_LOCATION (cfun->decl),
"called from this function");
}
else if (warn_inline
&& DECL_DECLARED_INLINE_P (fn)
......@@ -4467,9 +4469,15 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
/* Avoid warnings during early inline pass. */
&& symtab->global_info_ready)
{
warning (OPT_Winline, "inlining failed in call to %q+F: %s",
fn, _(cgraph_inline_failed_string (reason)));
warning (OPT_Winline, "called from here");
if (warning (OPT_Winline, "inlining failed in call to %q+F: %s",
fn, _(cgraph_inline_failed_string (reason))))
{
if (gimple_location (stmt) != UNKNOWN_LOCATION)
inform (gimple_location (stmt), "called from here");
else if (DECL_SOURCE_LOCATION (cfun->decl) != UNKNOWN_LOCATION)
inform (DECL_SOURCE_LOCATION (cfun->decl),
"called from this function");
}
}
goto egress;
}
......@@ -4534,7 +4542,8 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
{
id->block = make_node (BLOCK);
BLOCK_ABSTRACT_ORIGIN (id->block) = fn;
BLOCK_SOURCE_LOCATION (id->block) = LOCATION_LOCUS (input_location);
BLOCK_SOURCE_LOCATION (id->block)
= LOCATION_LOCUS (gimple_location (stmt));
prepend_lexical_block (gimple_block (stmt), id->block);
}
......@@ -4799,7 +4808,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
cg_edge->callee->remove ();
id->block = NULL_TREE;
successfully_inlined = TRUE;
successfully_inlined = true;
egress:
input_location = saved_location;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment