From patchwork Mon Jan 23 10:44:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 137343 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 754961007D1 for ; Mon, 23 Jan 2012 21:44:31 +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=1327920272; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=Z/sMDWOad6EryAU4pm9M sfQ/CbI=; b=dm7JpzZe99sT7LqCNVyM7WnHWLTMANaUlGHDgq7YGykr30Al8R8m CgVYxvOXnXlsLu+x6f0Pq6E1p5IU/bOMQHZcTqPxNSFkvY6MnSPiHViTV+TO7MKM M+MKjlZGy6qRQi8WaPa3IxnYFhGqQEYzDpYpfLi8/5TDo6zPKwOLthw= 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:Date:From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=deLdtH80bx2tj7pg6WXqxy+kaDqDj80oye1rRcpJ2U/eXF8i7Ol8jCc4mIcm2N jTFFjWbbhX0g+9JD+6iFRvJEQO0vkevmpXrSAui5TygDiyY7D8RuX6m6Pmm97ekz ns+t+8dMDXs7LLzv3TINV/vo6ye6dcGRlBWcZItpTikMk=; Received: (qmail 29113 invoked by alias); 23 Jan 2012 10:44:28 -0000 Received: (qmail 29104 invoked by uid 22791); 23 Jan 2012 10:44:27 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 10:44:14 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id EAD7D8891E for ; Mon, 23 Jan 2012 11:44:13 +0100 (CET) Date: Mon, 23 Jan 2012 11:44:13 +0100 (CET) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR51949 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 We ICE when splitting part of a function which has the malloc attribute and that part does not return. While the issue is more general (transfering attributes to a part/clone) we can address this probably common issue with the following simple patch. Richard. 2012-01-23 Richard Guenther PR tree-optimization/51949 * ipa-split.c (execute_split_functions): Do not split malloc functions. * gcc.dg/torture/pr51949.c: New testcase. Index: gcc/ipa-split.c =================================================================== --- gcc/ipa-split.c (revision 183421) +++ gcc/ipa-split.c (working copy) @@ -1395,10 +1395,11 @@ execute_split_functions (void) int todo = 0; struct cgraph_node *node = cgraph_get_node (current_function_decl); - if (flags_from_decl_or_type (current_function_decl) & ECF_NORETURN) + if (flags_from_decl_or_type (current_function_decl) + & (ECF_NORETURN|ECF_MALLOC)) { if (dump_file) - fprintf (dump_file, "Not splitting: noreturn function.\n"); + fprintf (dump_file, "Not splitting: noreturn/malloc function.\n"); return 0; } if (MAIN_NAME_P (DECL_NAME (current_function_decl))) Index: gcc/testsuite/gcc.dg/torture/pr51949.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr51949.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr51949.c (revision 0) @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +typedef long unsigned int size_t; +extern __attribute__ ((malloc)) void *mem_alloc(size_t); +void *mem_alloc(size_t amount) +{ + void *q = __builtin_malloc (amount); + if (!q) { + __builtin_printf("malloc"); + __builtin_exit(255); + } +} +void mem_realloc() +{ + mem_alloc(1); +} +void put_env_var() +{ + mem_alloc(1); +}