summaryrefslogtreecommitdiff
path: root/0089-StructReorderFields-Fix-gimple-call-not-rewritten.patch
blob: 76697e2a7118797125c20773ac6b2d05ad523662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 302b7e15d6308c29c215db4c9901342e1106381a Mon Sep 17 00:00:00 2001
From: huang-xiaoquan <huangxiaoquan1@huawei.com>
Date: Mon, 29 Apr 2024 11:00:12 +0800
Subject: [PATCH] [StructReorderFields] Fix gimple call not rewritten due to
 empty function node

Add parameter type escape for empty functions or inline functions.
---
 gcc/ipa-struct-reorg/ipa-struct-reorg.cc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc
index e08577c0c..2257d3528 100644
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc
@@ -4366,6 +4366,17 @@ ipa_struct_reorg::maybe_record_call (cgraph_node *node, gcall *stmt)
 
       argtype = argtype ? TREE_CHAIN (argtype) : NULL_TREE;
     }
+
+  /* Types escapes via a argument at empty or inlined function.  */
+  cgraph_node *callee = node->get_edge (stmt)->callee;
+  if (!gimple_call_builtin_p (stmt, BUILT_IN_FREE)
+      && gimple_call_num_args (stmt)
+      && callee && (!callee->has_gimple_body_p () || callee->inlined_to))
+    {
+      for (unsigned i = 0; i < gimple_call_num_args (stmt); i++)
+	mark_type_as_escape (TREE_TYPE (gimple_call_arg (stmt, i)),
+			      escape_var_arg_function);
+    }
 }
 
 void
@@ -8068,6 +8079,11 @@ ipa_struct_reorg::rewrite_functions (void)
 	      if (dump_file && (dump_flags & TDF_DETAILS))
 		{
 		  fprintf (dump_file, "\nNo rewrite:\n");
+		  if (current_function_decl == NULL)
+		    {
+		      fprintf (dump_file, "\ncurrent_function_decl == NULL\n");
+		      continue;
+		    }
 		  if (current_function_decl)
 		    dump_function_to_file (current_function_decl, dump_file,
 					   dump_flags | TDF_VOPS);
-- 
2.33.0