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: 66982 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC46B3858288 for ; Tue, 28 Mar 2023 06:21:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC46B3858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679984465; bh=EHjcJZdzcYeo4LE2beAWjRsP3j8QA13cBce93OxsFMI=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=RKvnspAke8jSxmmHP3F7bxe9OCC0qgMwNnWXOe/MEAD8CdKTeaXiNHSwRLjdKUDJN MZliGCci3WrAqG4KVmgZ8K5aoOhgJedAzQ1VVM1gtK6H7/Iar6uihXhgriwbuLJ4IO rgiMv3VPcQ3CswYYHq+JgXYyZGWZ8LAXOV5IWikw= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230328062105.BC46B3858288@sourceware.org> 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); +}