From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100859 invoked by alias); 28 Jan 2016 20:20:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 100777 invoked by uid 89); 28 Jan 2016 20:20:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:print_g, *ctx, 42,6 X-HELO: mail-vk0-f50.google.com Received: from mail-vk0-f50.google.com (HELO mail-vk0-f50.google.com) (209.85.213.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 28 Jan 2016 20:20:21 +0000 Received: by mail-vk0-f50.google.com with SMTP id e6so30480027vkh.2 for ; Thu, 28 Jan 2016 12:20:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=9Q9gUlKsPNy1UvenCxd3oL91Z8+WiHC++79NDzCFTlQ=; b=VviBy+n3ac5oBhO59ErffkvsprdzKYvxicJfCgnBPLFZxhSx0xP6GN41roh8xkbch9 bPgOG+tYw78CgB4q31w76yRTCspK01aOtTv7yNykI3JKv2HlaVpjm3arVhDxxxX5hrSG 52G8lu/C42mh5TZPW78TMsnr3vHV21s+uoveaRAP9gwIciK9ui10WWVylN0pA817pedA EKzDdq5hkoMImQAL32Qe2SAcACnn6Jwz/whQJLg0JHMMgHjLTG0Z45pN5E1aU3fSakB6 NG7onVtD0IMce0EcR0ECWBEHYolavdUUI3kOHnevZWy265qvWIi9MasUVhz9amcmdW6h /m2g== X-Gm-Message-State: AG10YOTtdSnMp2/CcIMls4Y/uvWpuVyWwslGU5SFpwQpgI4hDKk/j0oX4It35Aku8u/sMtxEYcmOG3+v1geWvdjt MIME-Version: 1.0 X-Received: by 10.31.52.65 with SMTP id b62mr3438225vka.61.1454012418006; Thu, 28 Jan 2016 12:20:18 -0800 (PST) Received: by 10.31.220.194 with HTTP; Thu, 28 Jan 2016 12:20:17 -0800 (PST) Date: Thu, 28 Jan 2016 20:20:00 -0000 Message-ID: Subject: [PATCH] New flag for dumping information about constexpr function calls memoization (GCC 5.2.0) From: Andres Tiraboschi To: GCC Patches Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-01/txt/msg02251.txt.bz2 Hi, This patch adds a flag (-fdump-memoization-hits) in order to dump information about wich constexpr functions calls are memoized. This is patch is for gcc-5.2.0. If OK, please commit it for me since I don't have write access. patch: diff --git a/gcc/common.opt b/gcc/common.opt index 1218a71..bf0c7df 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1168,6 +1168,10 @@ fdump-passes Common Var(flag_dump_passes) Init(0) Dump optimization passes +fdump-memoization-hits +Common Var(flag_dump_memoization_hits) Init(0) +Dump info about constexpr calls memoized. + fdump-unnumbered Common Report Var(flag_dump_unnumbered) Suppress output of instruction numbers, line number notes and addresses in debugging dumps diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index e250726..41ae5b3 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -42,6 +42,8 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "tree-inline.h" #include "ubsan.h" +#include "tree-pretty-print.h" +#include "dumpfile.h" static bool verify_constant (tree, bool, bool *, bool *); #define VERIFY_CONSTANT(X) \ @@ -1173,6 +1175,14 @@ cx_error_context (void) return r; } +static void +dump_memoization_hit (FILE *file, tree call, int flags) +{ + fprintf(file, "Memoized call:\n"); + print_generic_decl(file, call, flags); + fprintf(file, "\n"); +} + /* Subroutine of cxx_eval_constant_expression. Evaluate the call expression tree T in the context of OLD_CALL expression evaluation. */ @@ -1338,7 +1348,11 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, entry->result = result = error_mark_node; } else - result = entry->result; + { + if (flag_dump_memoization_hits) + dump_memoization_hit(stderr, t, 0); + result = entry->result; + } } if (!depth_ok)