From patchwork Thu Dec 22 19:47:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 132894 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 25C6EB6F9A for ; Fri, 23 Dec 2011 06:47:40 +1100 (EST) Received: (qmail 25041 invoked by alias); 22 Dec 2011 19:47:38 -0000 Received: (qmail 25033 invoked by uid 22791); 22 Dec 2011 19:47:37 -0000 X-SWARE-Spam-Status: No, hits=-7.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Thu, 22 Dec 2011 19:47:24 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBMJlO6s031086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 22 Dec 2011 14:47:24 -0500 Received: from houston.quesejoda.com (vpn-10-145.rdu.redhat.com [10.11.10.145]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBMJlNKX012728; Thu, 22 Dec 2011 14:47:23 -0500 Message-ID: <4EF3894B.5050504@redhat.com> Date: Thu, 22 Dec 2011 13:47:23 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: Richard Henderson , Torvald Riegel , gcc-patches Subject: PR middle-end/51212: sorry out on -fgnu-tm + -fnon-call-exceptions 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 The problem here is that with -fnon-call-exceptions, a memory dereference may trap, but when we instrument the store, we have lost the landing pad information. One solution would be to move the EH information to the TM load/store instrumentation builtins, but that doesn't get us around the fact that libitm is not exception safe, and we have no mechanism for taking and exception (and propagating it) in the middle of a transaction. Richard has suggested that another alternative could be to support the exception case for NULL, but non-null faulting memory references would still cause a crash. In this case we would simply test for NULL at the start of the accessors and explicitly throw the exception. And yet a third alternative, is to disable the -fgnu-tm and -fnon-call-exceptions combination. I have implemented this one, as I'd rather have it not work, than work half-way. Torvald, do you have any thoughts on the matter? Attached patch for disabling the feature, if you both agree on this approach. PR middle-end/51212 * opts.c (finish_options): Call sorry on -fgnu-tm and -fnon-call-exception combination. Index: testsuite/g++.dg/tm/pr51212.C =================================================================== --- testsuite/g++.dg/tm/pr51212.C (revision 0) +++ testsuite/g++.dg/tm/pr51212.C (revision 0) @@ -0,0 +1,19 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -fnon-call-exceptions" } + +struct S +{ + S () + { + } +}; + +__attribute__ ((transaction_callable)) +void foo (int *p) +{ + S s; + if (*p) + ; +} + +// { dg-message "sorry, unimplemented: non call exceptions and transactional memory" "-fnon-call-exceptions and -fgnu-tm together" { target *-*-* } 0 } Index: opts.c =================================================================== --- opts.c (revision 182542) +++ opts.c (working copy) @@ -663,6 +663,9 @@ finish_options (struct gcc_options *opts opts->x_flag_toplevel_reorder = 0; } + if (opts->x_flag_tm && opts->x_flag_non_call_exceptions) + sorry ("non call exceptions and transactional memory are not supported"); + /* -Wmissing-noreturn is alias for -Wsuggest-attribute=noreturn. */ if (opts->x_warn_missing_noreturn) opts->x_warn_suggest_attribute_noreturn = true;