From patchwork Wed May 17 02:16:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 763306 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 3wSHyF1nM9z9s1h for ; Wed, 17 May 2017 12:17:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="j8RCj90W"; 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:from :to:cc:subject:date:message-id; q=dns; s=default; b=miLEIJYhHa6F DWoodIILEYu4VJahnpR2Fep7nKOpNJzriY3RCRpZVVVmI9eVkanpbk3LONRAS09W LIj8T9r+BjRFBylKas1nVhnke3jqSnGGro+KPTxAoEpOzDfmmn6VKngZ+KLxf8JI srdD5ytbKEJkApqic15dyLcaA1u49U4= 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:from :to:cc:subject:date:message-id; s=default; bh=CQvzAGdmGbK//wKWdk AkVVFi5As=; b=j8RCj90WA6cRXSUfUnsMYMK/E8vGH6nVl7tvbBdmzVdDujMvC2 M9/2SGPs5MvB6+38OlrvTNMTwh9SgdAXhk2jbHBj9ocUxx8CEioIhsgA9aHTgG5C gLoyIk9e/vnFiLdHH0sZlUgvgdPOWFgMszDK+nHJiY0YsjXhwn+ld6Gmc= Received: (qmail 70658 invoked by alias); 17 May 2017 02:16:53 -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 66689 invoked by uid 89); 17 May 2017 02:16:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Produce, 1567 X-HELO: one.firstfloor.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 May 2017 02:16:49 +0000 Received: from firstfloor.org (67-5-219-155.ptld.qwest.net [67.5.219.155]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id 26D4686A95; Wed, 17 May 2017 04:16:50 +0200 (CEST) Received: by firstfloor.org (Postfix, from userid 1000) id 478C9A3288; Tue, 16 May 2017 19:16:48 -0700 (PDT) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH] Add -dB option to disable backtraces Date: Tue, 16 May 2017 19:16:47 -0700 Message-Id: <20170517021647.8495-1-andi@firstfloor.org> From: Andi Kleen When running creduce on an ICE substantial amounts of the total CPU time go to backtrace_qsort() (sorting dwarf of the compiler) for printing the backtrace of the ICE. When running a reduction we don't need the backtrace. So add a -dB option to turn it off, and make reduction a bit faster. Passes bootstrap and testing on x86_64-linux gcc/: 2017-05-16 Andi Kleen * diagnostic.c (diagnostic_initialize): Set disable_backtrace to false. (diagnostic_action_after_output): Check disable_backtrace. * diagnostic.h (struct diagnostic_context): Add disable_backtrace. * doc/invoke.texi (-dB): Document. * opts.c (decode_d_option): Handle -dB. --- gcc/diagnostic.c | 16 ++++++++++------ gcc/diagnostic.h | 7 +++++++ gcc/doc/invoke.texi | 6 ++++++ gcc/opts.c | 3 +++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 158519606f8..bbac3f384d4 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -156,6 +156,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts) context->caret_chars[i] = '^'; context->show_option_requested = false; context->abort_on_error = false; + context->disable_backtrace = false; context->show_column = false; context->pedantic_errors = false; context->permissive = false; @@ -500,13 +501,16 @@ diagnostic_action_after_output (diagnostic_context *context, case DK_ICE: case DK_ICE_NOBT: { - struct backtrace_state *state = NULL; - if (diag_kind == DK_ICE) - state = backtrace_create_state (NULL, 0, bt_err_callback, NULL); int count = 0; - if (state != NULL) - backtrace_full (state, 2, bt_callback, bt_err_callback, - (void *) &count); + if (!context->disable_backtrace) + { + struct backtrace_state *state = NULL; + if (diag_kind == DK_ICE) + state = backtrace_create_state (NULL, 0, bt_err_callback, NULL); + if (state != NULL) + backtrace_full (state, 2, bt_callback, bt_err_callback, + (void *) &count); + } if (context->abort_on_error) real_abort (); diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index dbd1703e0ef..440b547c6da 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -120,6 +120,9 @@ struct diagnostic_context /* True if we should raise a SIGABRT on errors. */ bool abort_on_error; + /* If true don't print backtraces for internal errors. */ + bool disable_backtrace; + /* True if we should show the column number on diagnostics. */ bool show_column; @@ -245,6 +248,10 @@ diagnostic_inhibit_notes (diagnostic_context * context) #define diagnostic_abort_on_error(DC) \ (DC)->abort_on_error = true +/* Don't print backtraces for internal errors. */ +#define diagnostic_disable_backtrace(DC) \ + (DC)->disable_backtrace = true; + /* This diagnostic_context is used by front-ends that directly output diagnostic messages without going through `error', `warning', and similar functions. */ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 715830a1a43..677e78c7078 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -12889,6 +12889,12 @@ Produce all the dumps listed above. @opindex dA Annotate the assembler output with miscellaneous debugging information. +@item -dB +@opindex dB +Do not print backtraces on compiler crashes. This speeds up reducing +test cases for compiler crashes, because printing backtraces is relatively +slow. + @item -dD @opindex dD Dump all macro definitions, at the end of preprocessing, in addition to diff --git a/gcc/opts.c b/gcc/opts.c index ffedb10f18f..0c1da107714 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -2593,6 +2593,9 @@ decode_d_option (const char *arg, struct gcc_options *opts, case 'a': opts->x_flag_dump_all_passed = true; break; + case 'B': + diagnostic_disable_backtrace (dc); + break; default: warning_at (loc, 0, "unrecognized gcc debugging option: %c", c);