113 lines
3.3 KiB
Diff
113 lines
3.3 KiB
Diff
From 9527d026dceb1e4f9d9f5c117dacfdfa65ce2735 Mon Sep 17 00:00:00 2001
|
|
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
|
|
Date: Tue, 23 May 2023 21:03:58 +0800
|
|
Subject: [PATCH 2/5] [StructReorg] Fix escape_cast_another_ptr check bug
|
|
|
|
In the other side check, escape mark is added
|
|
when the replacement struct type exists.
|
|
---
|
|
gcc/ipa-struct-reorg/ipa-struct-reorg.c | 15 +++---
|
|
.../struct/wo_prof_escape_replace_type.c | 49 +++++++++++++++++++
|
|
2 files changed, 57 insertions(+), 7 deletions(-)
|
|
create mode 100644 gcc/testsuite/gcc.dg/struct/wo_prof_escape_replace_type.c
|
|
|
|
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
|
index 2cac340c7..218140f58 100644
|
|
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
|
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
|
@@ -688,6 +688,8 @@ srtype::analyze (void)
|
|
info and/or static heuristics to differentiate splitting process. */
|
|
if (fields.length () == 2)
|
|
{
|
|
+ /* Currently, when the replacement structure type exists,
|
|
+ we only split the replacement structure. */
|
|
for (hash_map<tree, tree>::iterator it = replace_type_map.begin ();
|
|
it != replace_type_map.end (); ++it)
|
|
{
|
|
@@ -4921,7 +4923,9 @@ ipa_struct_reorg::check_other_side (srdecl *decl, tree other, gimple *stmt, vec<
|
|
}
|
|
|
|
srtype *t1 = find_type (inner_type (t));
|
|
- if (t1 == type)
|
|
+ /* In the other side check, escape mark is added
|
|
+ when the replacement struct type exists. */
|
|
+ if (t1 == type || is_replace_type (inner_type (t), type->type))
|
|
{
|
|
/* In Complete Struct Relayout opti, if lhs type is the same
|
|
as rhs type, we could return without any harm. */
|
|
@@ -4961,13 +4965,10 @@ ipa_struct_reorg::check_other_side (srdecl *decl, tree other, gimple *stmt, vec<
|
|
|
|
return;
|
|
}
|
|
- if (!is_replace_type (inner_type (t), type->type))
|
|
- {
|
|
- if (t1)
|
|
- t1->mark_escape (escape_cast_another_ptr, stmt);
|
|
+ if (t1)
|
|
+ t1->mark_escape (escape_cast_another_ptr, stmt);
|
|
|
|
- type->mark_escape (escape_cast_another_ptr, stmt);
|
|
- }
|
|
+ type->mark_escape (escape_cast_another_ptr, stmt);
|
|
}
|
|
|
|
|
|
diff --git a/gcc/testsuite/gcc.dg/struct/wo_prof_escape_replace_type.c b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_replace_type.c
|
|
new file mode 100644
|
|
index 000000000..d0a7b505e
|
|
--- /dev/null
|
|
+++ b/gcc/testsuite/gcc.dg/struct/wo_prof_escape_replace_type.c
|
|
@@ -0,0 +1,49 @@
|
|
+/* { dg-do compile } */
|
|
+
|
|
+#include <stdlib.h>
|
|
+
|
|
+struct AngleDef
|
|
+{
|
|
+ double K;
|
|
+ double th0;
|
|
+};
|
|
+typedef struct AngleDef angldef;
|
|
+
|
|
+struct bndangdihe
|
|
+{
|
|
+ int nbond;
|
|
+ int nangl;
|
|
+ int ndihe;
|
|
+};
|
|
+typedef struct bndangdihe bah;
|
|
+
|
|
+struct ambprmtop
|
|
+{
|
|
+ double *AnglK;
|
|
+ double *AnglEq;
|
|
+ bah nBAH;
|
|
+ angldef *AParam;
|
|
+ char source[512];
|
|
+ char eprulesource[512];
|
|
+};
|
|
+typedef struct ambprmtop prmtop;
|
|
+
|
|
+static void OrderBondParameters (prmtop *tp)
|
|
+{
|
|
+ int i;
|
|
+ tp->AParam = (angldef *)malloc (tp->nBAH.nangl * sizeof (angldef));
|
|
+ for (i = 0; i < tp->nBAH.nangl; i++)
|
|
+ {
|
|
+ tp->AParam[i].K = tp->AnglK[i];
|
|
+ tp->AParam[i].th0 = tp->AnglEq[i];
|
|
+ }
|
|
+}
|
|
+
|
|
+void main ()
|
|
+{
|
|
+ prmtop *tp = (prmtop *)malloc (100 * sizeof (prmtop));
|
|
+ OrderBondParameters (tp);
|
|
+}
|
|
+
|
|
+/*---------------------------------------------------------------------------------------------*/
|
|
+/* { dg-final { scan-ipa-dump "No structures to transform in struct split." "struct_reorg" } } */
|
|
--
|
|
2.33.0
|
|
|