From patchwork Tue Jul 10 01:11:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 941765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-481253-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XBYjDQap"; dkim-atps=neutral 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 41PjjR0hTSz9s1R for ; Tue, 10 Jul 2018 10:28:26 +1000 (AEST) 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:in-reply-to:references; q=dns; s= default; b=I/+TmycHx6gSlTmgbtQdeH+YQH5fBF3noUcb6Bwv1fgTnNUgYDuOu mjbx7fy2OLd9bvsPzhUl3pbSSPS+tnOIXrN9BXwQILeaAf7Ildl3IUPTxmJZ4UY3 eU0Xj2/w/+h3RLFv7aY0XyZ3knOVAl6C/f8cELvseAq7O+oPRV3ibg= 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:in-reply-to:references; s= default; bh=AnMakg9geJBD7KJuwG0BjNJiVbw=; b=XBYjDQapSiuY5oRUwLMN HhFyQmAIgxt54pyNG9Zryjn4pfGY3QPYcUajIKm3mtnFfixJ830SykDWTUPZ25wP N5UHJ9SmZ3TlMenRHGXiAIl6yHqdHY2M7AVjIT95VuS+76E9Cua0wnd6EbkXcNRk B3bfR2CcHv8X+rH+4N415m8= Received: (qmail 86409 invoked by alias); 10 Jul 2018 00:27:40 -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 86328 invoked by uid 89); 10 Jul 2018 00:27:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jul 2018 00:27:37 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA1AA30E6862; Tue, 10 Jul 2018 00:27:36 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-31.phx2.redhat.com [10.3.112.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7025A600C9; Tue, 10 Jul 2018 00:27:35 +0000 (UTC) From: David Malcolm To: Richard Biener Cc: gcc-patches@gcc.gnu.org, Richard Sandiford , David Malcolm Subject: [PATCH 5/5] Add opt-problem.cc Date: Mon, 9 Jul 2018 21:11:36 -0400 Message-Id: <1531185096-17113-6-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1531185096-17113-1-git-send-email-dmalcolm@redhat.com> References: <1531185096-17113-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes gcc/ChangeLog: * Makefile.in (OBJS): Add opt-problem.o. * opt-problem.cc: New file. --- gcc/Makefile.in | 1 + gcc/opt-problem.cc | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 gcc/opt-problem.cc diff --git a/gcc/Makefile.in b/gcc/Makefile.in index c5c3d3c..fb262da 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1425,6 +1425,7 @@ OBJS = \ omp-grid.o \ omp-low.o \ omp-simd-clone.o \ + opt-problem.o \ optabs.o \ optabs-libfuncs.o \ optabs-query.o \ diff --git a/gcc/opt-problem.cc b/gcc/opt-problem.cc new file mode 100644 index 0000000..f518b16 --- /dev/null +++ b/gcc/opt-problem.cc @@ -0,0 +1,96 @@ +/* Rich information on why an optimization wasn't possible. + Copyright (C) 2018 Free Software Foundation, Inc. + Contributed by David Malcolm . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "diagnostic.h" +#include "tree.h" +#include "gimple.h" +#include "pretty-print.h" +#include "gimple-pretty-print.h" +#include "opt-problem.h" + +/* Emit a remark about an optimization. */ + +bool +opt_report::remark (dump_location_t loc, const char *gmsgid, ...) +{ + if (!flag_remarks) + return false; + + va_list ap; + va_start (ap, gmsgid); + bool ret = emit_diagnostic_valist (DK_REMARK, loc.get_location_t (), -1, + gmsgid, &ap); + va_end (ap); + + // FIXME: how should this interact with optinfo? (we don't want a duplicate remark) + return ret; +} + +/* Emit a note about an optimization. */ + +bool +opt_report::note (dump_location_t loc, const char *gmsgid, ...) +{ + va_list ap; + va_start (ap, gmsgid); + bool ret = emit_diagnostic_valist (DK_NOTE, loc.get_location_t (), -1, + gmsgid, &ap); + va_end (ap); + + // FIXME: how should this interact with optinfo? (we don't want a duplicate note) + return ret; +} + +opt_problem *opt_problem::s_the_problem; + +// FIXME: some refactoring is needed, based on exactly where remarks land, +// and how this interacts with the optinfo stuff. For now, this decl: + +extern void +print_impl_location (pretty_printer *pp, const dump_impl_location_t &impl_loc); + +/* Emit a diagnostic note describing why an optimization wasn't possible. */ + +void +opt_problem::report_reason (opt_report &report) +{ + bool show_color = pp_show_color (global_dc->printer); + + pretty_printer pp; + pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_string (&pp, m_text); + if (m_stmt) + { + pp_string (&pp, ": "); + pp_begin_quote (&pp, show_color); + pp_gimple_stmt_1 (&pp, m_stmt, 0, TDF_SLIM); + pp_end_quote (&pp, show_color); + } + + print_impl_location (&pp, m_location.get_impl_location ()); + + const char *msg = pp_formatted_text (&pp); + + report.note (m_location, "%s", msg); +}