gcc/0123-DFE-Fix-internal-compiler-error-with-fipa-struct-reo.patch
Mingchuan Wu e3967b0b94 [Sync] Sync patch from openeuler/gcc
(cherry picked from commit 63828598f16b978ef91ea80730b8c13a698bfbb0)
2023-12-05 19:18:37 +08:00

53 lines
2.1 KiB
Diff

From 41af6d361a6d85ef4fce8a8438113d765596afdd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=91=E6=99=A8=E5=8D=89?= <zhengchenhui1@huawei.com>
Date: Thu, 12 Oct 2023 10:19:29 +0800
Subject: [PATCH 08/26] [DFE]Fix internal compiler error with
-fipa-struct-reorg=3.
---
gcc/ipa-struct-reorg/ipa-struct-reorg.c | 14 +++++++++++---
gcc/testsuite/gcc.dg/struct/struct-reorg.exp | 2 ++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
index 367bcf210..53d026386 100644
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
@@ -3991,9 +3991,17 @@ ipa_struct_reorg::maybe_mark_or_record_other_side (tree side, tree other, gimple
if (VOID_POINTER_P (TREE_TYPE (side))
&& TREE_CODE (side) == SSA_NAME)
{
- /* The type is other, the declaration is side. */
- current_function->record_decl (type, side, -1,
- isptrptr (TREE_TYPE (other)) ? TREE_TYPE (other) : NULL);
+ tree inner = SSA_NAME_VAR (side);
+ if (inner)
+ {
+ srdecl *in = find_decl (inner);
+ if (in && !in->type->has_escaped ())
+ {
+ /* The type is other, the declaration is side. */
+ current_function->record_decl (type, side, -1,
+ isptrptr (TREE_TYPE (other)) ? TREE_TYPE (other) : NULL);
+ }
+ }
}
else
{
diff --git a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp
index 281046b48..107f990f5 100644
--- a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp
+++ b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp
@@ -84,6 +84,8 @@ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/rf*.c]] \
# -fipa-struct-reorg=3
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dfe*.c]] \
"" "-fipa-struct-reorg=3 -fdump-ipa-all -flto-partition=one -fwhole-program"
+gcc-dg-runtest $srcdir/$subdir/struct_reorg-7.c \
+ "" "-fipa-struct-reorg=3 -fdump-ipa-all -flto-partition=one -fwhole-program"
# -fipa-struct-reorg=4
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pc*.c]] \
--
2.27.0