From patchwork Fri Dec 21 17:19:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1017637 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493010-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Wi03WDzO"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43LwNX6BKZz9sD9 for ; Sat, 22 Dec 2018 04:19:39 +1100 (AEDT) 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:mime-version:content-type; q=dns; s=default; b=UWqalJ102GJJnziWXHWAs0iymRkFS1fP+EJRRfeOl/sy7fnSjX YYRIcttU84OJoR5EDY7AVdVd8c+n05hPZHxl/yDEQTEMYYaMsJpbM8LwE4NDHVwM FB0vl6i6Qfg/DzWWJcITpRoXrvT9/azYv4xUI5p56irciuqpTm6Mw4deU= 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:mime-version:content-type; s= default; bh=feUI/ee7aNp9wabbw/5S7gYp4k8=; b=Wi03WDzO7Ke+zJA/455i 4Huejt65X96D0QUk0vuWpeq3piI/uoO1kqXjyPKXgYMNMS/kssRLIFSzL3KKbxG0 kobWmlBlSga9sb5cK3LLIiZrle9pYN+tkA75De+CNlhCSTAjRbUcHH17Mr5gLnNK 5WvkgkjgJHbeKFrE6yEa0uU= Received: (qmail 112377 invoked by alias); 21 Dec 2018 17:19:32 -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 112363 invoked by uid 89); 21 Dec 2018 17:19:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.2 spammy=267301 X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Dec 2018 17:19:28 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 03325AD9F; Fri, 21 Dec 2018 17:19:26 +0000 (UTC) Date: Fri, 21 Dec 2018 18:19:24 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Martin Liska , Jan Hubicka Subject: [PATCH] Improve PR85574 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 It looks like IPA ICF does code generation based on the order of a hahstable walk which is keyed on pointers. That's a no-no. Fixing that doesn't solve the cc1 miscompare for LTO bootstrap but at least the IPA ICF WPA dumps are now consistent between stages. [LTO] Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk (and branches)? Will only get to applying after Christmas holidays so in case you want to poke further feel free to apply yourself. Thanks, Richard. 2018-12-21 Richard Biener PR ipa/85574 * ipa-icf.h (sem_item_optimizer::sort_congruence_split): Declare. * ipa-icf.c (sem_item_optimizer::sort_congruence_split): New function. (sem_item_optimizer::do_congruence_step_f): Sort the congruence set after UIDs before splitting them. Index: gcc/ipa-icf.c =================================================================== --- gcc/ipa-icf.c (revision 267301) +++ gcc/ipa-icf.c (working copy) @@ -3117,6 +3117,18 @@ sem_item_optimizer::traverse_congruence_ return true; } +int +sem_item_optimizer::sort_congruence_split (const void *a_, const void *b_) +{ + const std::pair *a = (const std::pair *)a_; + const std::pair *b = (const std::pair *)b_; + if (a->first->id < b->first->id) + return -1; + else if (a->first->id > b->first->id) + return 1; + return 0; +} + /* Tests if a class CLS used as INDEXth splits any congruence classes. Bitmap stack BMSTACK is used for bitmap allocation. */ @@ -3157,13 +3169,20 @@ sem_item_optimizer::do_congruence_step_f } } + auto_vec > to_split; + to_split.reserve_exact (split_map.elements ()); + for (hash_map ::iterator i = split_map.begin (); + i != split_map.end (); ++i) + to_split.safe_push (*i); + to_split.qsort (sort_congruence_split); + traverse_split_pair pair; pair.optimizer = this; pair.cls = cls; splitter_class_removed = false; - split_map.traverse (&pair); + for (unsigned i = 0; i < to_split.length (); ++i) + traverse_congruence_split (to_split[i].first, to_split[i].second, &pair); /* Bitmap clean-up. */ split_map.traverse