From patchwork Sat Nov 17 12:25:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 199846 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 1D6532C007A for ; Sat, 17 Nov 2012 23:25:48 +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=1353759949; 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=mPMCA3/Kc0ehhX0PBbgO 5QKgcGw=; b=U921OYSzC6n38XIP8MR+3UjdhHwWWPYRaSi17RhC2kC6+bqvXgou dSO7HDgqtxApN6LzSa4bM8DhDPcFrdPw3SMTDzft0986OVowduwJKJAuWdFZrG33 qnlNtjPuv1oG+9dnWP3woX6yHZB9M3TaFajjREHpQ6mTRGg0cH1BUs4= 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=iGxkv2W5fWWTkKboI6fAuq2wIAqDQDVUcCpKXSOC4yF12OHatfkbOrX4UVAbOK VBKFiqHZGHsuMMxTDElhVQWaCaA0f7pc3/dqRi7BFA9RCtlq+p7RjecZYS8AQq+7 YXg5FwDFHDb9lZuly3qRyw5ZS7mnQE0PwEVFOlg6Qx5c0=; Received: (qmail 3784 invoked by alias); 17 Nov 2012 12:25:38 -0000 Received: (qmail 3763 invoked by uid 22791); 17 Nov 2012 12:25:36 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CP 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; Sat, 17 Nov 2012 12:25:25 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAHCPOIj023807 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 17 Nov 2012 07:25:24 -0500 Received: from zalov.redhat.com (vpn1-5-234.ams2.redhat.com [10.36.5.234]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAHCPMJ5014611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 17 Nov 2012 07:25:24 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qAHCPMpi032435; Sat, 17 Nov 2012 13:25:22 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qAHCPLE5032434; Sat, 17 Nov 2012 13:25:21 +0100 Date: Sat, 17 Nov 2012 13:25:21 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH] Fix up builtin memcpy calls generated by Fortran FE (PR fortran/55341) Message-ID: <20121117122521.GL1886@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! This PR is about ASAN failing with checking failures. The problem is on the Fortran FE side, which calls BUILT_IN_MEMCPY sometimes with wrong type of the last argument (which is not type compatible with the size_type_node type). Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-11-17 Jakub Jelinek PR fortran/55341 * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Convert last argument to memcpy to size_type_node type. * trans-stmt.c (gfc_conv_elemental_dependencies): Likewise. * trasn-array.c (duplicate_allocatable): Likewise. Jakub --- gcc/fortran/trans-intrinsic.c.jj 2012-11-06 12:21:17.000000000 +0100 +++ gcc/fortran/trans-intrinsic.c 2012-11-16 11:48:14.111974090 +0100 @@ -5600,14 +5600,16 @@ gfc_conv_intrinsic_transfer (gfc_se * se tmp = fold_convert (pvoid_type_node, tmp); /* Use memcpy to do the transfer. */ - tmp = build_call_expr_loc (input_location, - builtin_decl_explicit (BUILT_IN_MEMCPY), - 3, - tmp, - fold_convert (pvoid_type_node, source), - fold_build2_loc (input_location, MIN_EXPR, - gfc_array_index_type, - size_bytes, source_bytes)); + tmp + = build_call_expr_loc (input_location, + builtin_decl_explicit (BUILT_IN_MEMCPY), 3, tmp, + fold_convert (pvoid_type_node, source), + fold_convert (size_type_node, + fold_build2_loc (input_location, + MIN_EXPR, + gfc_array_index_type, + size_bytes, + source_bytes))); gfc_add_expr_to_block (&se->pre, tmp); se->expr = info->descriptor; @@ -5649,7 +5651,7 @@ scalar_transfer: builtin_decl_explicit (BUILT_IN_MEMCPY), 3, fold_convert (pvoid_type_node, tmpdecl), fold_convert (pvoid_type_node, ptr), - extent); + fold_convert (size_type_node, extent)); gfc_add_expr_to_block (&block, tmp); indirect = gfc_finish_block (&block); @@ -5687,7 +5689,7 @@ scalar_transfer: builtin_decl_explicit (BUILT_IN_MEMCPY), 3, fold_convert (pvoid_type_node, tmp), fold_convert (pvoid_type_node, ptr), - extent); + fold_convert (size_type_node, extent)); gfc_add_expr_to_block (&se->pre, tmp); /* For CLASS results, set the _vptr. */ --- gcc/fortran/trans-stmt.c.jj 2012-10-17 17:18:21.000000000 +0200 +++ gcc/fortran/trans-stmt.c 2012-11-16 11:45:26.608192584 +0100 @@ -337,7 +337,8 @@ gfc_conv_elemental_dependencies (gfc_se tmp = gfc_conv_descriptor_data_get (tmp); tmp = build_call_expr_loc (input_location, builtin_decl_explicit (BUILT_IN_MEMCPY), - 3, tmp, data, size); + 3, tmp, data, + fold_convert (size_type_node, size)); } gfc_add_expr_to_block (&se->post, tmp); --- gcc/fortran/trans-array.c.jj 2012-11-01 09:33:28.000000000 +0100 +++ gcc/fortran/trans-array.c 2012-11-16 11:49:46.875541899 +0100 @@ -7341,8 +7341,8 @@ duplicate_allocatable (tree dest, tree s } tmp = builtin_decl_explicit (BUILT_IN_MEMCPY); - tmp = build_call_expr_loc (input_location, tmp, 3, - dest, src, size); + tmp = build_call_expr_loc (input_location, tmp, 3, dest, src, + fold_convert (size_type_node, size)); } else { @@ -7367,7 +7367,8 @@ duplicate_allocatable (tree dest, tree s tmp = builtin_decl_explicit (BUILT_IN_MEMCPY); tmp = build_call_expr_loc (input_location, tmp, 3, gfc_conv_descriptor_data_get (dest), - gfc_conv_descriptor_data_get (src), size); + gfc_conv_descriptor_data_get (src), + fold_convert (size_type_node, size)); } gfc_add_expr_to_block (&block, tmp);