From patchwork Mon Jan 28 14:09:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 216217 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 8B9962C0084 for ; Tue, 29 Jan 2013 01:16:32 +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=1359987392; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=0zQW7Z1fyZG2i2NHb8To c7n3cpQ=; b=UcowSJ28/IIoRVRk2ZS6hJicczKwjR7Mevj1ShPClDUxpRyA4FDC Seomy0/2VtfJpvtDC01TVyzKgcjrfriqWE3oK2jHGduTj/BKNn4Pj/v+tu+L7ux2 oAOeJqW9P+IRVC2mBZyee8DCrLSZfs6iqaar+q/dLZir30FBwlBvFmg= 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:Received:Received:Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=kZ/UFjsc+8Y/YZSUVWem22Z3B9L9td06kuxFi59PYqXgBnUQEpFGRRfMDDeYSb dX4iC/Ko2FclEwIHhc1NElkc7mcISLcSEP1KCLQXHj9S2ctZ4ivsynEJTfp6iumm oGp/A7B8YYOpyHMbkmQpxa5uboCBjh7DbJRYZkHKa5DPY=; Received: (qmail 9067 invoked by alias); 28 Jan 2013 14:16:25 -0000 Received: (qmail 9056 invoked by uid 22791); 28 Jan 2013 14:16:23 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM, TW_TX X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 28 Jan 2013 14:16:11 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0SEGBXf026839 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 28 Jan 2013 09:16:11 -0500 Received: from zalov.redhat.com (vpn1-6-106.ams2.redhat.com [10.36.6.106]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0SEAC5N025316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 28 Jan 2013 09:10:15 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id r0SEABqO017673 for ; Mon, 28 Jan 2013 15:10:11 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r0SEA4VZ017668 for gcc-patches@gcc.gnu.org; Mon, 28 Jan 2013 15:10:04 +0100 Date: Mon, 28 Jan 2013 15:09:44 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Avoid setting gimple_location of force_gimple_operand* created stmts to DECL_SOURCE_LOCATION of current fn (PR tree-optimization/56094) Message-ID: <20130128140943.GF4385@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi! As discussed in the PR, this is a safer variant of a fix for 4.8, where input_location during most optimization passes is set to DECL_SOURCE_LOCATION (current_function_decl) and various parts of the gimplifier e.g. during force_gimple_operand* may end up setting gimple_location to that. For 4.9, we should revert this and set input_location to UNKNOWN_LOCATION for the optimizers. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2013-01-28 Jakub Jelinek PR tree-optimization/56094 * gimplify.c (force_gimple_operand_1): Temporarily set input_location to UNKNOWN_LOCATION while gimplifying expr. * gcc.dg/pr56094.c: New test. Jakub --- gcc/gimplify.c.jj 2013-01-25 21:02:45.000000000 +0100 +++ gcc/gimplify.c 2013-01-28 11:34:15.671374132 +0100 @@ -8600,6 +8600,7 @@ force_gimple_operand_1 (tree expr, gimpl { enum gimplify_status ret; struct gimplify_ctx gctx; + location_t saved_location; *stmts = NULL; @@ -8613,6 +8614,8 @@ force_gimple_operand_1 (tree expr, gimpl push_gimplify_context (&gctx); gimplify_ctxp->into_ssa = gimple_in_ssa_p (cfun); gimplify_ctxp->allow_rhs_cond_expr = true; + saved_location = input_location; + input_location = UNKNOWN_LOCATION; if (var) { @@ -8634,6 +8637,7 @@ force_gimple_operand_1 (tree expr, gimpl gcc_assert (ret != GS_ERROR); } + input_location = saved_location; pop_gimplify_context (NULL); return expr; --- gcc/testsuite/gcc.dg/pr56094.c.jj 2013-01-28 11:46:09.045221238 +0100 +++ gcc/testsuite/gcc.dg/pr56094.c 2013-01-28 11:47:54.052611852 +0100 @@ -0,0 +1,81 @@ +/* PR tree-optimization/56094 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fdump-tree-optimized-lineno" } */ + +_Bool cond; + +int +fn0 (unsigned char, unsigned long long, unsigned char, + unsigned char, signed short, unsigned int, + unsigned char *); + +extern void fn3 (unsigned char, unsigned char, unsigned char, unsigned char, + unsigned char, unsigned char, unsigned char, unsigned short); +extern void fn7 (int); +extern void fn8 (int); + +static __inline__ __attribute__ ((always_inline)) void +fn1 (unsigned char arg0, unsigned char arg1, unsigned char arg2, + unsigned char arg3, unsigned char arg4, unsigned char arg5, + unsigned short arg6) +{ + asm volatile ("" :: "g" ((unsigned long long) arg0), "g" (arg1), + "g" (arg2), "g" (arg3), "g" (arg4), "g" (arg5), + "g" (arg6)); + if (cond) + { + unsigned char loc0 = 0; + fn3 (loc0, arg0, arg1, arg2, arg3, arg4, arg5, arg6); + } +} + +static __inline__ __attribute__ ((always_inline)) void +fn4 (unsigned int arg0, unsigned long long arg1) +{ + asm volatile ("" :: "g" (arg0), "g" (arg1)); +} + +static __inline__ __attribute__ ((always_inline)) void +fn5 (unsigned int arg0, unsigned char arg1, unsigned int arg2, + unsigned char arg3) +{ + asm volatile ("" :: "g" (arg0), "g" (arg1), + "g" ((unsigned long long) arg2), "g" (arg3)); +} + +static __inline__ __attribute__ ((always_inline)) void +fn6 (unsigned long long arg0, unsigned char arg1, + unsigned char arg2, signed short arg3, + unsigned int arg4, unsigned char * arg5) +{ + asm volatile ("" :: "g" (arg0), "g" ((unsigned long long) arg1), + "g" ((unsigned long long) arg2), "g" (arg3), + "g" (arg4), "g" (arg5)); + if (cond) + { + unsigned char loc0 = 0; + fn0 (loc0, arg0, arg1, arg2, arg3, arg4, arg5); + } +} + +unsigned char b[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa }; +unsigned int q = sizeof (b) / sizeof (b[0]); + +void +foo () +{ + int i; + for (i = 1; i <= 50; i++) + { + fn6 (i + 0x1234, i + 1, i + 0xa, i + 0x1234, q, b); + fn5 (i + 0xabcd, i << 1, i + 0x1234, i << 2); + fn7 (i + 0xdead); + fn8 (i + 0xdead); + fn1 (i, i + 1, i + 2, i + 3, i + 4, i + 5, i << 10); + fn4 (i + 0xfeed, i); + } +} + +/* Verify no statements get the location of the foo () decl. */ +/* { dg-final { scan-tree-dump-not " : 65:1\\\]" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */