From patchwork Thu Dec 12 23:09:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 300810 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 82A6E2C0091 for ; Fri, 13 Dec 2013 10:10:03 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=e1hEXiRKOxOCTDIkPtwJGcdnypDEaOmChvrML4amK9t aiYaESWNIBWaCZwe1kbSlubBGUCbIVE1KyEZs5SSlufL33p0517/vo+FzNGeUFvy EVnp8cynb+TPbwQQjvc4eRutXSZC/BuGuLvFuhZ188onqswfpbuecLpgKwM7I7As = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=ldYkgUlRpul9+JM0JON89zvZe0c=; b=ixpaJrWfXUroPrXbU Rtj7EPWhhpUYa4VK7T5fYGU94dnxL2G+gG9KZoQLgxC5Bvjlk8FBm1GGtHjFwtMM odHcMGS7PcRnWuFnui72aHtWM7sNOfuiRh7s8o7DZGewPm1jV2UN+J0gjxNHjafc 6faM/xcTmUcRGfsc6M53b6LRjk= Received: (qmail 15519 invoked by alias); 12 Dec 2013 23:09:55 -0000 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 Received: (qmail 15502 invoked by uid 89); 12 Dec 2013 23:09:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Dec 2013 23:09:53 +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 rBCN9p0C016755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 12 Dec 2013 18:09:51 -0500 Received: from reynosa.quesejoda.com (vpn-59-232.rdu2.redhat.com [10.10.59.232]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rBCN9mWW017201; Thu, 12 Dec 2013 18:09:49 -0500 Message-ID: <52AA423C.9050808@redhat.com> Date: Thu, 12 Dec 2013 15:09:48 -0800 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Richard Biener CC: gcc-patches , glisse@gcc.gnu.org Subject: [PR tree-optimization/59149] fail on invalid arguments to flags_from_decl_or_type flags_from_decl_or_type() only handles a TYPE or DECL. Make this explicit instead. I also added a check in the use in trans-mem.c, just in case. The subsequent conditionals should take care of the TM case. It would be nice if Marc Glisse could provide the testcase he mentioned was failing. Either way, the attached patch doesn't hurt. Tested on x86-64 Linux. OK? commit b5830c04f011d6885e3a09f50602b8f5f495a408 Author: Aldy Hernandez Date: Mon Dec 9 08:10:44 2013 -0800 PR tree-optimization/59149 * calls.c (flags_from_decl_or_type): Fail on non decl or type. * trans-mem.c (diagnose_tm_1): Do not call flags_from_decl_or_type if no type or decl. diff --git a/gcc/calls.c b/gcc/calls.c index 3963bc2..2226e78 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -769,6 +769,8 @@ flags_from_decl_or_type (const_tree exp) || lookup_attribute ("transaction_pure", TYPE_ATTRIBUTES (exp)))) flags |= ECF_TM_PURE; } + else + gcc_unreachable (); if (TREE_THIS_VOLATILE (exp)) { diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index b2adc3d..1603d82 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -677,7 +677,8 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p, } else if (direct_call_p) { - if (flags_from_decl_or_type (fn) & ECF_TM_BUILTIN) + if (IS_TYPE_OR_DECL_P (fn) + && flags_from_decl_or_type (fn) & ECF_TM_BUILTIN) is_safe = true; else if (replacement) {