From patchwork Tue Dec 3 22:36:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 296343 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 B257F2C009F for ; Wed, 4 Dec 2013 09:36:35 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=b60638WLOpbN46dl4kqRxRLrTVRrc 3SpBRrkfVgGzmd1rNzTrIiUHi01Cf2Hw/2uAM6oQnwFUjEJdhItw7ZTJZWlaht6p WKAogBCiwKHB5X5zL5vEH8whjqcfny/MKnf7u4I3y1MW5sb46zF356KMi+tF/nKx UR1DveJfR7J0Js= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=hqZdXE0jkUu1DWKwBDPPQseu1qo=; b=yRi 8Us8VLg0SzUrlhAwjQctPL/thKIzpgaZf6mAa5fWEn3jZTXCA/EwyoRHRwP05hlb 9qoX2g7F7zioBUEqvm7pK6ehQ4hptF3yCNdHrNXYNEva/+WEd6MqhRxRzjo+4xTR zSYkf+Zc6LBF0PIzUg+L/cu/Vm2YFASSn7HBCt2E= Received: (qmail 23216 invoked by alias); 3 Dec 2013 22:36:24 -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 23206 invoked by uid 89); 3 Dec 2013 22:36:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 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; Tue, 03 Dec 2013 22:36:22 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB3MaFAb024618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Dec 2013 17:36:15 -0500 Received: from tucnak.zalov.cz (vpn1-4-53.ams2.redhat.com [10.36.4.53]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB3MaDCl024894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Dec 2013 17:36:14 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.7/8.14.7) with ESMTP id rB3MaCgX001260; Tue, 3 Dec 2013 23:36:12 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.7/8.14.7/Submit) id rB3MaCo6001259; Tue, 3 Dec 2013 23:36:12 +0100 Date: Tue, 3 Dec 2013 23:36:12 +0100 From: Jakub Jelinek To: Richard Biener , Jan Hubicka Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Don't ICE with -fno-devirtualize (PR tree-optimization/59355) Message-ID: <20131203223612.GF892@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 Hi! ipa_devirt apparently relies on -fdevirtualize, but -fno-devirtualize doesn't turn off -fdevirtualize-speculatively. I've tried to make it a 3 state option, but then while -O2 implied flag_devirtualize == 2 (i.e. normal + speculative), -O2 -fdevirtualize would imply flag_devirtualize == 1, which is IMHO undesirable, so I went for ignoring -fdevirtualize-speculatively if -fdevirtualize is not on. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-12-03 Jakub Jelinek PR tree-optimization/59355 * ipa-devirt.c (gate_ipa_devirt): Return false if !flag_devirtualize. * opts.c (common_handle_option): Fix comment spelling. * g++.dg/ipa/pr59355.C: New test. Jakub --- gcc/ipa-devirt.c.jj 2013-12-03 15:02:12.000000000 +0100 +++ gcc/ipa-devirt.c 2013-12-03 15:03:01.176455678 +0100 @@ -1591,12 +1591,14 @@ ipa_devirt (void) return ndevirtualized ? TODO_remove_functions : 0; } -/* Gate for IPCP optimization. */ +/* Gate for speculative IPA devirtualization optimization. */ static bool gate_ipa_devirt (void) { - return flag_devirtualize_speculatively && optimize; + return (flag_devirtualize + && flag_devirtualize_speculatively + && optimize); } namespace { --- gcc/opts.c.jj 2013-12-03 15:02:12.000000000 +0100 +++ gcc/opts.c 2013-12-03 15:03:39.693285001 +0100 @@ -1709,7 +1709,7 @@ common_handle_option (struct gcc_options if (!opts_set->x_flag_tree_loop_distribute_patterns) opts->x_flag_tree_loop_distribute_patterns = value; /* Indirect call profiling should do all useful transformations - speculative devirutalization does. */ + speculative devirtualization does. */ if (!opts_set->x_flag_devirtualize_speculatively && opts->x_flag_value_profile_transformations) opts->x_flag_devirtualize_speculatively = false; --- gcc/testsuite/g++.dg/ipa/pr59355.C.jj 2013-12-03 15:28:38.430518411 +0100 +++ gcc/testsuite/g++.dg/ipa/pr59355.C 2013-12-03 15:22:32.000000000 +0100 @@ -0,0 +1,14 @@ +// PR tree-optimization/59355 +// { dg-do compile } +// { dg-options "-O2 -fno-devirtualize" } + +struct S +{ + virtual void bar (); +}; + +void +foo (S *s) +{ + s->bar (); +}