From patchwork Thu May 5 05:36:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang David Li X-Patchwork-Id: 94201 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 C86FDB6FCC for ; Thu, 5 May 2011 15:36:45 +1000 (EST) Received: (qmail 25157 invoked by alias); 5 May 2011 05:36:44 -0000 Received: (qmail 25040 invoked by uid 22791); 5 May 2011 05:36:42 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 05 May 2011 05:36:26 +0000 Received: from wpaz1.hot.corp.google.com (wpaz1.hot.corp.google.com [172.24.198.65]) by smtp-out.google.com with ESMTP id p455aPR2025791; Wed, 4 May 2011 22:36:25 -0700 Received: from syzygy.mtv.corp.google.com (syzygy.mtv.corp.google.com [172.18.116.118]) by wpaz1.hot.corp.google.com with ESMTP id p455aOpk018377; Wed, 4 May 2011 22:36:25 -0700 Received: by syzygy.mtv.corp.google.com (Postfix, from userid 74076) id 8A74C205D4; Wed, 4 May 2011 22:36:24 -0700 (PDT) To: reply@codereview.appspotmail.com, gcc-patches@gcc.gnu.org Subject: [google] improves option mismatch handling for LIPO (issue4479045) Message-Id: <20110505053624.8A74C205D4@syzygy.mtv.corp.google.com> Date: Wed, 4 May 2011 22:36:24 -0700 (PDT) From: davidxl@google.com (David Li) X-System-Of-Record: true X-IsSubscribed: yes 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 This patch improves cross module option mismatch handling in LIPO mode -- will be commited to google/main. 1) Remove duplicates in the option list before comparison; 2) Force module incompatiblity when two modules disagree in -fexceptions setting. In LIPO mode, when option mismatch is discovered between the primary and aux module, a warning message is emitted, but the modules will be considered incompatible when -fripa-disallow-opt-mismatch is specified. With this change, exception option mismatch will force the primary module to reject the aux module. Tested: SPEC with LIPO. 2011-05-04 David Li * coverage.c (incompatible_cl_args): Better handling of option mismatch. --- This patch is available for review at http://codereview.appspot.com/4479045 Index: coverage.c =================================================================== --- coverage.c (revision 173353) +++ coverage.c (working copy) @@ -213,6 +213,27 @@ is_last_module (unsigned mod_id) return (mod_id == module_infos[num_in_fnames - 1]->ident); } +/* String hash function */ + +static hashval_t +str_hash (const void *p) +{ + const char *s = (const char *)p; + return htab_hash_string (s); +} + +/* String equal function */ + +static int +str_eq (const void *p1, const void *p2) +{ + const char *s1 = (const char *)p1; + const char *s2 = (const char *)p2; + + return !strcmp (s1, s2); +} + + /* Returns true if the command-line arguments stored in the given module-infos are incompatible. */ static bool @@ -227,6 +248,9 @@ incompatible_cl_args (struct gcov_module unsigned int num_non_warning_opts1 = 0, num_non_warning_opts2 = 0; bool warning_mismatch = false; bool non_warning_mismatch = false; + bool with_fexceptions1 = true; + bool with_fexceptions2 = true; + htab_t option_tab1, option_tab2; unsigned int start_index1 = mod_info1->num_quote_paths + mod_info1->num_bracket_paths + mod_info1->num_cpp_defines + mod_info1->num_cpp_includes; @@ -234,22 +258,52 @@ incompatible_cl_args (struct gcov_module mod_info2->num_bracket_paths + mod_info2->num_cpp_defines + mod_info2->num_cpp_includes; + option_tab1 = htab_create (10, str_hash, str_eq, NULL); + option_tab2 = htab_create (10, str_hash, str_eq, NULL); + /* First, separate the warning and non-warning options. */ for (i = 0; i < mod_info1->num_cl_args; i++) if (mod_info1->string_array[start_index1 + i][1] == 'W') warning_opts1[num_warning_opts1++] = mod_info1->string_array[start_index1 + i]; else - non_warning_opts1[num_non_warning_opts1++] = - mod_info1->string_array[start_index1 + i]; + { + void **slot; + char* option_string = mod_info1->string_array[start_index1 + i]; + + if (!strcmp ("-fexceptions", option_string)) + with_fexceptions1 = true; + else if (!strcmp ("-fno-exceptions", option_string)) + with_fexceptions1 = false; + + slot = htab_find_slot (option_tab1, option_string, INSERT); + if (!*slot) + { + *slot = option_string; + non_warning_opts1[num_non_warning_opts1++] = option_string; + } + } for (i = 0; i < mod_info2->num_cl_args; i++) if (mod_info2->string_array[start_index2 + i][1] == 'W') warning_opts2[num_warning_opts2++] = mod_info2->string_array[start_index2 + i]; else - non_warning_opts2[num_non_warning_opts2++] = - mod_info2->string_array[start_index2 + i]; + { + void **slot; + char* option_string = mod_info2->string_array[start_index2 + i]; + + if (!strcmp ("-fexceptions", option_string)) + with_fexceptions2 = true; + else if (!strcmp ("-fno-exceptions", option_string)) + with_fexceptions2 = false; + slot = htab_find_slot (option_tab2, option_string, INSERT); + if (!*slot) + { + *slot = option_string; + non_warning_opts2[num_non_warning_opts2++] = option_string; + } + } /* Compare warning options. If these mismatch, we emit a warning. */ if (num_warning_opts1 != num_warning_opts2) @@ -272,11 +326,24 @@ incompatible_cl_args (struct gcov_module warning (OPT_Wripa_opt_mismatch, "command line arguments mismatch for %s " "and %s", mod_info1->source_filename, mod_info2->source_filename); + if (warn_ripa_opt_mismatch && non_warning_mismatch && flag_ripa_verbose) + { + inform (UNKNOWN_LOCATION, "Options for %s", mod_info1->source_filename); + for (i = 0; i < num_non_warning_opts1; i++) + inform (UNKNOWN_LOCATION, non_warning_opts1[i]); + inform (UNKNOWN_LOCATION, "Options for %s", mod_info2->source_filename); + for (i = 0; i < num_non_warning_opts2; i++) + inform (UNKNOWN_LOCATION, non_warning_opts2[i]); + } + XDELETEVEC (warning_opts1); XDELETEVEC (warning_opts2); XDELETEVEC (non_warning_opts1); XDELETEVEC (non_warning_opts2); - return flag_ripa_disallow_opt_mismatch && non_warning_mismatch; + htab_delete (option_tab1); + htab_delete (option_tab2); + return ((flag_ripa_disallow_opt_mismatch && non_warning_mismatch) + || (with_fexceptions1 != with_fexceptions2)); } /* Read in the counts file, if available. DA_FILE_NAME is the