From patchwork Wed Jun 24 07:23:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1315891 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49sF4m4Z2Sz9sRN for ; Wed, 24 Jun 2020 17:23:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 313973986017; Wed, 24 Jun 2020 07:23:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 4FDF63851C18 for ; Wed, 24 Jun 2020 07:23:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FDF63851C18 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E3824AD1B for ; Wed, 24 Jun 2020 07:23:45 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH][obvious] options: Properly compare string options. To: gcc-patches@gcc.gnu.org Message-ID: <89a60c1b-7ad0-3c29-46e9-7ca01205cfa4@suse.cz> Date: Wed, 24 Jun 2020 09:23:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" For string types we must emit more complex code than simple pointer comparison. It's pretty much the same what we emit for cl_optimization_print_diff. I'm going to install it as obvious. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Martin gcc/ChangeLog: * optc-save-gen.awk: Compare string options in cl_optimization_compare by strcmp. --- gcc/optc-save-gen.awk | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk index 1b010085b75..760bf26721a 100644 --- a/gcc/optc-save-gen.awk +++ b/gcc/optc-save-gen.awk @@ -126,8 +126,10 @@ for (i = 0; i < n_opts; i++) { else if (otype ~ "^signed +char *$") var_opt_range[name] = "-128, 127" } - else if (otype ~ "^const char \\**$") + else if (otype ~ "^const char \\**$") { var_opt_string[n_opt_string++] = name; + string_options_names[name]++ + } else var_opt_other[n_opt_other++] = name; } @@ -382,8 +384,10 @@ if (have_save) { if (otype == var_type(flags[i])) var_target_range[name] = "" } - else if (otype ~ "^const char \\**$") + else if (otype ~ "^const char \\**$") { var_target_string[n_target_string++] = name; + string_options_names[name]++ + } else var_target_other[n_target_other++] = name; } @@ -966,8 +970,16 @@ for (i = 0; i < n_opts; i++) { continue; checked_options[name]++ - print " if (ptr1->x_" name " != ptr2->x_" name ")" - print " internal_error (\"% are modified in local context\");"; + if (name in string_options_names) { + print " if (ptr1->x_" name " != ptr2->x_" name ""; + print " && (!ptr1->x_" name" || !ptr2->x_" name + print " || strcmp (ptr1->x_" name", ptr2->x_" name ")))"; + print " internal_error (\"% are modified in local context\");"; + } + else { + print " if (ptr1->x_" name " != ptr2->x_" name ")" + print " internal_error (\"% are modified in local context\");"; + } } print "}";