From 7d18a78f6f1a1d50b877502eec0ecc1b52d26e14 Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Wed, 17 Jun 2020 19:41:48 +0200 Subject: relayout type --- gcc/expr-rewriter.c | 7 ----- gcc/gimple-rewriter.c | 30 ++++++++++++++++++++++ .../gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c | 3 ++- gcc/type-reconstructor.c | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/gcc/expr-rewriter.c b/gcc/expr-rewriter.c index 0b92827cf0f..646eade856c 100644 --- a/gcc/expr-rewriter.c +++ b/gcc/expr-rewriter.c @@ -263,13 +263,6 @@ void ExprTypeRewriter::_walk_post(const_tree e) { const enum tree_code code = TREE_CODE(e); - log("tree_code_name = %s\n", get_tree_code_name(code)); - - if(dump_file) { - print_generic_expr(dump_file, (tree)e); - log("\n"); - } - gcc_assert(e); tree t = TREE_TYPE(e); const bool in_map = _map.find(t) != _map.end(); diff --git a/gcc/gimple-rewriter.c b/gcc/gimple-rewriter.c index 076083a1805..7518844d658 100644 --- a/gcc/gimple-rewriter.c +++ b/gcc/gimple-rewriter.c @@ -1,3 +1,28 @@ +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "options.h" +#include "cgraph.h" +#include "tree-pass.h" +#include "tree-cfg.h" +#include "tree-pretty-print.h" +#include "gimple-pretty-print.h" +#include "stringpool.h" //get_identifier +#include "basic-block.h" //needed for gimple.h +#include "function.h" //needed for gimple.h +#include "gimple.h" +#include "cfg.h" // needed for gimple-iterator.h +#include "gimple-iterator.h" +#include "stor-layout.h" // layout_type +#include "fold-const.h" //build_fold_addr_expr +#include "gimple-ssa.h" // update_stmt +#include "attribs.h" // decl_attributes +#include "gimplify.h" //unshare_expr +#include "value-range.h" // make_ssa_name dependency +#include "tree-ssanames.h" // make_ssa_name +#include "ssa.h" +#include "tree-into-ssa.h" #include "gimple-rewriter.hpp" void @@ -6,6 +31,11 @@ GimpleTypeRewriter::_walk_pre(const_tree e) // This is for local variables // and other declarations exprTypeRewriter.walk(e); + const bool is_interesting = exprTypeRewriter.is_interesting_type(TREE_TYPE(e)); + const bool is_var_decl = TREE_CODE(e) == VAR_DECL; + const bool is_valid = is_interesting && is_var_decl; + if (!is_valid) return; + relayout_decl((tree)e); } void diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c index b3c8f739ef3..b761cb95004 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=b -fipa-typelist-struct=astruct_s" } */ +/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis " } */ #include #include @@ -17,4 +17,5 @@ main (int argc, char **argv) }; struct astruct_s a[2][2]; struct astruct_s b = a[argc][argc]; + printf("%d %d %d\n", b.a, b.c, b.d); } diff --git a/gcc/type-reconstructor.c b/gcc/type-reconstructor.c index ed46f21630a..df48c39267f 100644 --- a/gcc/type-reconstructor.c +++ b/gcc/type-reconstructor.c @@ -167,7 +167,7 @@ TypeReconstructor::_walk_POINTER_TYPE_post(const_tree t) bool is_modified = get_is_modified(t); - copy = is_modified ? build_distinct_type_copy(copy) : copy; + copy = is_modified ? build_variant_type_copy(copy) : copy; TREE_TYPE(copy) = is_modified ? _reorg_map[TREE_TYPE(t)] : TREE_TYPE(copy); TYPE_NAME(copy) = is_modified ? get_new_identifier(copy) : TYPE_NAME(copy); // This is useful so that we go again through type layout -- cgit v1.2.3