From patchwork Wed Nov 6 06:15:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 288728 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 0A59C2C00BD for ; Wed, 6 Nov 2013 17:15:52 +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:subject:content-type; q= dns; s=default; b=nUqbbtq0dUomXsnv7vEGlvmorQXrk5qfVPNezDk4nkLpyn oveSnG25SNjSLAscV7Bbc815Huwvp7sjx4rbNNhbqEPtNkILsrjcllJrU3pV2Ws1 qFeZ7TI192cvbBMCwDXRl5ooHYLLgUh3gO+hwr/tk0YUytW1Wiq41C/34fIMo= 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:subject:content-type; s= default; bh=aYurCer7EVuJeKr1nqV4az+wKCo=; b=jMb/+oqfn+JGmVbbJa3l jAl6RiZSKJgTuGdsj4wXxXD8v0rf8xXa3f4mi2cBBOSM0eTp/6BNmKedK0UxrK+l uC1QkMX6pdcNycimkqN/4C5fep9zhvA4tJASIFz5TEyk2zG9auSL0V2Dm7tnMPf/ fJ2hHYRn4zct25nkucmgr/c= Received: (qmail 8900 invoked by alias); 6 Nov 2013 06:15:41 -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 8891 invoked by uid 89); 6 Nov 2013 06:15:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Nov 2013 06:15:38 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA66FVuv032283 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Nov 2013 01:15:31 -0500 Received: from stumpy.slc.redhat.com (ovpn-113-132.phx2.redhat.com [10.3.113.132]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rA66FUnp015441 for ; Wed, 6 Nov 2013 01:15:31 -0500 Message-ID: <5279DE82.1040703@redhat.com> Date: Tue, 05 Nov 2013 23:15:30 -0700 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gcc-patches Subject: [RFA][PATCH] Minor erroneous path isolation followups X-IsSubscribed: yes Per a discussion between Richi and myself, this patch adds a __builtin_trap to the Java front end. If someone could look at that code closely to ensure I didn't muck it up, I'd appreciated it. With that code in the Java front-end, we can remove the hack from gate_isolate_erroneous_paths. Finally, Ian noticed I didn't update invoke.texi. For some silly reason I thought we'd get that from the various option definition files. Bootstrapped and regression tested on x86_64-unknown-linux-gnu. OK for the trunk? * doc/invoke.texi (-fisolate-erroneous-paths): Document. * gimple-ssa-isolate-paths.c (gate_isolate_erroneous_paths): No longer check if we have __builtin_trap, assume it's available. * java/builtins.c (initialize_builtins): Provide __builtin_trap. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 35f41d9..8fbe8ab 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -377,6 +377,7 @@ Objective-C and Objective-C++ Dialects}. -fira-region=@var{region} -fira-hoist-pressure @gol -fira-loop-pressure -fno-ira-share-save-slots @gol -fno-ira-share-spill-slots -fira-verbose=@var{n} @gol +-fisolate-erroneous-paths @gol -fivopts -fkeep-inline-functions -fkeep-static-consts @gol -floop-block -floop-interchange -floop-strip-mine -floop-nest-optimize @gol -floop-parallelize-all -flto -flto-compression-level @gol @@ -6735,6 +6736,7 @@ also turns on the following optimization flags: -finline-small-functions @gol -findirect-inlining @gol -fipa-sra @gol +-fisolate-erroneous-paths @gol -foptimize-sibling-calls @gol -fpartial-inlining @gol -fpeephole2 @gol @@ -7622,6 +7624,11 @@ it may significantly increase code size (see @option{--param ipcp-unit-growth=@var{value}}). This flag is enabled by default at @option{-O3}. +@item -fisolate-erroneous-paths +Detect paths which trigger erroneous or undefined behaviour. Isolate those +paths from the main control flow and turn the statement with erroneous or +undefined behaviour into a trap. + @item -ftree-sink @opindex ftree-sink Perform forward store motion on trees. This flag is diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index 4868867..983ed4d 100644 --- a/gcc/gimple-ssa-isolate-paths.c +++ b/gcc/gimple-ssa-isolate-paths.c @@ -283,8 +283,7 @@ gate_isolate_erroneous_paths (void) { /* If we do not have a suitable builtin function for the trap statement, then do not perform the optimization. */ - return (flag_isolate_erroneous_paths != 0 - && builtin_decl_explicit (BUILT_IN_TRAP) != NULL); + return (flag_isolate_erroneous_paths != 0); } namespace { diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index f971a6f..c8de217 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -580,6 +580,9 @@ initialize_builtins (void) build_function_type_list (ptr_type_node, int_type_node, NULL_TREE), "__builtin_return_address", ECF_NOTHROW | ECF_LEAF); + define_builtin (BUILT_IN_TRAP, "__builtin_trap", + build_function_type_list (void_type_node, NULL_TREE), + "__builtin_trap", ECF_NOTHROW | ECF_LEAF); build_common_builtin_nodes (); }