1 Star 0 Fork 139

misaka00251/gcc

forked from src-openEuler/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0024-StructReorderFields-Add-lto-and-whole-program-gate.patch 3.10 KB
一键复制 编辑 原始数据 按行查看 历史
eastb233 提交于 2021-09-14 11:33 . [Sync] Sync patch from openeuler/gcc
From 0ee0f0ebeb098787cb9698887c237606b6ab10c6 Mon Sep 17 00:00:00 2001
From: huangxiaoquan <huangxiaoquan1@huawei.com>
Date: Wed, 1 Sep 2021 17:07:22 +0800
Subject: [PATCH 24/24] [StructReorderFields] Add lto and whole-program gate
Only enable struct reorder fields optimizations in lto or whole-program.
This prevents some .c files from being struct reorder fields optimized
while some of them are not optimized during project compilation.
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
index b0d4fe80797..2bf41e0d83b 100644
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
@@ -6655,7 +6655,9 @@ pass_ipa_struct_reorg::gate (function *)
&& flag_lto_partition == LTO_PARTITION_ONE
/* Only enable struct optimizations in C since other
languages' grammar forbid. */
- && lang_c_p ());
+ && lang_c_p ()
+ /* Only enable struct optimizations in lto or whole_program. */
+ && (in_lto_p || flag_whole_program));
}
const pass_data pass_data_ipa_reorder_fields =
@@ -6699,7 +6701,9 @@ pass_ipa_reorder_fields::gate (function *)
&& flag_lto_partition == LTO_PARTITION_ONE
/* Only enable struct optimizations in C since other
languages' grammar forbid. */
- && lang_c_p ());
+ && lang_c_p ()
+ /* Only enable struct optimizations in lto or whole_program. */
+ && (in_lto_p || flag_whole_program));
}
} // anon namespace
diff --git a/gcc/testsuite/gcc.dg/struct/struct_reorg-1.c b/gcc/testsuite/gcc.dg/struct/struct_reorg-1.c
index 6565fe8dd63..23444fe8b0d 100644
--- a/gcc/testsuite/gcc.dg/struct/struct_reorg-1.c
+++ b/gcc/testsuite/gcc.dg/struct/struct_reorg-1.c
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O3 -flto-partition=one -fipa-struct-reorg -fdump-ipa-all" }
+// { dg-options "-O3 -flto-partition=one -fipa-struct-reorg -fdump-ipa-all -fwhole-program" }
struct a
{
@@ -21,4 +21,10 @@ int g(void)
return b->t;
}
+int main()
+{
+ f ();
+ return g ();
+}
+
/* { dg-final { scan-ipa-dump "No structures to transform." "struct_reorg" } } */
diff --git a/gcc/testsuite/gcc.dg/struct/struct_reorg-3.c b/gcc/testsuite/gcc.dg/struct/struct_reorg-3.c
index 5864ad46fd3..2d1f95c9935 100644
--- a/gcc/testsuite/gcc.dg/struct/struct_reorg-3.c
+++ b/gcc/testsuite/gcc.dg/struct/struct_reorg-3.c
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-O3 -flto-partition=one -fipa-struct-reorg -fdump-ipa-all" }
+// { dg-options "-O3 -flto-partition=one -fipa-struct-reorg -fdump-ipa-all -fwhole-program" }
#include <stdlib.h>
typedef struct {
@@ -10,7 +10,7 @@ typedef struct {
compile_stack_elt_t *stack;
unsigned size;
} compile_stack_type;
-void f (const char *p, const char *pend, int c)
+__attribute__((noinline)) void f (const char *p, const char *pend, int c)
{
compile_stack_type compile_stack;
while (p != pend)
@@ -20,4 +20,9 @@ void f (const char *p, const char *pend, int c)
* sizeof (compile_stack_elt_t));
}
+int main()
+{
+ f (NULL, NULL, 1);
+}
+
/* { dg-final { scan-ipa-dump "Number of structures to transform is 1" "struct_reorg" } } */
--
2.21.0.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/misaka00251/gcc.git
git@gitee.com:misaka00251/gcc.git
misaka00251
gcc
gcc
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385