From patchwork Mon May 24 16:46:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 1482858 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; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=JUo3EnLf; dkim-atps=neutral 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 4Fpjmj3kWsz9s1l for ; Tue, 25 May 2021 02:47:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E77C388A809; Mon, 24 May 2021 16:47:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E77C388A809 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621874824; bh=HDZsjPl6OYVXfplvrJCTAhXmNXeDeM60nh0X5k2bmpk=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JUo3EnLfxb8nQQ2wtFufVXVzAR7l/9/paeWtLrMNJ8Y9YrFf/WMSm3zDKzU6E+DPP 63za0kLS6oa0+DnrBG8rSozCALxzYloxGO6FabxFNEMhu6hC6mmjBiunM/4/n5+kfG lXpGpZj67fYjHUKxUE5sjL3p/w6fhMO8ZpCA79mI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 7B3DD385383B for ; Mon, 24 May 2021 16:47:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7B3DD385383B Received: by mail-ot1-x331.google.com with SMTP id n3-20020a9d74030000b029035e65d0a0b8so4424651otk.9 for ; Mon, 24 May 2021 09:47:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language; bh=HDZsjPl6OYVXfplvrJCTAhXmNXeDeM60nh0X5k2bmpk=; b=Xn8ZFhoe7FMWfK+CwCbT72DDE0GA3VE0u/bpHgEEcbSzCcjU8ScY+d/2uAfoOI4JJo xfIUfm4fiLf1AQxKdWsGQdyZo2YQk8OzYRAVGxeEUWbjPRS1tRaSpCXfnh2KIkSqGy1B a7G5o3Nxp+GUbBkpbWpqqmNKR87AbEPGq9eOrvHUWlcjEAPNNlP6eK8wti+QafZl5mLu cujo1d9SHvkp1JX+r7h4eVoj86waqJFpulx4wcBfSHdruzqfX2KtPdQdFYIycG21V8BU v9oZW4n9jVVEzWpVhBALrFg9RHHNUixWNdrYNA+CLh65yReMcSUBhro/ZhX0Sq++vvN5 hbfA== X-Gm-Message-State: AOAM532ONQeI5pELzLqoP1gb5Hbc1Rj5FmsU/haN4nrHP1GKyqqJrAX3 4NcClt7jNBG7zKJLHGZ5dy0= X-Google-Smtp-Source: ABdhPJxZu3F7j+2oBSZEVG3ZlQRFTSA/BL6akRZacWd4Q4UBHbuO5QK8rqNSvZFuyMIkv+Q4J0PxfQ== X-Received: by 2002:a9d:5552:: with SMTP id h18mr20342909oti.104.1621874820945; Mon, 24 May 2021 09:47:00 -0700 (PDT) Received: from [192.168.0.41] (71-218-14-121.hlrn.qwest.net. [71.218.14.121]) by smtp.gmail.com with ESMTPSA id i11sm3141934otk.70.2021.05.24.09.47.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 May 2021 09:47:00 -0700 (PDT) Subject: [PATCH] add missing GTY support for hash-map (PR 100463) To: gcc-patches , Jason Merrill Message-ID: Date: Mon, 24 May 2021 10:46:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: , X-Patchwork-Original-From: Martin Sebor via Gcc-patches From: Martin Sebor Reply-To: Martin Sebor Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Instantiating a hash_map on a number of integer types including, for example, int or unsigned int (such as location_t), or HOST_WIDE_INT, and using it with the garbage collector causes many cryptic compilation errors due to incomplete support for such types (the PR shows a few examples). I ran into these errors as I was prototyping a new feature and they took me egregiously long to figure out, even with help from others. The attached patch adds the missing functions necessary to complete the support for all integer types to avoid these errors. This is prerequisite for a future patch of mine. The patch uses just one of these hash_map instances but others shouldn't have to run into the same errors if they happen to choose one of them. Tested on x86_64-linux. Martin PR other/100463 - many errors using GTY and hash_map gcc/ChangeLog: * ggc.h (gt_ggc_mx): Add overloads for all integers. (gt_pch_nx): Same. * hash-map.h (class hash_map): Add pch_nx_helper overloads for all integers. (hash_map::operator==): New function. diff --git a/gcc/ggc.h b/gcc/ggc.h index 65f6cb4d19d..92884717f5c 100644 --- a/gcc/ggc.h +++ b/gcc/ggc.h @@ -332,19 +332,30 @@ gt_pch_nx (const char *) { } -inline void -gt_ggc_mx (int) -{ -} - -inline void -gt_pch_nx (int) -{ -} - -inline void -gt_pch_nx (unsigned int) -{ -} +inline void gt_pch_nx (bool) { } +inline void gt_pch_nx (char) { } +inline void gt_pch_nx (signed char) { } +inline void gt_pch_nx (unsigned char) { } +inline void gt_pch_nx (short) { } +inline void gt_pch_nx (unsigned short) { } +inline void gt_pch_nx (int) { } +inline void gt_pch_nx (unsigned int) { } +inline void gt_pch_nx (long int) { } +inline void gt_pch_nx (unsigned long int) { } +inline void gt_pch_nx (long long int) { } +inline void gt_pch_nx (unsigned long long int) { } + +inline void gt_ggc_mx (bool) { } +inline void gt_ggc_mx (char) { } +inline void gt_ggc_mx (signed char) { } +inline void gt_ggc_mx (unsigned char) { } +inline void gt_ggc_mx (short) { } +inline void gt_ggc_mx (unsigned short) { } +inline void gt_ggc_mx (int) { } +inline void gt_ggc_mx (unsigned int) { } +inline void gt_ggc_mx (long int) { } +inline void gt_ggc_mx (unsigned long int) { } +inline void gt_ggc_mx (long long int) { } +inline void gt_ggc_mx (unsigned long long int) { } #endif diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 0779c930f0a..dd039f10343 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -107,27 +107,31 @@ class GTY((user)) hash_map gt_pch_nx (&x, op, cookie); } - static void - pch_nx_helper (int, gt_pointer_operator, void *) - { - } - - static void - pch_nx_helper (unsigned int, gt_pointer_operator, void *) - { - } - - static void - pch_nx_helper (bool, gt_pointer_operator, void *) - { - } - template static void pch_nx_helper (T *&x, gt_pointer_operator op, void *cookie) { op (&x, cookie); } + + /* The overloads below should match those in ggc.h. */ +#define DEFINE_PCH_HELPER(T) \ + static void pch_nx_helper (T, gt_pointer_operator, void *) { } + + DEFINE_PCH_HELPER (bool); + DEFINE_PCH_HELPER (char); + DEFINE_PCH_HELPER (signed char); + DEFINE_PCH_HELPER (unsigned char); + DEFINE_PCH_HELPER (short); + DEFINE_PCH_HELPER (unsigned short); + DEFINE_PCH_HELPER (int); + DEFINE_PCH_HELPER (unsigned int); + DEFINE_PCH_HELPER (long); + DEFINE_PCH_HELPER (unsigned long); + DEFINE_PCH_HELPER (long long); + DEFINE_PCH_HELPER (unsigned long long); + +#undef DEFINE_PCH_HELPER }; public: @@ -273,8 +277,12 @@ public: return reference_pair (e.m_key, e.m_value); } - bool - operator != (const iterator &other) const + bool operator== (const iterator &other) const + { + return m_iter == other.m_iter; + } + + bool operator != (const iterator &other) const { return m_iter != other.m_iter; }