From 8a5a3a5b7cc72724576e36555b2fff135bec2d7d Mon Sep 17 00:00:00 2001 From: Erick Ochoa Date: Wed, 29 Apr 2020 09:59:44 +0200 Subject: Fixing test case found by creduce --- build.sh | 7 +++++- gcc/ipa-str-reorg-dead-field-eliminate.c | 4 +-- gcc/ipa-type-escape-analysis.c | 29 ++++++++++++++++++++++ .../gcc.dg/ipa/ipa-structreorg-51-creduce-0.c | 6 +++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c diff --git a/build.sh b/build.sh index 615b2b9f5ef..97158b0cf59 100755 --- a/build.sh +++ b/build.sh @@ -7,7 +7,12 @@ installdir=${1:-"gcc-inst"} mkdir -p $HOME/code/gcc-build/ mkdir -p $HOME/code/${installdir}/ pushd $HOME/code/gcc-build/ -$OLDPWD/configure --disable-bootstrap --disable-libsanitizer --enable-__cxa_atexit --enable-shared --disable-libsanitizer --enable-languages=c,c++,fortran --enable-lto --enable-gold --enable-linker-build-id --with-cpu-emag --prefix="$HOME/code/${installdir}/" +if find . -mindepth 1 -print -quit 2>/dev/null | grep -q . ; then + echo "not empty?" +else + $OLDPWD/configure --disable-bootstrap --disable-libsanitizer --enable-__cxa_atexit --enable-shared --disable-libsanitizer --enable-languages=c,c++,fortran --enable-lto --enable-gold --enable-linker-build-id --with-cpu-emag --prefix="$HOME/code/${installdir}/" +fi + make -j `nproc` make install -j `nproc` make check-gcc RUNTESTFLAGS="ipa.exp" diff --git a/gcc/ipa-str-reorg-dead-field-eliminate.c b/gcc/ipa-str-reorg-dead-field-eliminate.c index 7a6d7191cca..f2e3ccedbb1 100644 --- a/gcc/ipa-str-reorg-dead-field-eliminate.c +++ b/gcc/ipa-str-reorg-dead-field-eliminate.c @@ -943,7 +943,7 @@ collect_assign_rhs (gimple *stmt, hash_set &decl_map) break; default: { - print_gimple_stmt (dump_file, stmt, 0); + //print_gimple_stmt (dump_file, stmt, 0); test_log ("DEFAULT HERE: %s", 0, get_tree_code_name (code)); } break; @@ -2130,7 +2130,7 @@ rewrite_assign_rhs (gimple *stmt, gimple_stmt_iterator &gsi, break; default: { - print_gimple_stmt (dump_file, stmt, 0); + //print_gimple_stmt (dump_file, stmt, 0); test_log ("DEFAULT HERE: %s", 0, get_tree_code_name (code)); } break; diff --git a/gcc/ipa-type-escape-analysis.c b/gcc/ipa-type-escape-analysis.c index 64463c7df56..c39472079a2 100644 --- a/gcc/ipa-type-escape-analysis.c +++ b/gcc/ipa-type-escape-analysis.c @@ -116,6 +116,7 @@ update_escape_info_record (const_tree record_type, type_map &escape_map, bool is escaping_info *info = escape_map.get(record_type); // we are collecting records, therefore, we **must** have // it in the escaping info + //FIXME: Is this true? According to creduce bug, no. gcc_assert(info); info->is_escaping |= is_escaping; info->reason = union_op(info->reason, reason); @@ -425,6 +426,33 @@ collect_function_body (cgraph_node *cnode, type_map &escape_map) pop_cfun(); } +static void +collect_return_type (cgraph_node *cnode, type_map &escape_map) +{ + gcc_assert(cnode); + + const_tree decl = cnode->decl; + const enum tree_code code = TREE_CODE(decl); + const bool is_function_decl = FUNCTION_DECL == code; + gcc_assert (is_function_decl); + + const_tree fn_type = TREE_TYPE (decl); + const enum tree_code fn_type_code = TREE_CODE(fn_type); + const bool is_fn_type = FUNCTION_TYPE == fn_type_code; + gcc_assert (is_fn_type); + + const_tree ret_type = TREE_TYPE(fn_type); + gcc_assert (ret_type); + + const bool is_boring = filter_type(escape_map, ret_type); + if (is_boring) return; + + escaping_reason reason = new_escaping_reason(); + escaping_info info = {ret_type, false, reason}; + escape_map.put(ret_type, info); + return; +} + static void collect_types(type_map &escape_map) { @@ -436,6 +464,7 @@ collect_types(type_map &escape_map) collect_parm_declarations (cnode, escape_map); collect_function_body (cnode, escape_map); collect_local_declarations (cnode, escape_map); + collect_return_type (cnode, escape_map); } } diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c new file mode 100644 index 00000000000..b7ef85f30dd --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-51-creduce-0.c @@ -0,0 +1,6 @@ +/* { dg-do link } */ +/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate" } */ + +struct { +} main() { +} -- cgit v1.2.3