From patchwork Mon Sep 21 21:02:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= X-Patchwork-Id: 520581 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8F98614012C for ; Tue, 22 Sep 2015 07:03:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=gHzdb2zm; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=bARDXRLDKI6BZOIJgFiGuwbhLNpTSGzICOaFIzIORO7OVS de1wKt92aQrrkHqIYeHEO5YDFtx4p2YQgoB7YgWAjgfkoOKaHGtNj1vbHwxjxgaN wG7+6l4dtPsdxDzkno+3lOdHGFl6dVZQrErLU0tKyQg/r5M8k+XrvrqvQ82Bo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=kXhz/Aw2ugd9TYdsZWAVTOHN6QQ=; b=gHzdb2zmsp+XhSLwXKHl eTGlO2+jywyrnAp6/wOYl1JzyKK38sM/Dq9t4EqMm1paYMRREhMrvPedm33huzDZ yVwdmK94+tm3SvNe767IuK0YN15GXdb1DMOj6dZ0MEh/nvnQ1d3AXsg22xqU6wL8 fcDVWiVIfsy49h2IVV5k+/4= Received: (qmail 106332 invoked by alias); 21 Sep 2015 21:03:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 105516 invoked by uid 89); 21 Sep 2015 21:03:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wi0-f180.google.com Received: from mail-wi0-f180.google.com (HELO mail-wi0-f180.google.com) (209.85.212.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 21 Sep 2015 21:03:16 +0000 Received: by wiclk2 with SMTP id lk2so129997952wic.1 for ; Mon, 21 Sep 2015 14:03:13 -0700 (PDT) X-Received: by 10.194.79.196 with SMTP id l4mr27681617wjx.93.1442869393033; Mon, 21 Sep 2015 14:03:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.186.214 with HTTP; Mon, 21 Sep 2015 14:02:33 -0700 (PDT) From: =?UTF-8?B?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= Date: Mon, 21 Sep 2015 23:02:33 +0200 Message-ID: Subject: [PATCH tree-inline v2] do not say "called from here" with UNKNOWN_LOCATION To: Gcc Patch List , Richard Biener 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-21 Manuel López-Ibáñez * 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 instead of TRUE. gcc/testsuite/ChangeLog: 2015-09-21 Manuel López-Ibáñez * 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. Index: gcc/testsuite/gcc.target/i386/inline_error.c =================================================================== --- gcc/testsuite/gcc.target/i386/inline_error.c (revision 227965) +++ gcc/testsuite/gcc.target/i386/inline_error.c (working copy) @@ -7,7 +7,7 @@ foo () /* { dg-error "inlining failed in return 0; } int bar() { - return foo (); /* { dg-error "called from here" } */ + return foo (); /* { dg-message "called from here" } */ } Index: gcc/testsuite/gcc.target/i386/pr57756.c =================================================================== --- gcc/testsuite/gcc.target/i386/pr57756.c (revision 227965) +++ gcc/testsuite/gcc.target/i386/pr57756.c (working copy) @@ -9,11 +9,11 @@ __inline int callee () /* { dg-error "in } __attribute__((target("sse"))) static __inline int caller () { - return callee(); /* { dg-error "called from here" } */ + return callee(); /* { dg-message "called from here" } */ } int main () { return caller(); Index: gcc/testsuite/gcc.target/i386/pr59789.c =================================================================== --- gcc/testsuite/gcc.target/i386/pr59789.c (revision 227965) +++ gcc/testsuite/gcc.target/i386/pr59789.c (working copy) @@ -16,7 +16,7 @@ _mm_set_epi32 (int __q3, int __q2, int _ __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" } */ } Index: gcc/testsuite/gcc.target/i386/intrinsics_5.c =================================================================== --- gcc/testsuite/gcc.target/i386/intrinsics_5.c (revision 227965) +++ gcc/testsuite/gcc.target/i386/intrinsics_5.c (working copy) @@ -8,9 +8,9 @@ #include __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.*" } */ Index: gcc/testsuite/gcc.target/i386/intrinsics_6.c =================================================================== --- gcc/testsuite/gcc.target/i386/intrinsics_6.c (revision 227965) +++ gcc/testsuite/gcc.target/i386/intrinsics_6.c (working copy) @@ -8,9 +8,9 @@ #include __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.*" } */ Index: gcc/testsuite/gcc.dg/winline-5.c =================================================================== --- gcc/testsuite/gcc.dg/winline-5.c (revision 227965) +++ gcc/testsuite/gcc.dg/winline-5.c (working copy) @@ -15,7 +15,7 @@ inline int q(void) /* { dg-warning "inli big(); big(); } int t (void) { - return q (); /* { dg-warning "called from here" } */ + return q (); /* { dg-message "called from here" } */ } Index: gcc/testsuite/gcc.dg/winline-9.c =================================================================== --- gcc/testsuite/gcc.dg/winline-9.c (revision 227965) +++ gcc/testsuite/gcc.dg/winline-9.c (working copy) @@ -20,7 +20,7 @@ int t() { if (a) aa(); if (b) - bb(); /* { dg-warning "called from here" "" } */ + bb(); /* { dg-message "called from here" } */ } Index: gcc/testsuite/gcc.dg/always_inline2.c =================================================================== --- gcc/testsuite/gcc.dg/always_inline2.c (revision 227965) +++ gcc/testsuite/gcc.dg/always_inline2.c (working copy) @@ -2,7 +2,7 @@ /* { dg-options "-O2 -fgnu89-inline" } */ inline __attribute__ ((always_inline)) void t(void); /* { dg-error "body not available" } */ void q(void) { - t(); /* { dg-error "called from here" } */ + t(); /* { dg-message "called from here" } */ } Index: gcc/testsuite/gcc.dg/winline-2.c =================================================================== --- gcc/testsuite/gcc.dg/winline-2.c (revision 227965) +++ gcc/testsuite/gcc.dg/winline-2.c (working copy) @@ -2,7 +2,7 @@ /* { dg-options "-Winline -O2 -fgnu89-inline" } */ 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" } */ } Index: gcc/testsuite/gcc.dg/winline-6.c =================================================================== --- gcc/testsuite/gcc.dg/winline-6.c (revision 227965) +++ gcc/testsuite/gcc.dg/winline-6.c (working copy) @@ -15,7 +15,7 @@ inline int q(void) /* { dg-warning "larg big(); big(); } inline int t (void) { - return q () + 1; /* { dg-warning "called from here" } */ + return q () + 1; /* { dg-message "called from here" } */ } Index: gcc/testsuite/gcc.dg/winline-10.c =================================================================== --- gcc/testsuite/gcc.dg/winline-10.c (revision 227965) +++ gcc/testsuite/gcc.dg/winline-10.c (working copy) @@ -9,9 +9,9 @@ inline void f (x) /* { dg-warning "inlin asm (""); } 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" } */ Index: gcc/testsuite/gcc.dg/pr49243.c =================================================================== --- gcc/testsuite/gcc.dg/pr49243.c (revision 227965) +++ gcc/testsuite/gcc.dg/pr49243.c (working copy) @@ -18,8 +18,8 @@ static inline int wrapper(const char **s } 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(); } Index: gcc/testsuite/gcc.dg/always_inline3.c =================================================================== --- gcc/testsuite/gcc.dg/always_inline3.c (revision 227965) +++ gcc/testsuite/gcc.dg/always_inline3.c (working copy) @@ -4,8 +4,8 @@ int do_something_evil (void); inline __attribute__ ((always_inline)) void 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. */ } Index: gcc/testsuite/gcc.dg/winline-3.c =================================================================== --- gcc/testsuite/gcc.dg/winline-3.c (revision 227965) +++ gcc/testsuite/gcc.dg/winline-3.c (working copy) @@ -15,7 +15,7 @@ inline int q(void) /* { dg-warning "max- big(); big(); } inline int t (void) { - return q (); /* { dg-warning "called from here" "" } */ + return q (); /* { dg-message "called from here" } */ } Index: gcc/testsuite/gcc.dg/winline-7.c =================================================================== --- gcc/testsuite/gcc.dg/winline-7.c (revision 227965) +++ gcc/testsuite/gcc.dg/winline-7.c (working copy) @@ -9,7 +9,7 @@ inline void *q (void) /* { dg-warning "( { return alloca (10); } inline void *t (void) { - return q (); /* { dg-warning "called from here" } */ + return q (); /* { dg-message "called from here" } */ } Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 227965) +++ gcc/tree-inline.c (working copy) @@ -4382,27 +4382,20 @@ expand_call_inline (basic_block bb, gimp hash_map *dst; hash_map *st = NULL; 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; - input_location = gimple_location (stmt); - /* From here on, we're only interested in CALL_EXPRs. */ call_stmt = dyn_cast (stmt); if (!call_stmt) goto egress; @@ -4452,11 +4445,15 @@ expand_call_inline (basic_block bb, gimp /* PR 20090218-1_0.c. Body can be provided by another module. */ && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto)) { 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) && !DECL_NO_INLINE_WARNING_P (fn) && !DECL_IN_SYSTEM_HEADER (fn) @@ -4465,13 +4461,19 @@ expand_call_inline (basic_block bb, gimp /* Do not warn about not inlined recursive calls. */ && !cg_edge->recursive_p () /* 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; } fn = cg_edge->callee->decl; cg_edge->callee->get_untransformed_body (); @@ -4532,11 +4533,12 @@ expand_call_inline (basic_block bb, gimp not refer to them in any way to not break GC for locations. */ if (gimple_block (stmt)) { 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); } /* Local declarations will be replaced by their equivalents in this map. */ @@ -4797,14 +4798,13 @@ expand_call_inline (basic_block bb, gimp /* Update callgraph if needed. */ cg_edge->callee->remove (); id->block = NULL_TREE; - successfully_inlined = TRUE; + successfully_inlined = true; egress: - input_location = saved_location; return successfully_inlined; } /* Expand call statements reachable from STMT_P. We can only have CALL_EXPRs as the "toplevel" tree code or nested