From patchwork Thu Oct 7 13:27:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1537718 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQBvr6T2Rz9sRN for ; Fri, 8 Oct 2021 00:27:52 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ADF363857C5B for ; Thu, 7 Oct 2021 13:27:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 44B4A3857C6F for ; Thu, 7 Oct 2021 13:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 44B4A3857C6F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id C964928104A; Thu, 7 Oct 2021 15:27:37 +0200 (CEST) Date: Thu, 7 Oct 2021 15:27:37 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix ipa-modref ICE Message-ID: <20211007132737.GD67653@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch fixes omitted case in contains_p which later trigger a sanity check since merging is not symmetric. Bootstrapped/regtested x86_64-linux, comitted. Honza gcc/ChangeLog: 2021-10-07 Jan Hubicka PR ipa/102581 * ipa-modref-tree.h (modref_access_node::contains_p): Handle offsets better. (modref_access_node::try_merge_with): Add sanity check that there are no redundant entries in the list. gcc/testsuite/ChangeLog: 2021-10-07 Jan Hubicka * g++.dg/torture/pr102581.C: New test. diff --git a/gcc/ipa-modref-tree.h b/gcc/ipa-modref-tree.h index 6a9ed5ce54b..8e9b89b3e2c 100644 --- a/gcc/ipa-modref-tree.h +++ b/gcc/ipa-modref-tree.h @@ -110,8 +110,11 @@ struct GTY(()) modref_access_node if (!a.parm_offset_known) return false; /* Accesses are never below parm_offset, so look - for smaller offset. */ - if (!known_le (parm_offset, a.parm_offset)) + for smaller offset. + If access ranges are known still allow merging + when bit offsets comparsion passes. */ + if (!known_le (parm_offset, a.parm_offset) + && !range_info_useful_p ()) return false; aoffset_adj = (a.parm_offset - parm_offset) << LOG2_BITS_PER_UNIT; @@ -618,6 +621,7 @@ private: found = true; if (!found && n->merge (*a, false)) found = restart = true; + gcc_checking_assert (found || !a->merge (*n, false)); if (found) { accesses->unordered_remove (i); diff --git a/gcc/testsuite/g++.dg/torture/pr102581.C b/gcc/testsuite/g++.dg/torture/pr102581.C new file mode 100644 index 00000000000..7f172d088b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr102581.C @@ -0,0 +1,51 @@ +// { dg-do compile } +/* { dg-additional-options "-fno-strict-aliasing" } */ +enum VkStructureType { + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR +} typedef VkPhysicalDeviceSparseProperties; +struct VkPhysicalDeviceProperties { + int apiVersion; + VkPhysicalDeviceSparseProperties sparseProperties; +}; +typedef struct { + VkStructureType sType; + int *pPhysicalDevices; +} VkPhysicalDeviceFeatures2; +typedef struct VkPhysicalDeviceProperties2 { + VkStructureType sType; + void *pNext; +} VkPhysicalDeviceMemoryProperties2; +struct VulkanVersion { + int major; + int minor; + int patch; +}; +int make_vulkan_version_version; +VulkanVersion make_vulkan_version() { + return {make_vulkan_version_version, make_vulkan_version_version, + make_vulkan_version_version}; +} +struct AppGpu { + int &inst; + int id; + int *phys_device = nullptr; + VulkanVersion api_version{}; + VkPhysicalDeviceProperties props{}; + VkPhysicalDeviceProperties2 props2{}; + int memory_props{}; + VkPhysicalDeviceMemoryProperties2 memory_props2{}; + int features{}; + VkPhysicalDeviceFeatures2 features2{}; + int *dev = nullptr; + int enabled_features{}; + int AppGpu_phys_device; + int AppGpu_inst; + AppGpu() : inst(AppGpu_inst), id() { + api_version = make_vulkan_version(); + props2.sType = memory_props2.sType = features2.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; + } +}; +int +main() { AppGpu(); return 0; }