From patchwork Tue Mar 28 06:20:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 75842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2004257vqo; Mon, 27 Mar 2023 23:21:22 -0700 (PDT) X-Google-Smtp-Source: AKy350amg+pukNSIfjGFnUjSZOjingz29We8VR3PqxDmn5keoKQOy596glHCIyrBlHVeb+E/tQwi X-Received: by 2002:a17:906:b049:b0:937:9a24:370b with SMTP id bj9-20020a170906b04900b009379a24370bmr15596709ejb.67.1679984481987; Mon, 27 Mar 2023 23:21:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679984481; cv=none; d=google.com; s=arc-20160816; b=nlLLCCq6PpDiLSpEf+iyt1Wpsc0LyMthkVaSbLH/GMGUGcKBDvjSA0wQhcBi8n5oVo uI86ryejaQgY2M7N9zFWVIt90fJ+o1C4pmpUsouzKDab92lEBX5c84dR4jVgeugoDRSN KHRGCH2OXVCYEtEMl5+nCnghXWELH+oEPqUoWKZ6mU3OM20XxJrwSh+1yVa80Qkigij9 Ljnarrz2yJQp7RW6LynJoa0RbJnMm8UMKwudcolurDC0auwqzdBaPRajwfQ11jPwyf0D w6PNqQUPlrk4OR4861BXao2b6Lii2OsEn/O8PphEYgXlS1fJEfv+tBb3vnvuL1WJAbSb NsYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:cc:to:date:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=EHjcJZdzcYeo4LE2beAWjRsP3j8QA13cBce93OxsFMI=; b=W6fIiTEXDjlWzeS9ua8jmDNcqqz1letwYmDebTAZ8YJ/Jwf3DG6jnML0xVdmxHotgW qqyxcFglC/1mFDV+zS86PqOdq5Nf7ZAmCeaVwD229Ewiap5ibiQEt+QYOw8r5vtpwgbU CEG1IYerX1HEn0M4q1ZSWl33CqRqZ2i/a73QfuYbc9IuwXmBbE9vACV9v/yZM2WJyBye +wutHl5+8b642LleQ1rNEq5UZfYAyU7ehOz45MMlb1SOgaNipN8mws4+vPfCxVcfT4gP tFRiwAErAmUawEmdWLpKnsBbeXbcuM48AiGvpVspNltpH2AdChFynB7vWdxCwbkyria7 cnfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=esOBHr98; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j12-20020a170906278c00b0093017a4c5eesi27673407ejc.903.2023.03.27.23.21.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 23:21:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=esOBHr98; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A450C3858C53 for ; Tue, 28 Mar 2023 06:21:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A450C3858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679984480; bh=EHjcJZdzcYeo4LE2beAWjRsP3j8QA13cBce93OxsFMI=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=esOBHr989RlcqSBOs4+ldYFe6LL2suZtH0ac/r1V2xfSTfRWIUJRNUGiY07rJLiYy qbdpZTCIlRqXrlzobSyjixkHB//3mytYGtVyU5mXlGRQHWSbb0imuTkz+n/SMmQ9fd DnFRQHXqAQZBIXRHUc2yexhl64Nv3Hr0TALUb7J8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id EC1CA3858D39 for ; Tue, 28 Mar 2023 06:20:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC1CA3858D39 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E59EF1F8BA; Tue, 28 Mar 2023 06:20:36 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id B11CA2C141; Tue, 28 Mar 2023 06:20:36 +0000 (UTC) Date: Tue, 28 Mar 2023 06:20:36 +0000 (UTC) To: gcc-patches@gcc.gnu.org cc: jason@redhat.com, Jakub Jelinek Subject: [PATCH] ipa/106124 - ICE with -fkeep-inline-functions and OpenMP User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230328062120.A450C3858C53@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761591408448408122?= X-GMAIL-MSGID: =?utf-8?q?1761591408448408122?= The testcases in this bug reveal cases where an early generated type is collected because it was unused but gets attempted to be recreated later when a late DIE for a function (an OpenMP reduction) is created. That's unexpected and possibly the fault of OpenMP but the following allows the re-creation of the context type to succeed. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK? Thanks, Richard. PR ipa/106124 * dwarf2out.cc (lookup_type_die): Reset TREE_ASM_WRITTEN so we can re-create the DIE for the type if required. * g++.dg/gomp/pr106124.C: New testcase. --- gcc/dwarf2out.cc | 1 + gcc/testsuite/g++.dg/gomp/pr106124.C | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/gomp/pr106124.C diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 1711ad2c2da..1a0015ce00f 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -5894,6 +5894,7 @@ lookup_type_die (tree type) if (die && die->removed) { TYPE_SYMTAB_DIE (type) = NULL; + TREE_ASM_WRITTEN (type) = 0; return NULL; } return die; diff --git a/gcc/testsuite/g++.dg/gomp/pr106124.C b/gcc/testsuite/g++.dg/gomp/pr106124.C new file mode 100644 index 00000000000..3129749804b --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr106124.C @@ -0,0 +1,19 @@ +// { dg-do compile } +// { dg-require-effective-target c++11 } +// { dg-options "-g -O2 -fopenmp -fkeep-inline-functions" } + +int q; +struct A +{ + typedef int T; +#pragma omp declare reduction (x : T : omp_out += omp_in + [] (){ return q; }()) initializer (omp_priv = [](){ return 0; }()) + static void foo (); +}; +void bar (int &, int &); +void +A::foo () +{ + int r = 0, s = 0; +#pragma omp parallel reduction (x : r, s) + bar (r, s); +}