From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679984436; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=EHjcJZdzcYeo4LE2beAWjRsP3j8QA13cBce93OxsFMI=; b=s0ZDRifM4+fAPgWhYiDIVEVh64zHc9ynxckyONf0H7FkUVcwCAxMLrlyB6NpAxkYnsZAk7 i4ITy9QY+TCHTdtygJaMWIDOR2qrz5lIgdfC5dAzSdqgjd2+DX0nwsDe1bqDFiJk7vGppz rPDct4dUp/rB7KDd00q5+Hc5Ramok8E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679984436; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=EHjcJZdzcYeo4LE2beAWjRsP3j8QA13cBce93OxsFMI=; b=f+4eA2AQhalzvFpYHmukO86A1CP221fodv0OVymU1qYCDIloQg2T+PcdI/B6Wau+tCS46W IwswDIKxtM2kCbCw== 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) From: Richard Biener 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 Content-Type: text/plain; charset=US-ASCII 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 List-Id: Message-ID: <20230328062036.ptzxY9S3GXFmJ5miOeUW3-HUoUpOoLcoIjpj-lBbFuQ@z> 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); +} -- 2.35.3