From patchwork Tue Oct 30 05:53:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 195290 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]) by ozlabs.org (Postfix) with SMTP id AFCFA2C008C for ; Tue, 30 Oct 2012 16:53:56 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352181237; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=KisNL/sKSD6V9g8bt6KpHtUG1Jo=; b=KNqjxrEv9sXdQgtrigeAKMvvG905HUVELrehRG/znM3WWEae5kcMEB16WK4Erf Ex78d2XgjJC29E5BjKDIgHGHchAh7aVImGocMw2V8Ek9+3jv68PQQOFwkSZUeqvm g4lX4cZZ4r0p9oQR74LchwOMaAP3Dl13vbG6LZURzlNEA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Pz9gt/rqnlc62wDbLTCKGxWZ6racmrLBQRcvRRgNcLgUPt7XoxmCM7ZNn98m+A ukFrTnLgmMLS7+2QujmFN3mnbUw4bSoxghHf2bcFJUUQQU0HRihaE34h/l54hCFW ihM0bSNmsE6K4F8gBJvlG/W+5YpTY/sYThEgZGasrxvPU=; Received: (qmail 23080 invoked by alias); 30 Oct 2012 05:53:50 -0000 Received: (qmail 23059 invoked by uid 22791); 30 Oct 2012 05:53:49 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Oct 2012 05:53:43 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa11so3732284pad.20 for ; Mon, 29 Oct 2012 22:53:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.219.5 with SMTP id pk5mr62954392pbc.124.1351576422850; Mon, 29 Oct 2012 22:53:42 -0700 (PDT) Received: by 10.68.19.138 with HTTP; Mon, 29 Oct 2012 22:53:42 -0700 (PDT) In-Reply-To: References: <20121029120601.GA19039@gmail.com> <20121029121826.GJ1752@tucnak.redhat.com> Date: Mon, 29 Oct 2012 22:53:42 -0700 Message-ID: Subject: Re: PATCH: Correct alloca length in dump_gimple_bb_header From: "H.J. Lu" To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org X-IsSubscribed: yes 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 On Mon, Oct 29, 2012 at 6:01 AM, H.J. Lu wrote: > On Mon, Oct 29, 2012 at 5:18 AM, Jakub Jelinek wrote: >> On Mon, Oct 29, 2012 at 05:06:01AM -0700, H.J. Lu wrote: >>> When indent == 0, we call alloca with -1 bytes. This patch changes >>> it to indent + 1. This is a trunk only regression. OK to install? >> >>> 2012-10-29 H.J. Lu >>> >>> * gimple-pretty-print.c (dump_gimple_bb_header): Correct alloca >>> length. >>> >>> diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c >>> index 4b3235e..62c315e 100644 >>> --- a/gcc/gimple-pretty-print.c >>> +++ b/gcc/gimple-pretty-print.c >>> @@ -2093,7 +2093,7 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) >>> gimple stmt = first_stmt (bb); >>> if (!stmt || gimple_code (stmt) != GIMPLE_LABEL) >>> { >>> - char *s_indent = (char *) alloca ((size_t) indent - 2 + 1); >>> + char *s_indent = (char *) alloca ((size_t) indent + 1); >>> memset (s_indent, ' ', (size_t) indent); >>> s_indent[indent] = '\0'; >>> fprintf (outf, "%s:\n", s_indent, bb->index); >> >> Can't you instead of all this just do >> fprintf (outf, "%*s:\n", indent, "", bb->index); >> ? >> > > The whole function has another: > > char *s_indent = (char *) alloca ((size_t) indent + 1); > memset (s_indent, ' ', (size_t) indent); > s_indent[indent] = '\0'; > > We should make the same switch for both. Tested on Lnux/x8-64. OK to install? diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 4b3235e..a5a493a 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -2068,9 +2068,6 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) if (flags & TDF_LINENO) { gimple_stmt_iterator gsi; - char *s_indent = (char *) alloca ((size_t) indent + 1); - memset (s_indent, ' ', (size_t) indent); - s_indent[indent] = '\0'; if (flags & TDF_COMMENT)