From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27208 invoked by alias); 8 Nov 2011 13:43:10 -0000 Received: (qmail 27066 invoked by uid 22791); 8 Nov 2011 13:43:05 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00,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; Tue, 08 Nov 2011 13:42:49 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id A21AE89994; Tue, 8 Nov 2011 14:42:47 +0100 (CET) Date: Tue, 08 Nov 2011 14:00:00 -0000 From: Richard Guenther To: "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix PR50999, serialize frontend specific flags (-fexceptions) In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg01184.txt.bz2 On Tue, 8 Nov 2011, Joseph S. Myers wrote: > On Mon, 7 Nov 2011, Richard Guenther wrote: > > > Joseph, do you have any advise on how to address frontend specific > > options in a more general way? I'm trying to re-construct a > > command-line that when processed frontend agnostic would produce > > the same end-result in global_options as if going through the frontend. > > Is that even possible (do you have option examples that would show > > this is impossible?) > > Reconstructing command lines is never going to be particularly reliable. > I think the short-term fix will be saving these particular options > explicitly, and the longer-term fix will be representing them (anything > affecting IR semantics rather than just what IR gets generated) in the IR > so that once the front end is finished the global settings never get used. > (That doesn't mean moving them all to the individual GIMPLE operations, > although for complex-method that would be the best location; moving them > to struct function, with appropriate code to stream the new fields and do > whatever's appropriate when inlining between functions with different > settings, would still be useful.) Ok, yes - that's the general direction. I've modified the patch to use global_options again and checked in the following. Bootstrapped and tested on x86_64-unknown-linux-gnu. Richard. 2011-11-08 Richard Guenther PR lto/50999 * lto-opts.c (append_to_collect_gcc_options): Split out from... (lto_write_options): ... here. Prepend frontend specific flags. Index: gcc/lto-opts.c =================================================================== *** gcc/lto-opts.c (revision 181150) --- gcc/lto-opts.c (working copy) *************** along with GCC; see the file COPYING3. *** 35,40 **** --- 35,63 ---- #include "lto-streamer.h" #include "toplev.h" + /* Append the option piece OPT to the COLLECT_GCC_OPTIONS string + set up by OB, appropriately quoted and separated by spaces + (if !*FIRST_P). */ + + static void + append_to_collect_gcc_options (struct obstack *ob, + bool *first_p, const char *opt) + { + const char *p, *q = opt; + if (!first_p) + obstack_grow (ob, " ", 1); + obstack_grow (ob, "'", 1); + while ((p = strchr (q, '\''))) + { + obstack_grow (ob, q, p - q); + obstack_grow (ob, "'\\''", 4); + q = ++p; + } + obstack_grow (ob, q, strlen (q)); + obstack_grow (ob, "'", 1); + *first_p = false; + } + /* Write currently held options to an LTO IL section. */ void *************** lto_write_options (void) *** 45,60 **** struct obstack temporary_obstack; unsigned int i, j; char *args; section_name = lto_get_section_name (LTO_section_opts, NULL, NULL); lto_begin_section (section_name, false); memset (&stream, 0, sizeof (stream)); obstack_init (&temporary_obstack); for (i = 1; i < save_decoded_options_count; ++i) { struct cl_decoded_option *option = &save_decoded_options[i]; - const char *q, *p; /* Skip frontend and driver specific options here. */ if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO))) --- 68,97 ---- struct obstack temporary_obstack; unsigned int i, j; char *args; + bool first_p = true; section_name = lto_get_section_name (LTO_section_opts, NULL, NULL); lto_begin_section (section_name, false); memset (&stream, 0, sizeof (stream)); obstack_init (&temporary_obstack); + + /* Output options that affect GIMPLE IL semantics and are implicitely + enabled by the frontend. + This for now includes an explicit set of options that we also handle + explicitly in lto-wrapper.c. In the end the effects on GIMPLE IL + semantics should be explicitely encoded in the IL or saved per + function rather than per compilation unit. */ + /* -fexceptions causes the EH machinery to be initialized, enabling + generation of unwind data so that explicit throw() calls work. */ + if (global_options.x_flag_exceptions) + append_to_collect_gcc_options (&temporary_obstack, &first_p, + "-fexceptions"); + + /* Output explicitely passed options. */ for (i = 1; i < save_decoded_options_count; ++i) { struct cl_decoded_option *option = &save_decoded_options[i]; /* Skip frontend and driver specific options here. */ if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO))) *************** lto_write_options (void) *** 82,113 **** break; } ! if (i != 1) ! obstack_grow (&temporary_obstack, " ", 1); ! obstack_grow (&temporary_obstack, "'", 1); ! q = option->canonical_option[0]; ! while ((p = strchr (q, '\''))) ! { ! obstack_grow (&temporary_obstack, q, p - q); ! obstack_grow (&temporary_obstack, "'\\''", 4); ! q = ++p; ! } ! obstack_grow (&temporary_obstack, q, strlen (q)); ! obstack_grow (&temporary_obstack, "'", 1); ! ! for (j = 1; j < option->canonical_option_num_elements; ++j) ! { ! obstack_grow (&temporary_obstack, " '", 2); ! q = option->canonical_option[j]; ! while ((p = strchr (q, '\''))) ! { ! obstack_grow (&temporary_obstack, q, p - q); ! obstack_grow (&temporary_obstack, "'\\''", 4); ! q = ++p; ! } ! obstack_grow (&temporary_obstack, q, strlen (q)); ! obstack_grow (&temporary_obstack, "'", 1); ! } } obstack_grow (&temporary_obstack, "\0", 1); args = XOBFINISH (&temporary_obstack, char *); --- 119,127 ---- break; } ! for (j = 0; j < option->canonical_option_num_elements; ++j) ! append_to_collect_gcc_options (&temporary_obstack, &first_p, ! option->canonical_option[j]); } obstack_grow (&temporary_obstack, "\0", 1); args = XOBFINISH (&temporary_obstack, char *);