summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-02-21 16:19:33 +0100
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-04-28 23:35:37 +0200
commit12f38a22e78d9f8102f52616502b5963babfa49a (patch)
treec2e0c3eb15a074c6d8b625e34ab6cb38d4b99c31
parente72ec1d184ea97eea5b633f6ec5010e6c1b945f0 (diff)
style
-rwxr-xr-xbuild.sh14
-rw-r--r--gcc/ipa-str-reorg-dead-field-eliminate.c3485
-rw-r--r--gcc/ipa-str-reorg-field-reorder.c4
-rw-r--r--gcc/ipa-str-reorg-instance-interleave.c2
-rw-r--r--gcc/ipa-structure-reorg.c1123
-rw-r--r--gcc/ipa-structure-reorg.h171
-rw-r--r--gcc/lto-streamer.h3
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c6
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c14
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c14
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c16
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c20
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c19
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c22
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c18
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c18
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c18
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c16
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c21
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c13
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c17
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c13
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c16
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c31
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c34
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c34
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c34
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-27-array-cast-0.c19
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c34
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c24
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c14
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c29
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c32
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c30
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c38
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c30
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c19
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c49
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c43
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c44
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c45
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c14
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c15
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c14
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c14
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c15
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c34
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c15
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c15
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c27
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c29
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c43
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c59
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c15
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c14
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c16
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c18
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c44
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c16
-rw-r--r--gcc/tree-pass.h3
60 files changed, 3385 insertions, 2681 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 00000000000..615b2b9f5ef
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+set -e
+set -u
+
+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}/"
+make -j `nproc`
+make install -j `nproc`
+make check-gcc RUNTESTFLAGS="ipa.exp"
+popd
diff --git a/gcc/ipa-str-reorg-dead-field-eliminate.c b/gcc/ipa-str-reorg-dead-field-eliminate.c
index 0d0fef8c26e..d9cbf7c91a8 100644
--- a/gcc/ipa-str-reorg-dead-field-eliminate.c
+++ b/gcc/ipa-str-reorg-dead-field-eliminate.c
@@ -29,859 +29,952 @@ along with GCC; see the file COPYING3. If not see
#include "tree-cfg.h"
#include "tree-pretty-print.h"
#include "gimple-pretty-print.h"
-#include "stringpool.h" //get_identifier
+#include "stringpool.h" //get_identifier
#include "basic-block.h" //needed for gimple.h
-#include "function.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 "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 <vector> // needed for ipa-structure-reorg
#include <map>
#include <set>
-#include "ipa-structure-reorg.h"
+#include "ipa-structure-reorg.h"
#include "ipa-utils.h"
-#define test_write(M, ...) \
- if (dump_file) \
- { \
- fprintf(dump_file, M, \
- ##__VA_ARGS__); \
+#define test_write(M, ...) \
+ if (dump_file) \
+ { \
+ fprintf (dump_file, M, ##__VA_ARGS__); \
}
-#define test_log(M, indent, ...) \
- if (dump_file) \
- { \
- fprintf(dump_file, "%*c" M "\n", indent, ' ', \
- ##__VA_ARGS__); \
+#define test_log(M, indent, ...) \
+ if (dump_file) \
+ { \
+ fprintf (dump_file, "%*c" M "\n", indent, ' ', ##__VA_ARGS__); \
}
-
-static const char* get_type_name(const_tree type);
-static const char* get_record_name(const_tree record);
-//INFO: cannot change
-//tree expr to const_tree expr
+static const char *
+get_type_name (const_tree type);
+static const char *
+get_record_name (const_tree record);
+// INFO: cannot change
+// tree expr to const_tree expr
static void
-log_expr_prologue(const int indent, const char* debug_str, tree expr)
+log_expr_prologue (const int indent, const char *debug_str, tree expr)
{
- const char* expr_str = print_generic_expr_to_str(expr);
- test_log("<%s \"%s\">", indent, debug_str, expr_str);
- const_tree type = TREE_TYPE(expr);
- if (TREE_CODE(type) == ARRAY_TYPE)
- {
- const_tree domain = TYPE_DOMAIN(type);
- const_tree min = TYPE_MIN_VALUE(domain);
- const_tree max = TYPE_MAX_VALUE(domain);
- int _min = tree_to_uhwi(min);
- int _max = tree_to_uhwi(max);
- test_log("< domain = (%d,%d)>", indent, _min, _max);
- }
- test_log("< type = %s>", indent, get_type_name(type));
+ const char *expr_str = print_generic_expr_to_str (expr);
+ test_log ("<%s \"%s\">", indent, debug_str, expr_str);
+ const_tree type = TREE_TYPE (expr);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ const_tree domain = TYPE_DOMAIN (type);
+ const_tree min = TYPE_MIN_VALUE (domain);
+ const_tree max = TYPE_MAX_VALUE (domain);
+ int _min = tree_to_uhwi (min);
+ int _max = tree_to_uhwi (max);
+ test_log ("< domain = (%d,%d)>", indent, _min, _max);
+ }
+ test_log ("< type = %s>", indent, get_type_name (type));
}
// This really should be inaccessible to anyone.
static const_tree
-get_base_type_from_ptr_or_arr_type(const_tree old_pointer_type, const_tree pointer_type, unsigned int &indirection_level)
+get_base_type_from_ptr_or_arr_type (const_tree old_pointer_type,
+ const_tree pointer_type,
+ unsigned int &indirection_level)
{
- if (pointer_type == NULL) {
- gcc_assert(TREE_CODE(old_pointer_type) != POINTER_TYPE);
- gcc_assert(TREE_CODE(old_pointer_type) != ARRAY_TYPE);
- return old_pointer_type;
- }
- return get_base_type_from_ptr_or_arr_type(pointer_type, TREE_TYPE(pointer_type), ++indirection_level);
+ if (pointer_type == NULL)
+ {
+ gcc_assert (TREE_CODE (old_pointer_type) != POINTER_TYPE);
+ gcc_assert (TREE_CODE (old_pointer_type) != ARRAY_TYPE);
+ return old_pointer_type;
+ }
+ return get_base_type_from_ptr_or_arr_type (pointer_type,
+ TREE_TYPE (pointer_type),
+ ++indirection_level);
}
static const_tree
-get_base_type_from_ptr_or_arr_type(const_tree ptr_or_array, unsigned int &indirection_level)
+get_base_type_from_ptr_or_arr_type (const_tree ptr_or_array,
+ unsigned int &indirection_level)
{
- const bool is_array = TREE_CODE(ptr_or_array) == ARRAY_TYPE;
- const bool is_ptr = TREE_CODE(ptr_or_array) == POINTER_TYPE;
+ const bool is_array = TREE_CODE (ptr_or_array) == ARRAY_TYPE;
+ const bool is_ptr = TREE_CODE (ptr_or_array) == POINTER_TYPE;
const bool is_array_or_ptr = is_array || is_ptr;
- gcc_assert(is_array_or_ptr);
+ gcc_assert (is_array_or_ptr);
indirection_level = 0;
- return get_base_type_from_ptr_or_arr_type(ptr_or_array, TREE_TYPE(ptr_or_array), indirection_level);
+ return get_base_type_from_ptr_or_arr_type (ptr_or_array,
+ TREE_TYPE (ptr_or_array),
+ indirection_level);
}
-
static const_tree
-get_base_type_from_array_type(const_tree array_type, unsigned int &indirection_level)
+get_base_type_from_array_type (const_tree array_type,
+ unsigned int &indirection_level)
{
- gcc_assert(TREE_CODE(array_type) == ARRAY_TYPE);
- return get_base_type_from_ptr_or_arr_type(array_type, indirection_level);
+ gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
+ return get_base_type_from_ptr_or_arr_type (array_type, indirection_level);
}
static const_tree
-get_base_type_from_array_type(const_tree array_type)
+get_base_type_from_array_type (const_tree array_type)
{
- gcc_assert(TREE_CODE(array_type) == ARRAY_TYPE);
+ gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
unsigned int indirection_level;
- return get_base_type_from_array_type(array_type, indirection_level);
+ return get_base_type_from_array_type (array_type, indirection_level);
}
static const_tree
-get_base_type_from_pointer_type(const_tree pointer_type, unsigned int &indirection_level)
+get_base_type_from_pointer_type (const_tree pointer_type,
+ unsigned int &indirection_level)
{
- gcc_assert(TREE_CODE(pointer_type) == POINTER_TYPE);
- return get_base_type_from_ptr_or_arr_type(pointer_type, indirection_level);
+ gcc_assert (TREE_CODE (pointer_type) == POINTER_TYPE);
+ return get_base_type_from_ptr_or_arr_type (pointer_type, indirection_level);
}
static const_tree
-get_base_type_from_pointer_type(const_tree pointer_type)
+get_base_type_from_pointer_type (const_tree pointer_type)
{
- gcc_assert(TREE_CODE(pointer_type) == POINTER_TYPE);
+ gcc_assert (TREE_CODE (pointer_type) == POINTER_TYPE);
unsigned int indirection_level;
- return get_base_type_from_pointer_type(pointer_type, indirection_level);
+ return get_base_type_from_pointer_type (pointer_type, indirection_level);
}
// This function should be hidden
static const_tree
-get_base_type_from_ptr_or_arr_var(const_tree var, unsigned int &indirection_level)
+get_base_type_from_ptr_or_arr_var (const_tree var,
+ unsigned int &indirection_level)
{
- tree ptr_or_array = TREE_TYPE(var);
- const bool is_array = TREE_CODE(ptr_or_array) == ARRAY_TYPE;
- const bool is_ptr = TREE_CODE(ptr_or_array) == POINTER_TYPE;
+ tree ptr_or_array = TREE_TYPE (var);
+ const bool is_array = TREE_CODE (ptr_or_array) == ARRAY_TYPE;
+ const bool is_ptr = TREE_CODE (ptr_or_array) == POINTER_TYPE;
const bool is_array_or_ptr = is_array || is_ptr;
- gcc_assert(is_array_or_ptr);
- const_tree retval = get_base_type_from_ptr_or_arr_type(ptr_or_array, indirection_level);
+ gcc_assert (is_array_or_ptr);
+ const_tree retval
+ = get_base_type_from_ptr_or_arr_type (ptr_or_array, indirection_level);
return retval;
}
static const_tree
-get_base_type_from_array_var(const_tree var, unsigned int &indirection_level)
+get_base_type_from_array_var (const_tree var, unsigned int &indirection_level)
{
- gcc_assert(TREE_CODE(var) != ARRAY_TYPE);
- tree array_type = TREE_TYPE(var);
- gcc_assert(TREE_CODE(array_type) == ARRAY_TYPE);
- const_tree retval = get_base_type_from_ptr_or_arr_var(array_type, indirection_level);
+ gcc_assert (TREE_CODE (var) != ARRAY_TYPE);
+ tree array_type = TREE_TYPE (var);
+ gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
+ const_tree retval
+ = get_base_type_from_ptr_or_arr_var (array_type, indirection_level);
return retval;
}
-
static const_tree
-get_base_type_from_pointer_var(const_tree var, unsigned int &indirection_level)
+get_base_type_from_pointer_var (const_tree var, unsigned int &indirection_level)
{
- gcc_assert(TREE_CODE(var) != POINTER_TYPE);
- tree pointer_type = TREE_TYPE(var);
- gcc_assert(TREE_CODE(pointer_type) == POINTER_TYPE);
- const_tree retval = get_base_type_from_ptr_or_arr_type(pointer_type, indirection_level);
+ gcc_assert (TREE_CODE (var) != POINTER_TYPE);
+ tree pointer_type = TREE_TYPE (var);
+ gcc_assert (TREE_CODE (pointer_type) == POINTER_TYPE);
+ const_tree retval
+ = get_base_type_from_ptr_or_arr_type (pointer_type, indirection_level);
return retval;
}
static const_tree
-get_base_type_from_pointer_var(const_tree var)
+get_base_type_from_pointer_var (const_tree var)
{
- gcc_assert(TREE_CODE(var) != POINTER_TYPE);
+ gcc_assert (TREE_CODE (var) != POINTER_TYPE);
unsigned int indirection_level;
- return get_base_type_from_pointer_var(var, indirection_level);
+ return get_base_type_from_pointer_var (var, indirection_level);
}
-//INFO: cannot change
-//tree expr to const_tree expr
+// INFO: cannot change
+// tree expr to const_tree expr
static void
-log_expr_epilogue(const int indent, const char* debug_str, tree expr)
+log_expr_epilogue (const int indent, const char *debug_str, tree expr)
{
- const char* expr_str = print_generic_expr_to_str(expr);
- const_tree type = TREE_TYPE(expr);
- if (TREE_CODE(type) == ARRAY_TYPE)
- {
- const_tree domain = TYPE_DOMAIN(type);
- const_tree min = TYPE_MIN_VALUE(domain);
- const_tree max = TYPE_MAX_VALUE(domain);
- int _min = tree_to_uhwi(min);
- int _max = tree_to_uhwi(max);
- test_log("< domain = (%d,%d)>", indent, _min, _max);
- }
- test_log("< type = %s>", indent, get_type_name(type));
- test_log("</%s \"%s\">", indent, debug_str, expr_str);
+ const char *expr_str = print_generic_expr_to_str (expr);
+ const_tree type = TREE_TYPE (expr);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ const_tree domain = TYPE_DOMAIN (type);
+ const_tree min = TYPE_MIN_VALUE (domain);
+ const_tree max = TYPE_MAX_VALUE (domain);
+ int _min = tree_to_uhwi (min);
+ int _max = tree_to_uhwi (max);
+ test_log ("< domain = (%d,%d)>", indent, _min, _max);
+ }
+ test_log ("< type = %s>", indent, get_type_name (type));
+ test_log ("</%s \"%s\">", indent, debug_str, expr_str);
}
-static const char*
-make_array_postfix(unsigned int indirection_level)
+static const char *
+make_array_postfix (unsigned int indirection_level)
{
- gcc_assert(indirection_level > 0);
- static const char* max_indirection_level_str_array = "[][][][][][][][][][][][][]";
- static const size_t size_array = strlen(max_indirection_level_str_array );
+ gcc_assert (indirection_level > 0);
+ static const char *max_indirection_level_str_array
+ = "[][][][][][][][][][][][][]";
+ static const size_t size_array = strlen (max_indirection_level_str_array);
static const size_t postfix_size_array = 2;
- static const size_t max_indirection_level_array = size_array / postfix_size_array;
- gcc_assert(indirection_level < max_indirection_level_array);
- return max_indirection_level_str_array + size_array - (indirection_level * postfix_size_array);
+ static const size_t max_indirection_level_array
+ = size_array / postfix_size_array;
+ gcc_assert (indirection_level < max_indirection_level_array);
+ return max_indirection_level_str_array + size_array
+ - (indirection_level * postfix_size_array);
}
-static const char*
-make_pointer_postfix(unsigned int indirection_level)
+static const char *
+make_pointer_postfix (unsigned int indirection_level)
{
- gcc_assert(indirection_level > 0);
- static const char* max_indirection_level_str_pointer = "************************";
- static const size_t size_pointer = strlen(max_indirection_level_str_pointer);
+ gcc_assert (indirection_level > 0);
+ static const char *max_indirection_level_str_pointer
+ = "************************";
+ static const size_t size_pointer = strlen (max_indirection_level_str_pointer);
static const size_t postfix_size_pointer = 1;
- static const size_t max_indirection_level_pointer = size_pointer / postfix_size_pointer;
- gcc_assert(indirection_level < max_indirection_level_pointer);
- return max_indirection_level_str_pointer + size_pointer - (indirection_level * postfix_size_pointer);
+ static const size_t max_indirection_level_pointer
+ = size_pointer / postfix_size_pointer;
+ gcc_assert (indirection_level < max_indirection_level_pointer);
+ return max_indirection_level_str_pointer + size_pointer
+ - (indirection_level * postfix_size_pointer);
}
-static const char*
-make_pointer_or_array_name(const char* base_type, const char* postfix)
+static const char *
+make_pointer_or_array_name (const char *base_type, const char *postfix)
{
- char *ptr;
- int calculated_size = strlen(base_type) + strlen(postfix);
- //TODO: Do not use asprintf?
- //We'll let exit() deal with freeing this memory.
- int retval = asprintf(&ptr, "%s%s", base_type, postfix);
- gcc_assert(retval == calculated_size);
- return ptr;
+ char *ptr;
+ int calculated_size = strlen (base_type) + strlen (postfix);
+ // TODO: Do not use asprintf?
+ // We'll let exit() deal with freeing this memory.
+ int retval = asprintf (&ptr, "%s%s", base_type, postfix);
+ gcc_assert (retval == calculated_size);
+ return ptr;
}
-static const char*
-make_pointer_name(const char* base_type_name, const unsigned int indirection_level)
+static const char *
+make_pointer_name (const char *base_type_name,
+ const unsigned int indirection_level)
{
- const char* postfix = make_pointer_postfix(indirection_level);
- const char* ptr = make_pointer_or_array_name(base_type_name, postfix);
+ const char *postfix = make_pointer_postfix (indirection_level);
+ const char *ptr = make_pointer_or_array_name (base_type_name, postfix);
return ptr;
}
-static const char*
-make_array_name(const char* base_type_name, const unsigned int indirection_level)
+static const char *
+make_array_name (const char *base_type_name,
+ const unsigned int indirection_level)
{
- const char* postfix = make_array_postfix(indirection_level);
- const char* ptr = make_pointer_or_array_name(base_type_name, postfix);
+ const char *postfix = make_array_postfix (indirection_level);
+ const char *ptr = make_pointer_or_array_name (base_type_name, postfix);
return ptr;
}
-static const char*
-make_pointer_name(const_tree base_type, const unsigned int indirection_level)
+static const char *
+make_pointer_name (const_tree base_type, const unsigned int indirection_level)
{
- const char* struct_name = get_type_name(base_type);
- return make_pointer_name(struct_name, indirection_level);
+ const char *struct_name = get_type_name (base_type);
+ return make_pointer_name (struct_name, indirection_level);
}
-static const char*
-make_array_name(const_tree base_type, const unsigned int indirection_level)
+static const char *
+make_array_name (const_tree base_type, const unsigned int indirection_level)
{
- const char* struct_name = get_type_name(base_type);
- return make_array_name(struct_name, indirection_level);
+ const char *struct_name = get_type_name (base_type);
+ return make_array_name (struct_name, indirection_level);
}
-static const char*
-make_pointer_name(const_tree pointer)
+static const char *
+make_pointer_name (const_tree pointer)
{
- gcc_assert(TREE_CODE(pointer) == POINTER_TYPE);
+ gcc_assert (TREE_CODE (pointer) == POINTER_TYPE);
unsigned int indirection_level;
- const_tree base_type = get_base_type_from_pointer_type(pointer, indirection_level);
- const char* pointer_name = make_pointer_name(base_type, indirection_level);
+ const_tree base_type
+ = get_base_type_from_pointer_type (pointer, indirection_level);
+ const char *pointer_name = make_pointer_name (base_type, indirection_level);
return pointer_name;
}
-static const char*
-make_reference_name(const_tree ref)
+static const char *
+make_reference_name (const_tree ref)
{
- test_log("making reference name", 0);
- gcc_assert(TREE_CODE(ref) == REFERENCE_TYPE);
- const_tree base_type = TREE_TYPE(ref);
- const char* old_name = get_type_name(base_type);
+ test_log ("making reference name", 0);
+ gcc_assert (TREE_CODE (ref) == REFERENCE_TYPE);
+ const_tree base_type = TREE_TYPE (ref);
+ const char *old_name = get_type_name (base_type);
char *ptr;
- static const char* prefix = "&";
+ static const char *prefix = "&";
static const char *suffix = ".reorg";
- int new_size = strlen(prefix) + strlen(old_name) + strlen(suffix);
- int retval = asprintf(&ptr, "%s%s%s", prefix, old_name, suffix);
- gcc_assert(retval == new_size);
- test_log("here %s", 0, ptr);
+ int new_size = strlen (prefix) + strlen (old_name) + strlen (suffix);
+ int retval = asprintf (&ptr, "%s%s%s", prefix, old_name, suffix);
+ gcc_assert (retval == new_size);
+ test_log ("here %s", 0, ptr);
return ptr;
}
-
-static const char*
-make_array_name(const_tree array)
+static const char *
+make_array_name (const_tree array)
{
- gcc_assert(TREE_CODE(array) == ARRAY_TYPE);
+ gcc_assert (TREE_CODE (array) == ARRAY_TYPE);
unsigned int indirection_level;
- const_tree base_type = get_base_type_from_array_type(array, indirection_level);
- const char* array_name = make_array_name(base_type, indirection_level);
+ const_tree base_type
+ = get_base_type_from_array_type (array, indirection_level);
+ const char *array_name = make_array_name (base_type, indirection_level);
return array_name;
}
-static const char*
-make_base_name_based_on_old(const char* old_name)
+static const char *
+make_base_name_based_on_old (const char *old_name)
{
- gcc_assert(old_name);
+ gcc_assert (old_name);
char *ptr;
static const char *suffix = ".reorg";
- int new_size = strlen(old_name) + strlen(suffix);
- int retval = asprintf(&ptr, "%s%s", old_name, suffix);
- gcc_assert(retval == new_size);
+ int new_size = strlen (old_name) + strlen (suffix);
+ int retval = asprintf (&ptr, "%s%s", old_name, suffix);
+ gcc_assert (retval == new_size);
return ptr;
}
-static const char*
-make_base_name_based_on_old(const_tree base_type)
+static const char *
+make_base_name_based_on_old (const_tree base_type)
{
- enum tree_code base_code = TREE_CODE(base_type);
+ enum tree_code base_code = TREE_CODE (base_type);
const bool is_pointer = POINTER_TYPE == base_code;
const bool is_array = ARRAY_TYPE == base_code;
const bool prohibited = is_pointer || is_array;
- //This means that this is only for base types
- //and structs.
- //I.e. we don't want to generate names which have
+ // This means that this is only for base types
+ // and structs.
+ // I.e. we don't want to generate names which have
//[][][] at the end or ****
- gcc_assert(!prohibited);
- const char* base_type_name = get_type_name(base_type);
- return make_base_name_based_on_old(base_type_name);
+ gcc_assert (!prohibited);
+ const char *base_type_name = get_type_name (base_type);
+ return make_base_name_based_on_old (base_type_name);
}
-static const char*
-make_record_name_based_on_old(const char* old_record_name)
+static const char *
+make_record_name_based_on_old (const char *old_record_name)
{
- return make_base_name_based_on_old(old_record_name);
+ return make_base_name_based_on_old (old_record_name);
}
-static const char*
-make_array_name_based_on_old(const_tree array)
+static const char *
+make_array_name_based_on_old (const_tree array)
{
- enum tree_code code = TREE_CODE(array);
- gcc_assert(ARRAY_TYPE == code);
+ enum tree_code code = TREE_CODE (array);
+ gcc_assert (ARRAY_TYPE == code);
unsigned int indirection_level;
- const_tree base_type = get_base_type_from_array_type(array, indirection_level);
- const char* reorged_base_type_name = make_base_name_based_on_old(base_type);
- const char* suffix = make_array_postfix(indirection_level);
- return make_pointer_or_array_name(reorged_base_type_name, suffix);
+ const_tree base_type
+ = get_base_type_from_array_type (array, indirection_level);
+ const char *reorged_base_type_name = make_base_name_based_on_old (base_type);
+ const char *suffix = make_array_postfix (indirection_level);
+ return make_pointer_or_array_name (reorged_base_type_name, suffix);
}
-static const char*
-make_pointer_name_based_on_old(const_tree pointer)
+static const char *
+make_pointer_name_based_on_old (const_tree pointer)
{
- enum tree_code code = TREE_CODE(pointer);
- gcc_assert(POINTER_TYPE == code);
+ enum tree_code code = TREE_CODE (pointer);
+ gcc_assert (POINTER_TYPE == code);
unsigned int indirection_level;
- const_tree base_type = get_base_type_from_pointer_type(pointer, indirection_level);
- const char* reorged_base_type_name = make_base_name_based_on_old(base_type);
- const char* suffix = make_pointer_postfix(indirection_level);
- return make_pointer_or_array_name(reorged_base_type_name, suffix);
+ const_tree base_type
+ = get_base_type_from_pointer_type (pointer, indirection_level);
+ const char *reorged_base_type_name = make_base_name_based_on_old (base_type);
+ const char *suffix = make_pointer_postfix (indirection_level);
+ return make_pointer_or_array_name (reorged_base_type_name, suffix);
}
-static const char*
-make_record_name_based_on_old(const_tree record)
+static const char *
+make_record_name_based_on_old (const_tree record)
{
- enum tree_code code = TREE_CODE(record);
- gcc_assert(RECORD_TYPE == code);
- const char* old_name = get_type_name(record);
- return make_record_name_based_on_old(old_name);
+ enum tree_code code = TREE_CODE (record);
+ gcc_assert (RECORD_TYPE == code);
+ const char *old_name = get_type_name (record);
+ return make_record_name_based_on_old (old_name);
}
-static bool rewrite_addr_expr_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_addr_expr(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_addr_expr_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_addr_expr (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_addr_expr", expr);
- bool retval = rewrite_addr_expr_def(expr, type_map, indent + 4);
- log_expr_epilogue(indent, "rewrite_addr_expr", expr);
+ log_expr_prologue (indent, "rewrite_addr_expr", expr);
+ bool retval = rewrite_addr_expr_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_addr_expr", expr);
return retval;
}
-static bool rewrite_array_ref_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
+static bool
+rewrite_array_ref_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
static bool
-rewrite_array_ref(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_array_ref (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_array_ref", expr);
- bool retval = rewrite_array_ref_def(expr, type_map, indent + 4);
- log_expr_epilogue(indent, "rewrite_array_ref", expr);
+ log_expr_prologue (indent, "rewrite_array_ref", expr);
+ bool retval = rewrite_array_ref_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_array_ref", expr);
return retval;
}
-static bool rewrite_bin_expr_default_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_bin_expr_default(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_bin_expr_default_def (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_bin_expr_default (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_bin_expr", expr);
- bool retval = rewrite_bin_expr_default_def(expr, type_map, indent + 4);
- log_expr_epilogue(indent, "rewrite_bin_expr", expr);
+ log_expr_prologue (indent, "rewrite_bin_expr", expr);
+ bool retval = rewrite_bin_expr_default_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_bin_expr", expr);
return retval;
}
-static bool rewrite_constructor_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_constructor(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_constructor_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_constructor (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_constructor", expr);
- bool retval = rewrite_constructor_def(expr, type_map, indent + 4);
- log_expr_epilogue(indent, "rewrite_constructor", expr);
+ log_expr_prologue (indent, "rewrite_constructor", expr);
+ bool retval = rewrite_constructor_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_constructor", expr);
return retval;
}
-static bool rewrite_field_decl_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_field_decl(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_field_decl_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_field_decl (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_field_decl", expr);
- bool retval = rewrite_field_decl_def(expr, type_map, indent + 4);
- log_expr_epilogue(indent, "rewrite_field_decl", expr);
+ log_expr_prologue (indent, "rewrite_field_decl", expr);
+ bool retval = rewrite_field_decl_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_field_decl", expr);
return retval;
}
-static bool rewrite_integer_cst_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_integer_cst(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_integer_cst_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_integer_cst (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_integer_cst", expr);
- bool retval = rewrite_integer_cst_def(expr, type_map, indent + 4);
- log_expr_epilogue(indent, "rewrite_integer_cst", expr);
+ log_expr_prologue (indent, "rewrite_integer_cst", expr);
+ bool retval = rewrite_integer_cst_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_integer_cst", expr);
return retval;
}
-static bool rewrite_function_decl_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_function_decl(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_function_decl_def (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_function_decl (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_function_decl", expr);
- bool retval = rewrite_function_decl_def(expr, type_map, indent + 4);
- log_expr_epilogue(indent, "rewrite_function_decl", expr);
+ log_expr_prologue (indent, "rewrite_function_decl", expr);
+ bool retval = rewrite_function_decl_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_function_decl", expr);
return retval;
}
-static bool rewrite_component_ref(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
-static bool rewrite_component_ref_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_component_ref(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_component_ref (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_component_ref_def (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_component_ref (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_component_ref", expr);
- bool retval = rewrite_component_ref_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_component_ref", expr);
+ log_expr_prologue (indent, "rewrite_component_ref", expr);
+ bool retval = rewrite_component_ref_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_component_ref", expr);
return retval;
}
-static bool rewrite_expr(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
-static bool rewrite_expr_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_expr(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_expr (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_expr_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_expr (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_expr", expr);
- bool retval = rewrite_expr_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_expr", expr);
+ log_expr_prologue (indent, "rewrite_expr", expr);
+ bool retval = rewrite_expr_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_expr", expr);
return retval;
}
-static bool rewrite_mem_ref_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
+static bool
+rewrite_mem_ref_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
-static bool rewrite_mem_ref(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+static bool
+rewrite_mem_ref (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_mem_ref", expr);
- bool retval = rewrite_mem_ref_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_mem_ref", expr);
+ log_expr_prologue (indent, "rewrite_mem_ref", expr);
+ bool retval = rewrite_mem_ref_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_mem_ref", expr);
return retval;
}
-static bool rewrite_plus_expr_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_plus_expr(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_plus_expr_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_plus_expr (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_plux_expr", expr);
- bool retval = rewrite_plus_expr_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_plus_expr", expr);
+ log_expr_prologue (indent, "rewrite_plux_expr", expr);
+ bool retval = rewrite_plus_expr_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_plus_expr", expr);
return retval;
}
-static bool rewrite_pointer_diff_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_pointer_diff(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_pointer_diff_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_pointer_diff (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_pointer_diff", expr);
- bool retval = rewrite_pointer_diff_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_pointer_diff", expr);
+ log_expr_prologue (indent, "rewrite_pointer_diff", expr);
+ bool retval = rewrite_pointer_diff_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_pointer_diff", expr);
return retval;
}
-static bool rewrite_pointer_plus_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_pointer_plus(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_pointer_plus_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_pointer_plus (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_pointer_plus", expr);
- bool retval = rewrite_pointer_plus_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_pointer_plus", expr);
+ log_expr_prologue (indent, "rewrite_pointer_plus", expr);
+ bool retval = rewrite_pointer_plus_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_pointer_plus", expr);
return retval;
}
-static bool rewrite_ssa_name_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_ssa_name(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_ssa_name_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_ssa_name (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_ssa_name", expr);
- bool retval = rewrite_ssa_name_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_ssa_name", expr);
+ log_expr_prologue (indent, "rewrite_ssa_name", expr);
+ bool retval = rewrite_ssa_name_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_ssa_name", expr);
return retval;
}
-static bool rewrite_var_decl_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
static bool
-rewrite_var_decl(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_var_decl_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static bool
+rewrite_var_decl (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- log_expr_prologue(indent, "rewrite_var_decl", expr);
- bool retval = rewrite_var_decl_def(expr, type_map, indent+4);
- log_expr_epilogue(indent, "rewrite_var_decl", expr);
+ log_expr_prologue (indent, "rewrite_var_decl", expr);
+ bool retval = rewrite_var_decl_def (expr, type_map, indent + 4);
+ log_expr_epilogue (indent, "rewrite_var_decl", expr);
return retval;
}
static bool
-rewrite_expr_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_expr_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
bool retval = false;
- switch (TREE_CODE(expr))
- {
+ switch (TREE_CODE (expr))
+ {
case ADDR_EXPR:
- retval = rewrite_addr_expr(expr, type_map, indent);
- break;
+ retval = rewrite_addr_expr (expr, type_map, indent);
+ break;
case ARRAY_REF:
- retval = rewrite_array_ref(expr, type_map, indent);
- break;
+ retval = rewrite_array_ref (expr, type_map, indent);
+ break;
case COMPONENT_REF:
- retval = rewrite_component_ref(expr, type_map, indent);
- break;
+ retval = rewrite_component_ref (expr, type_map, indent);
+ break;
case CONSTRUCTOR:
- retval = rewrite_constructor(expr, type_map, indent);
- break;
+ retval = rewrite_constructor (expr, type_map, indent);
+ break;
case FIELD_DECL:
- retval = rewrite_field_decl(expr, type_map, indent);
- break;
+ retval = rewrite_field_decl (expr, type_map, indent);
+ break;
case FUNCTION_DECL:
- retval = rewrite_function_decl(expr, type_map, indent);
- break;
+ retval = rewrite_function_decl (expr, type_map, indent);
+ break;
case INTEGER_CST:
- retval = rewrite_integer_cst(expr, type_map, indent);
- break;
+ retval = rewrite_integer_cst (expr, type_map, indent);
+ break;
case MEM_REF:
- retval = rewrite_mem_ref(expr, type_map, indent);
- break;
+ retval = rewrite_mem_ref (expr, type_map, indent);
+ break;
case MINUS_EXPR:
- retval = rewrite_bin_expr_default(expr, type_map, indent);
- break;
+ retval = rewrite_bin_expr_default (expr, type_map, indent);
+ break;
case MULT_EXPR:
- retval = rewrite_bin_expr_default(expr, type_map, indent);
- break;
+ retval = rewrite_bin_expr_default (expr, type_map, indent);
+ break;
case POINTER_DIFF_EXPR:
- retval = rewrite_pointer_diff(expr, type_map, indent);
- break;
+ retval = rewrite_pointer_diff (expr, type_map, indent);
+ break;
case POINTER_PLUS_EXPR:
- retval = rewrite_pointer_plus(expr, type_map, indent);
- break;
+ retval = rewrite_pointer_plus (expr, type_map, indent);
+ break;
case PLUS_EXPR:
- retval = rewrite_plus_expr(expr, type_map, indent);
- break;
+ retval = rewrite_plus_expr (expr, type_map, indent);
+ break;
case SSA_NAME:
- retval = rewrite_ssa_name(expr, type_map, indent);
- break;
+ retval = rewrite_ssa_name (expr, type_map, indent);
+ break;
case VAR_DECL:
- retval = rewrite_var_decl(expr, type_map, indent);
- break;
+ retval = rewrite_var_decl (expr, type_map, indent);
+ break;
default:
{
- enum tree_code code = TREE_CODE(expr);
- test_log("code = %s", indent, get_tree_code_name(code));
- const_tree *new_type_ptr = type_map.get(TREE_TYPE(expr));
- if (!new_type_ptr) return false;
- retval = true;
- TREE_TYPE(expr) = (tree) *new_type_ptr;
+ enum tree_code code = TREE_CODE (expr);
+ test_log ("code = %s", indent, get_tree_code_name (code));
+ const_tree *new_type_ptr = type_map.get (TREE_TYPE (expr));
+ if (!new_type_ptr)
+ return false;
+ retval = true;
+ TREE_TYPE (expr) = (tree) *new_type_ptr;
}
- break;
- }
+ break;
+ }
return retval;
}
-
inline static void
-test_print_generic_decl(tree decl)
+test_print_generic_decl (tree decl)
{
- if (!dump_file) return;
- print_generic_decl(dump_file, decl, TDF_DETAILS);
+ if (!dump_file)
+ return;
+ print_generic_decl (dump_file, decl, TDF_DETAILS);
}
inline static void
-test_print_gimple_stmt(gimple *stmt)
+test_print_gimple_stmt (gimple *stmt)
{
- if (!dump_file) return;
- print_gimple_stmt(dump_file, stmt, 0, TDF_NONE);
+ if (!dump_file)
+ return;
+ print_gimple_stmt (dump_file, stmt, 0, TDF_NONE);
}
inline static void
-print_function(cgraph_node *cnode)
+print_function (cgraph_node *cnode)
{
- if (!dump_file) return;
- gcc_assert(cnode);
+ if (!dump_file)
+ return;
+ gcc_assert (cnode);
cnode->get_untransformed_body ();
- dump_function_to_file(cnode->decl, dump_file, TDF_NONE);
+ dump_function_to_file (cnode->decl, dump_file, TDF_NONE);
}
static int
-get_field_offset(const_tree field)
+get_field_offset (const_tree field)
{
- gcc_assert(TREE_CODE(field) == FIELD_DECL);
- tree cst = byte_position(field);
- int offset = tree_to_shwi(cst);
+ gcc_assert (TREE_CODE (field) == FIELD_DECL);
+ tree cst = byte_position (field);
+ int offset = tree_to_shwi (cst);
return offset;
}
-
-static const char*
-get_field_name(const_tree field_decl)
+static const char *
+get_field_name (const_tree field_decl)
{
- gcc_assert(field_decl);
- gcc_assert(TREE_CODE(field_decl) == FIELD_DECL);
- //TODO: deal with anonymous fields.
- tree id = DECL_NAME(field_decl);
- if (!id) return "anonymous";
- gcc_assert(id);
- const char* identifier = IDENTIFIER_POINTER(id);
- gcc_assert(identifier);
+ gcc_assert (field_decl);
+ gcc_assert (TREE_CODE (field_decl) == FIELD_DECL);
+ // TODO: deal with anonymous fields.
+ tree id = DECL_NAME (field_decl);
+ if (!id)
+ return "anonymous";
+ gcc_assert (id);
+ const char *identifier = IDENTIFIER_POINTER (id);
+ gcc_assert (identifier);
return identifier;
}
static const_tree
-get_field_with_offset_unsafe(const_tree record, const unsigned offset)
+get_field_with_offset_unsafe (const_tree record, const unsigned offset)
{
- gcc_assert(record);
- gcc_assert(TREE_CODE(record) == RECORD_TYPE);
- for (tree field = TYPE_FIELDS(record); field; field = DECL_CHAIN(field))
- {
- int field_offset = get_field_offset(field);
- if (field_offset == offset) return field;
- }
+ gcc_assert (record);
+ gcc_assert (TREE_CODE (record) == RECORD_TYPE);
+ for (tree field = TYPE_FIELDS (record); field; field = DECL_CHAIN (field))
+ {
+ int field_offset = get_field_offset (field);
+ if (field_offset == offset)
+ return field;
+ }
return NULL;
}
static const_tree
-get_field_with_offset(const_tree record, const unsigned offset)
+get_field_with_offset (const_tree record, const unsigned offset)
{
- const_tree retval = get_field_with_offset_unsafe(record, offset);
- gcc_assert(retval != NULL);
+ const_tree retval = get_field_with_offset_unsafe (record, offset);
+ gcc_assert (retval != NULL);
return retval;
}
static const_tree
-get_field_with_name_unsafe(const_tree record, const char* identifier)
+get_field_with_name_unsafe (const_tree record, const char *identifier)
{
- gcc_assert(record);
- gcc_assert(TREE_CODE(record) == RECORD_TYPE);
- for (tree field = TYPE_FIELDS(record); field; field = DECL_CHAIN(field))
- {
- const char* field_identifier = get_field_name(field);
- const bool is_same_name = strcmp(field_identifier, identifier) == 0;
- if (!is_same_name) continue;
+ gcc_assert (record);
+ gcc_assert (TREE_CODE (record) == RECORD_TYPE);
+ for (tree field = TYPE_FIELDS (record); field; field = DECL_CHAIN (field))
+ {
+ const char *field_identifier = get_field_name (field);
+ const bool is_same_name = strcmp (field_identifier, identifier) == 0;
+ if (!is_same_name)
+ continue;
- gcc_assert(TREE_CODE(field) == FIELD_DECL);
- return field;
- }
+ gcc_assert (TREE_CODE (field) == FIELD_DECL);
+ return field;
+ }
return NULL;
}
static const_tree
-get_field_with_name(const_tree record, const char* identifier)
+get_field_with_name (const_tree record, const char *identifier)
{
- const_tree retval = get_field_with_name_unsafe(record, identifier);
- gcc_assert(retval != NULL);
+ const_tree retval = get_field_with_name_unsafe (record, identifier);
+ gcc_assert (retval != NULL);
return retval;
}
-//TODO: deal with anonymous structs.
-//Some records don't have identifier pointers
-static const char*
-get_record_name(const_tree record)
+// TODO: deal with anonymous structs.
+// Some records don't have identifier pointers
+static const char *
+get_record_name (const_tree record)
{
- gcc_assert(record);
- gcc_assert(TREE_CODE(record) == RECORD_TYPE);
- tree name_tree = TYPE_NAME(record);
+ gcc_assert (record);
+ gcc_assert (TREE_CODE (record) == RECORD_TYPE);
+ tree name_tree = TYPE_NAME (record);
// The TYPE_NAME will be NULL_TREE for a type
// that is not a built-in type, the result of a typedef
// or a named class type.
// TODO: verify that we are never changing
// <name_tree_is_null> types
- if (name_tree == NULL_TREE) { return "<name_tree_is_null>"; }
+ if (name_tree == NULL_TREE)
+ {
+ return "<name_tree_is_null>";
+ }
- if (TREE_CODE(name_tree) == TYPE_DECL) {
- tree original_type = DECL_ORIGINAL_TYPE(name_tree);
- tree type_name = DECL_NAME(name_tree);
- return IDENTIFIER_POINTER(type_name);
- }
- const char* identifier = IDENTIFIER_POINTER(name_tree);
- gcc_assert(identifier);
+ if (TREE_CODE (name_tree) == TYPE_DECL)
+ {
+ tree original_type = DECL_ORIGINAL_TYPE (name_tree);
+ tree type_name = DECL_NAME (name_tree);
+ return IDENTIFIER_POINTER (type_name);
+ }
+ const char *identifier = IDENTIFIER_POINTER (name_tree);
+ gcc_assert (identifier);
return identifier;
}
-static const char*
-get_array_name(const_tree array)
+static const char *
+get_array_name (const_tree array)
{
- gcc_assert(array);
- gcc_assert(TREE_CODE(array) == ARRAY_TYPE);
- const bool is_modified = TYPE_NAME(array);
- if (is_modified) return IDENTIFIER_POINTER(TYPE_NAME(array));
+ gcc_assert (array);
+ gcc_assert (TREE_CODE (array) == ARRAY_TYPE);
+ const bool is_modified = TYPE_NAME (array);
+ if (is_modified)
+ return IDENTIFIER_POINTER (TYPE_NAME (array));
- return make_array_name(array);
+ return make_array_name (array);
}
-static const char*
-get_pointer_name(const_tree pointer)
+static const char *
+get_pointer_name (const_tree pointer)
{
- gcc_assert(pointer);
- gcc_assert(TREE_CODE(pointer) == POINTER_TYPE);
- const bool is_modified = TYPE_NAME(pointer);
- if (is_modified) return IDENTIFIER_POINTER(TYPE_NAME(pointer));
+ gcc_assert (pointer);
+ gcc_assert (TREE_CODE (pointer) == POINTER_TYPE);
+ const bool is_modified = TYPE_NAME (pointer);
+ if (is_modified)
+ return IDENTIFIER_POINTER (TYPE_NAME (pointer));
- const char* new_pointer_name = make_pointer_name(pointer);
+ const char *new_pointer_name = make_pointer_name (pointer);
return new_pointer_name;
}
-static const char*
-get_reference_name(const_tree ref)
+static const char *
+get_reference_name (const_tree ref)
{
- gcc_assert(ref);
- gcc_assert(TREE_CODE(ref) == REFERENCE_TYPE);
- const bool is_modified = TYPE_NAME(ref);
- if (is_modified) return IDENTIFIER_POINTER(TYPE_NAME(ref));
+ gcc_assert (ref);
+ gcc_assert (TREE_CODE (ref) == REFERENCE_TYPE);
+ const bool is_modified = TYPE_NAME (ref);
+ if (is_modified)
+ return IDENTIFIER_POINTER (TYPE_NAME (ref));
- const char* new_pointer_name = make_reference_name(ref);
+ const char *new_pointer_name = make_reference_name (ref);
return new_pointer_name;
}
-static const char*
-get_type_name(const_tree type)
+static const char *
+get_type_name (const_tree type)
{
- enum tree_code code = TREE_CODE(type);
- switch(code)
- {
+ enum tree_code code = TREE_CODE (type);
+ switch (code)
+ {
case ARRAY_TYPE:
- return get_array_name(type);
- break;
+ return get_array_name (type);
+ break;
case POINTER_TYPE:
- return get_pointer_name(type);
- break;
+ return get_pointer_name (type);
+ break;
case RECORD_TYPE:
- return get_record_name(type);
- break;
+ return get_record_name (type);
+ break;
case REFERENCE_TYPE:
- return get_reference_name(type);
- break;
+ return get_reference_name (type);
+ break;
default:
- //TODO: generalize even more?
- //wait for experimental results to dictate what
- //else we should specify.
- return get_tree_code_name(code);
- break;
- }
+ // TODO: generalize even more?
+ // wait for experimental results to dictate what
+ // else we should specify.
+ return get_tree_code_name (code);
+ break;
+ }
return NULL;
}
-static bool filter_out_boring_type(const_tree type, hash_map<const_tree, tree> &map);
+static bool
+filter_out_boring_type (const_tree type, hash_map<const_tree, tree> &map);
static bool
-is_interesting_struct(const_tree record)
+is_interesting_struct (const_tree record)
{
- enum tree_code code = TREE_CODE(record);
- gcc_assert(code == RECORD_TYPE);
+ enum tree_code code = TREE_CODE (record);
+ gcc_assert (code == RECORD_TYPE);
- const char* record_name = get_type_name(record);
+ const char *record_name = get_type_name (record);
const int buffer_size = 1024;
char interesting_structs[buffer_size];
- static const int cli_length = strlen(flag_ipa_typelist_struct);
- gcc_assert(cli_length < buffer_size);
- strcpy(interesting_structs, flag_ipa_typelist_struct);
+ static const int cli_length = strlen (flag_ipa_typelist_struct);
+ gcc_assert (cli_length < buffer_size);
+ strcpy (interesting_structs, flag_ipa_typelist_struct);
bool retval = false;
char *save_ptr;
- char* token = strtok_r(interesting_structs, ",", &save_ptr);
- while(token)
- {
- retval |= strcmp(record_name, token) == 0;
- token = strtok_r(NULL, ",", &save_ptr);
- }
+ char *token = strtok_r (interesting_structs, ",", &save_ptr);
+ while (token)
+ {
+ retval |= strcmp (record_name, token) == 0;
+ token = strtok_r (NULL, ",", &save_ptr);
+ }
return retval;
}
static bool
-is_interesting_field(const_tree field)
+is_interesting_field (const_tree field)
{
- enum tree_code code = TREE_CODE(field);
- gcc_assert(code == FIELD_DECL);
+ enum tree_code code = TREE_CODE (field);
+ gcc_assert (code == FIELD_DECL);
- const char* field_name = get_field_name(field);
+ const char *field_name = get_field_name (field);
const int buffer_size = 1024;
char interesting_fields[buffer_size];
- static const int cli_length = strlen(flag_ipa_typelist_field);
- gcc_assert(cli_length < buffer_size);
- strcpy(interesting_fields, flag_ipa_typelist_field);
+ static const int cli_length = strlen (flag_ipa_typelist_field);
+ gcc_assert (cli_length < buffer_size);
+ strcpy (interesting_fields, flag_ipa_typelist_field);
bool retval = false;
char *save_ptr;
- char* token = strtok_r(interesting_fields, ",", &save_ptr);
- while(token)
- {
- retval |= strcmp(field_name, token) == 0;
- token = strtok_r(NULL, ",", &save_ptr);
- }
+ char *token = strtok_r (interesting_fields, ",", &save_ptr);
+ while (token)
+ {
+ retval |= strcmp (field_name, token) == 0;
+ token = strtok_r (NULL, ",", &save_ptr);
+ }
return retval;
}
static bool
-filter_out_boring_record(const_tree record, hash_map<const_tree, tree> &map)
+filter_out_boring_record (const_tree record, hash_map<const_tree, tree> &map)
{
- test_log("filter_out_boring_record", 0);
- enum tree_code code = TREE_CODE(record);
- gcc_assert(code == RECORD_TYPE);
-
+ test_log ("filter_out_boring_record", 0);
+ enum tree_code code = TREE_CODE (record);
+ gcc_assert (code == RECORD_TYPE);
- for(tree field = TYPE_FIELDS(record); field ; field = DECL_CHAIN(field))
- {
- tree field_type = TREE_TYPE(field);
- enum tree_code field_code = TREE_CODE(field);
- test_log("filter_out_boring_field %s %s", 0, get_type_name(field_type), get_tree_code_name(field_code));
- bool is_boring = filter_out_boring_type(field_type, map);
- if (!is_boring) return false;
- }
+ for (tree field = TYPE_FIELDS (record); field; field = DECL_CHAIN (field))
+ {
+ tree field_type = TREE_TYPE (field);
+ enum tree_code field_code = TREE_CODE (field);
+ test_log ("filter_out_boring_field %s %s", 0, get_type_name (field_type),
+ get_tree_code_name (field_code));
+ bool is_boring = filter_out_boring_type (field_type, map);
+ if (!is_boring)
+ return false;
+ }
- return !is_interesting_struct(record);
+ return !is_interesting_struct (record);
}
static bool
-filter_out_boring_pointer(const_tree pointer, hash_map<const_tree, tree>&map)
+filter_out_boring_pointer (const_tree pointer, hash_map<const_tree, tree> &map)
{
- test_log("filter_out_boring_pointer", 0);
- enum tree_code code = TREE_CODE(pointer);
- gcc_assert(code == POINTER_TYPE);
- const_tree base_type = get_base_type_from_pointer_type(pointer);
- return filter_out_boring_type(base_type, map);
+ test_log ("filter_out_boring_pointer", 0);
+ enum tree_code code = TREE_CODE (pointer);
+ gcc_assert (code == POINTER_TYPE);
+ const_tree base_type = get_base_type_from_pointer_type (pointer);
+ return filter_out_boring_type (base_type, map);
}
static bool
-filter_out_boring_array(const_tree array, hash_map<const_tree, tree>&map)
+filter_out_boring_array (const_tree array, hash_map<const_tree, tree> &map)
{
- enum tree_code code = TREE_CODE(array);
- gcc_assert(code == ARRAY_TYPE);
- const_tree base_type = get_base_type_from_array_type(array);
- return filter_out_boring_type(base_type, map);
+ enum tree_code code = TREE_CODE (array);
+ gcc_assert (code == ARRAY_TYPE);
+ const_tree base_type = get_base_type_from_array_type (array);
+ return filter_out_boring_type (base_type, map);
}
static bool
-filter_out_boring_reference(const_tree ref, hash_map<const_tree, tree>&map)
+filter_out_boring_reference (const_tree ref, hash_map<const_tree, tree> &map)
{
- enum tree_code code = TREE_CODE(ref);
- gcc_assert(code == REFERENCE_TYPE);
- test_log("in filter out boring reference", 0);
- bool retval = filter_out_boring_type(TREE_TYPE(ref), map);
- if (retval) { test_log("we are getting a reference", 0); }
+ enum tree_code code = TREE_CODE (ref);
+ gcc_assert (code == REFERENCE_TYPE);
+ test_log ("in filter out boring reference", 0);
+ bool retval = filter_out_boring_type (TREE_TYPE (ref), map);
+ if (retval)
+ {
+ test_log ("we are getting a reference", 0);
+ }
return retval;
}
-
static bool
-filter_out_boring_type(const_tree type, hash_map<const_tree, tree> &map)
+filter_out_boring_type (const_tree type, hash_map<const_tree, tree> &map)
{
- if (!type) {
- test_log("filter_out_boring_type (NULL)", 0);
- return true;
- }
+ if (!type)
+ {
+ test_log ("filter_out_boring_type (NULL)", 0);
+ return true;
+ }
// maybe something like, if the type is
// equivalent to one of the already
@@ -893,292 +986,330 @@ filter_out_boring_type(const_tree type, hash_map<const_tree, tree> &map)
// then we receive type B which is interesting
// this approach would fail...
- enum tree_code code = TREE_CODE(type);
- const char *type_name = get_type_name(type);
- test_log("filter_out_boring_type %s %s", 0, type_name, get_tree_code_name(code));
- if (strcmp(type_name, "indirect_call_tuple") == 0) return true;
+ enum tree_code code = TREE_CODE (type);
+ const char *type_name = get_type_name (type);
+ test_log ("filter_out_boring_type %s %s", 0, type_name,
+ get_tree_code_name (code));
+ if (strcmp (type_name, "indirect_call_tuple") == 0)
+ return true;
bool retval = true;
- switch(code)
- {
- case ARRAY_TYPE:
- retval = filter_out_boring_array(type, map);
- break;
- case POINTER_TYPE:
- retval = filter_out_boring_pointer(type, map);
- break;
- case RECORD_TYPE:
- retval = filter_out_boring_record(type, map);
- break;
- case REFERENCE_TYPE:
- retval = filter_out_boring_reference(type, map);
- break;
- default:
+ switch (code)
{
- test_log("default in tree code %s", 0, get_tree_code_name(code));
- retval = true;
+ case ARRAY_TYPE:
+ retval = filter_out_boring_array (type, map);
+ break;
+ case POINTER_TYPE:
+ retval = filter_out_boring_pointer (type, map);
+ break;
+ case RECORD_TYPE:
+ retval = filter_out_boring_record (type, map);
+ break;
+ case REFERENCE_TYPE:
+ retval = filter_out_boring_reference (type, map);
+ break;
+ default:
+ {
+ test_log ("default in tree code %s", 0, get_tree_code_name (code));
+ retval = true;
+ }
+ break;
}
- break;
- }
- if (!retval) {
- test_log("putting %s", 0, get_type_name(type));
- map.put(type, NULL);
- }
+ if (!retval)
+ {
+ test_log ("putting %s", 0, get_type_name (type));
+ map.put (type, NULL);
+ }
return retval;
}
static bool
-filter_var_decls(tree var_decl, hash_map<const_tree, tree> &type_map)
+filter_var_decls (tree var_decl, hash_map<const_tree, tree> &type_map)
{
- gcc_assert(var_decl);
- gcc_assert(TREE_CODE(var_decl) == VAR_DECL);
- tree type = TREE_TYPE(var_decl);
- return filter_out_boring_type(type, type_map);
+ gcc_assert (var_decl);
+ gcc_assert (TREE_CODE (var_decl) == VAR_DECL);
+ tree type = TREE_TYPE (var_decl);
+ return filter_out_boring_type (type, type_map);
}
static bool
-filter_parm_decls(tree parm_decl, hash_map<const_tree, tree>& type_map)
+filter_parm_decls (tree parm_decl, hash_map<const_tree, tree> &type_map)
{
- gcc_assert(parm_decl);
- gcc_assert(TREE_CODE(parm_decl) == PARM_DECL);
- tree type = TREE_TYPE(parm_decl);
- return filter_out_boring_type(type, type_map);
+ gcc_assert (parm_decl);
+ gcc_assert (TREE_CODE (parm_decl) == PARM_DECL);
+ tree type = TREE_TYPE (parm_decl);
+ return filter_out_boring_type (type, type_map);
}
static bool
-filter_ssa_decls(tree ssa, hash_map<const_tree, tree>& type_map)
+filter_ssa_decls (tree ssa, hash_map<const_tree, tree> &type_map)
{
- tree type = TREE_TYPE(ssa);
- test_log("in SSA decl %s", 0, get_type_name(type));
- return filter_out_boring_type(type, type_map);
+ tree type = TREE_TYPE (ssa);
+ test_log ("in SSA decl %s", 0, get_type_name (type));
+ return filter_out_boring_type (type, type_map);
}
static bool
-collect_ssa_decls(cgraph_node *cnode, bool (*filter)(tree, hash_map<const_tree, tree>&), hash_map<const_tree, tree>& decl_map)
+collect_ssa_decls (cgraph_node *cnode,
+ bool (*filter) (tree, hash_map<const_tree, tree> &),
+ hash_map<const_tree, tree> &decl_map)
{
unsigned i;
tree name;
- push_cfun(DECL_STRUCT_FUNCTION(cnode->decl));
- cnode->get_untransformed_body();
- if (!cnode->decl) return false;
+ push_cfun (DECL_STRUCT_FUNCTION (cnode->decl));
+ cnode->get_untransformed_body ();
+ if (!cnode->decl)
+ return false;
FOR_EACH_SSA_NAME (i, name, cfun)
{
- bool filter_out = (*filter)(name, decl_map);
- if (filter_out) continue;
+ bool filter_out = (*filter) (name, decl_map);
+ if (filter_out)
+ continue;
- tree type = TREE_TYPE(name);
- tree *ptr = decl_map.get(type);
- if (ptr) continue;
+ tree type = TREE_TYPE (name);
+ tree *ptr = decl_map.get (type);
+ if (ptr)
+ continue;
- const char* type_identifier = get_type_name(type);
- test_log("collecting,%s", 0, type_identifier);
- decl_map.put(type, NULL);
+ const char *type_identifier = get_type_name (type);
+ test_log ("collecting,%s", 0, type_identifier);
+ decl_map.put (type, NULL);
}
- pop_cfun();
+ pop_cfun ();
return false;
-
}
static void
-collect_parm_declarations(cgraph_node *cnode, bool (*filter)(tree, hash_map<const_tree, tree>&), hash_map<const_tree, tree> &decl_map)
+collect_parm_declarations (cgraph_node *cnode,
+ bool (*filter) (tree, hash_map<const_tree, tree> &),
+ hash_map<const_tree, tree> &decl_map)
{
- gcc_assert(cnode);
- //TODO: Do we need to get_untransformed_body_here?
- for (tree parm = DECL_ARGUMENTS(cnode->decl); parm; parm = DECL_CHAIN(parm))
- {
- bool filter_out = (*filter)(parm, decl_map);
- if (filter_out) continue;
-
- tree type = TREE_TYPE(parm);
- tree *ptr = decl_map.get(type);
- // We already have this type.
- if (ptr) continue;
-
- const char* type_identifier = get_type_name(type);
- test_log("collecting,%s", 0, type_identifier);
- decl_map.put(type, NULL);
- }
+ gcc_assert (cnode);
+ // TODO: Do we need to get_untransformed_body_here?
+ for (tree parm = DECL_ARGUMENTS (cnode->decl); parm; parm = DECL_CHAIN (parm))
+ {
+ bool filter_out = (*filter) (parm, decl_map);
+ if (filter_out)
+ continue;
+
+ tree type = TREE_TYPE (parm);
+ tree *ptr = decl_map.get (type);
+ // We already have this type.
+ if (ptr)
+ continue;
+
+ const char *type_identifier = get_type_name (type);
+ test_log ("collecting,%s", 0, type_identifier);
+ decl_map.put (type, NULL);
+ }
}
static void
-collect_pointer_plus(tree lhs, tree rhs1, tree rhs2, hash_map<const_tree, tree> &decl_map)
-{
- tree lhs_type = lhs ? TREE_TYPE(lhs) : NULL;
- bool is_lhs_boring = lhs_type ? filter_out_boring_type(lhs_type, decl_map) : true;
- tree rhs1_type = rhs1 ? TREE_TYPE(rhs1) : NULL;
- bool is_rhs1_boring = rhs1_type ? filter_out_boring_type(rhs1_type, decl_map) : true;
- tree rhs2_type = rhs2 ? TREE_TYPE(rhs2) : NULL;
- bool is_rhs2_boring = rhs2_type ? filter_out_boring_type(rhs2_type, decl_map) : true;
-
- if (!is_lhs_boring) { test_log("putting lhs %s", 0, get_type_name(lhs_type)); decl_map.put(lhs_type, NULL); }
- if (!is_rhs1_boring) { test_log("putting rhs1 %s", 0, get_type_name(rhs1_type)); decl_map.put(rhs1_type, NULL); }
- if (!is_rhs2_boring) { test_log("putting rhs2 %s", 0, get_type_name(rhs2_type)); decl_map.put(rhs2_type, NULL); }
+collect_pointer_plus (tree lhs, tree rhs1, tree rhs2,
+ hash_map<const_tree, tree> &decl_map)
+{
+ tree lhs_type = lhs ? TREE_TYPE (lhs) : NULL;
+ bool is_lhs_boring
+ = lhs_type ? filter_out_boring_type (lhs_type, decl_map) : true;
+ tree rhs1_type = rhs1 ? TREE_TYPE (rhs1) : NULL;
+ bool is_rhs1_boring
+ = rhs1_type ? filter_out_boring_type (rhs1_type, decl_map) : true;
+ tree rhs2_type = rhs2 ? TREE_TYPE (rhs2) : NULL;
+ bool is_rhs2_boring
+ = rhs2_type ? filter_out_boring_type (rhs2_type, decl_map) : true;
+
+ if (!is_lhs_boring)
+ {
+ test_log ("putting lhs %s", 0, get_type_name (lhs_type));
+ decl_map.put (lhs_type, NULL);
+ }
+ if (!is_rhs1_boring)
+ {
+ test_log ("putting rhs1 %s", 0, get_type_name (rhs1_type));
+ decl_map.put (rhs1_type, NULL);
+ }
+ if (!is_rhs2_boring)
+ {
+ test_log ("putting rhs2 %s", 0, get_type_name (rhs2_type));
+ decl_map.put (rhs2_type, NULL);
+ }
}
static void
-collect_assign_rhs(gimple *stmt, hash_map<const_tree, tree> &decl_map)
+collect_assign_rhs (gimple *stmt, hash_map<const_tree, tree> &decl_map)
{
bool is_stmt_rewritten = false;
- enum tree_code code = gimple_expr_code(stmt);
- switch(code)
- {
+ enum tree_code code = gimple_expr_code (stmt);
+ switch (code)
+ {
case POINTER_PLUS_EXPR:
case POINTER_DIFF_EXPR:
case COMPONENT_REF:
{
- tree rhs2 = gimple_assign_rhs2(stmt);
- tree rhs1 = gimple_assign_rhs1(stmt);
- tree lhs = gimple_assign_lhs(stmt);
- collect_pointer_plus(lhs, rhs1, rhs2, decl_map);
+ tree rhs2 = gimple_assign_rhs2 (stmt);
+ tree rhs1 = gimple_assign_rhs1 (stmt);
+ tree lhs = gimple_assign_lhs (stmt);
+ collect_pointer_plus (lhs, rhs1, rhs2, decl_map);
}
- break;
+ break;
default:
- {
- print_gimple_stmt(dump_file, stmt, 0);
- test_log("DEFAULT HERE: %s", 0, get_tree_code_name(code));
+ {
+ print_gimple_stmt (dump_file, stmt, 0);
+ test_log ("DEFAULT HERE: %s", 0, get_tree_code_name (code));
+ }
+ break;
}
- break;
- }
}
static void
-collect_assign(gimple *stmt, hash_map<const_tree, tree> &decl_map)
+collect_assign (gimple *stmt, hash_map<const_tree, tree> &decl_map)
{
- gcc_assert(stmt);
+ gcc_assert (stmt);
tree lhs = gimple_assign_lhs (stmt);
- collect_assign_rhs(stmt, decl_map);
+ collect_assign_rhs (stmt, decl_map);
}
static void
-collect_stmt(gimple*stmt, hash_map<const_tree, tree> &decl_map)
+collect_stmt (gimple *stmt, hash_map<const_tree, tree> &decl_map)
{
- gcc_assert(stmt);
- const enum gimple_code code = gimple_code(stmt);
+ gcc_assert (stmt);
+ const enum gimple_code code = gimple_code (stmt);
switch (code)
- {
+ {
case GIMPLE_ASSIGN:
- collect_assign(stmt, decl_map);
- break;
+ collect_assign (stmt, decl_map);
+ break;
default:
- break;
- }
+ break;
+ }
return;
}
static void
-collect_basic_block(basic_block bb, hash_map<const_tree, tree> &decl_map)
+collect_basic_block (basic_block bb, hash_map<const_tree, tree> &decl_map)
{
- gcc_assert(bb);
- for (gimple_stmt_iterator gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi))
- {
- gimple *stmt = gsi_stmt(gsi);
- collect_stmt(stmt, decl_map);
- }
+ gcc_assert (bb);
+ for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gimple *stmt = gsi_stmt (gsi);
+ collect_stmt (stmt, decl_map);
+ }
}
static void
-collect_function_body(cgraph_node *cnode, hash_map<const_tree, tree> &decl_map)
+collect_function_body (cgraph_node *cnode, hash_map<const_tree, tree> &decl_map)
{
- gcc_assert(cnode);
- cnode->get_untransformed_body();
+ gcc_assert (cnode);
+ cnode->get_untransformed_body ();
basic_block bb = NULL;
function *func = DECL_STRUCT_FUNCTION (cnode->decl);
- push_cfun(func);
+ push_cfun (func);
FOR_EACH_BB_FN (bb, func)
- {
- collect_basic_block(bb, decl_map);
- }
- pop_cfun();
- print_function(cnode);
+ {
+ collect_basic_block (bb, decl_map);
+ }
+ pop_cfun ();
+ print_function (cnode);
}
-//TODO: It would be nice to have this as an iterator
-//TODO: Maybe after the filter, there should be
-//a function that takes a type and gets you
-//an identifier string.
+// TODO: It would be nice to have this as an iterator
+// TODO: Maybe after the filter, there should be
+// a function that takes a type and gets you
+// an identifier string.
static void
-collect_local_declarations(cgraph_node* cnode, bool (*filter)(tree, hash_map<const_tree, tree>&), hash_map<const_tree, tree> &decl_map)
+collect_local_declarations (cgraph_node *cnode,
+ bool (*filter) (tree, hash_map<const_tree, tree> &),
+ hash_map<const_tree, tree> &decl_map)
{
- gcc_assert(cnode);
+ gcc_assert (cnode);
int i = 0;
- function *func = DECL_STRUCT_FUNCTION(cnode->decl);
- //TODO: What condition do I need to check for this one?
- cnode->get_untransformed_body();
+ function *func = DECL_STRUCT_FUNCTION (cnode->decl);
+ // TODO: What condition do I need to check for this one?
+ cnode->get_untransformed_body ();
tree var_decl = NULL;
- FOR_EACH_LOCAL_DECL(func, i, var_decl)
- {
- bool filter_out = (*filter)(var_decl, decl_map);
- if (filter_out) continue;
-
- tree type = TREE_TYPE(var_decl);
- const char* type_identifier = get_type_name(type);
- test_log("collecting,%s", 0, type_identifier);
- decl_map.put(type, NULL);
- }
+ FOR_EACH_LOCAL_DECL (func, i, var_decl)
+ {
+ bool filter_out = (*filter) (var_decl, decl_map);
+ if (filter_out)
+ continue;
+
+ tree type = TREE_TYPE (var_decl);
+ const char *type_identifier = get_type_name (type);
+ test_log ("collecting,%s", 0, type_identifier);
+ decl_map.put (type, NULL);
+ }
}
static void
-collect_global_declaration(varpool_node* vnode, bool (*filter)(tree, hash_map<const_tree, tree>&), hash_map<const_tree, tree> &decl_map)
+collect_global_declaration (varpool_node *vnode,
+ bool (*filter) (tree, hash_map<const_tree, tree> &),
+ hash_map<const_tree, tree> &decl_map)
{
- test_log("collect global declarations", 0);
+ test_log ("collect global declarations", 0);
int i;
struct ipa_ref *ref;
/* Only IPA_REF_STORE and IPA_REF_LOAD left. */
for (i = 0; vnode->iterate_referring (i, ref); i++)
- {
- symtab_node *f_node = ref->referring;
- cgraph_node *f_cnode = dyn_cast<cgraph_node *> (f_node);
-
- // TODO: place assertion for interesting ones
- // interesting types MUST have functions?
- /*
- if (!f_cnode)
{
- if (dump_file) fprintf (dump_file, "skipping variable %s due to static initialization\n", vnode->name ());
- return;
+ symtab_node *f_node = ref->referring;
+ cgraph_node *f_cnode = dyn_cast<cgraph_node *> (f_node);
+
+ // TODO: place assertion for interesting ones
+ // interesting types MUST have functions?
+ /*
+ if (!f_cnode)
+ {
+ if (dump_file) fprintf (dump_file, "skipping variable %s due to static
+ initialization\n", vnode->name ()); return;
+ }
+ */
+
+ bool filter_out = (*filter) (vnode->decl, decl_map);
+ if (filter_out)
+ {
+ test_log ("filter out", 0);
+ continue;
+ }
+
+ tree type = TREE_TYPE (vnode->decl);
+ const char *type_identifier = get_type_name (type);
+ test_log ("collecting,%s", 0, type_identifier);
+ decl_map.put (type, NULL);
}
- */
-
- bool filter_out = (*filter)(vnode->decl, decl_map);
- if (filter_out) { test_log("filter out", 0); continue; }
-
- tree type = TREE_TYPE(vnode->decl);
- const char* type_identifier = get_type_name(type);
- test_log("collecting,%s", 0, type_identifier);
- decl_map.put(type, NULL);
-
- }
}
static void
-collect_global_declarations(bool (*filter)(tree, hash_map<const_tree, tree>&), hash_map<const_tree, tree> &decl_map)
+collect_global_declarations (bool (*filter) (tree,
+ hash_map<const_tree, tree> &),
+ hash_map<const_tree, tree> &decl_map)
{
varpool_node *vnode;
- FOR_EACH_VARIABLE(vnode)
- {
- collect_global_declaration(vnode, filter, decl_map);
- }
+ FOR_EACH_VARIABLE (vnode)
+ {
+ collect_global_declaration (vnode, filter, decl_map);
+ }
}
static void
-collect_orig_structs(hash_map<const_tree, tree> &type_map)
+collect_orig_structs (hash_map<const_tree, tree> &type_map)
{
- collect_global_declarations(&filter_var_decls, type_map);
+ collect_global_declarations (&filter_var_decls, type_map);
cgraph_node *cnode = NULL;
- FOR_EACH_DEFINED_FUNCTION(cnode)
- {
- print_function(cnode);
- collect_parm_declarations(cnode, &filter_parm_decls, type_map);
- collect_function_body(cnode, type_map);
- collect_local_declarations(cnode, &filter_var_decls, type_map);
- }
+ FOR_EACH_DEFINED_FUNCTION (cnode)
+ {
+ print_function (cnode);
+ collect_parm_declarations (cnode, &filter_parm_decls, type_map);
+ collect_function_body (cnode, type_map);
+ collect_local_declarations (cnode, &filter_var_decls, type_map);
+ }
}
-
-
-static const_tree make_new_type_based_on_old(const_tree old, hash_map<const_tree, const_tree>* mod_type_map);
+static const_tree
+make_new_type_based_on_old (const_tree old,
+ hash_map<const_tree, const_tree> *mod_type_map);
/*
* This method will copy the parameter
@@ -1187,231 +1318,242 @@ static const_tree make_new_type_based_on_old(const_tree old, hash_map<const_tree
* to account for the deleted parameter
*/
static const_tree
-make_new_record_based_on_old(const_tree old,
- hash_map<const_tree, const_tree>* mod_type_map)
+make_new_record_based_on_old (const_tree old,
+ hash_map<const_tree, const_tree> *mod_type_map)
{
- const_tree *new_record_ptr = mod_type_map->get(old);
- gcc_assert(!new_record_ptr);
+ const_tree *new_record_ptr = mod_type_map->get (old);
+ gcc_assert (!new_record_ptr);
- //TODO: You will not have this guarantee in the end,
- //we need an API to let this method know which structs will be
- //deleted, or someting similar to that.
- const char* old_name = get_type_name(old);
- bool will_definitely_change = is_interesting_struct(old);
+ // TODO: You will not have this guarantee in the end,
+ // we need an API to let this method know which structs will be
+ // deleted, or someting similar to that.
+ const char *old_name = get_type_name (old);
+ bool will_definitely_change = is_interesting_struct (old);
- tree new_record = make_node(RECORD_TYPE);
- const char* new_name = make_record_name_based_on_old(old_name);
- tree new_record_name = get_identifier(new_name);
- TYPE_NAME(new_record) = new_record_name;
+ tree new_record = make_node (RECORD_TYPE);
+ const char *new_name = make_record_name_based_on_old (old_name);
+ tree new_record_name = get_identifier (new_name);
+ TYPE_NAME (new_record) = new_record_name;
tree prev_new_field = NULL;
- for(tree old_field = TYPE_FIELDS(old); old_field; old_field = DECL_CHAIN(old_field))
- {
- const bool are_field_names_equal = is_interesting_field(old_field);
-
- if (are_field_names_equal && will_definitely_change) {
- continue;
- }
-
- tree new_field = make_node(FIELD_DECL);
- DECL_NAME(new_field) = DECL_NAME(old_field);
- tree old_field_type = TREE_TYPE(old_field);
- const_tree new_field_type = make_new_type_based_on_old(TREE_TYPE(old_field), mod_type_map);
- test_log("inside making new field, %s %s", 0, get_type_name(old_field_type), get_type_name(new_field_type));
- const_tree maybe_new_field = new_field_type == old_field ? old_field : new_field_type;
- TREE_TYPE(new_field) = (tree) maybe_new_field;
- DECL_SOURCE_LOCATION(new_field) = DECL_SOURCE_LOCATION(old_field);
- SET_DECL_ALIGN(new_field, DECL_ALIGN(old_field));
- DECL_USER_ALIGN(new_field) = DECL_ALIGN(old_field);
- TREE_ADDRESSABLE (new_field) = TREE_ADDRESSABLE (old_field);
- DECL_NONADDRESSABLE_P (new_field) = !TREE_ADDRESSABLE (old_field);
- TREE_THIS_VOLATILE (new_field) = TREE_THIS_VOLATILE (old_field);
- // DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET
- // are actually set by layout_type.
- const bool first_new_field = !prev_new_field;
- if (first_new_field)
- {
- TYPE_FIELDS(new_record) = new_field;
- }
- else
+ for (tree old_field = TYPE_FIELDS (old); old_field;
+ old_field = DECL_CHAIN (old_field))
{
- DECL_CHAIN(prev_new_field) = new_field;
+ const bool are_field_names_equal = is_interesting_field (old_field);
+
+ if (are_field_names_equal && will_definitely_change)
+ {
+ continue;
+ }
+
+ tree new_field = make_node (FIELD_DECL);
+ DECL_NAME (new_field) = DECL_NAME (old_field);
+ tree old_field_type = TREE_TYPE (old_field);
+ const_tree new_field_type
+ = make_new_type_based_on_old (TREE_TYPE (old_field), mod_type_map);
+ test_log ("inside making new field, %s %s", 0,
+ get_type_name (old_field_type), get_type_name (new_field_type));
+ const_tree maybe_new_field
+ = new_field_type == old_field ? old_field : new_field_type;
+ TREE_TYPE (new_field) = (tree) maybe_new_field;
+ DECL_SOURCE_LOCATION (new_field) = DECL_SOURCE_LOCATION (old_field);
+ SET_DECL_ALIGN (new_field, DECL_ALIGN (old_field));
+ DECL_USER_ALIGN (new_field) = DECL_ALIGN (old_field);
+ TREE_ADDRESSABLE (new_field) = TREE_ADDRESSABLE (old_field);
+ DECL_NONADDRESSABLE_P (new_field) = !TREE_ADDRESSABLE (old_field);
+ TREE_THIS_VOLATILE (new_field) = TREE_THIS_VOLATILE (old_field);
+ // DECL_FIELD_OFFSET and DECL_FIELD_BIT_OFFSET
+ // are actually set by layout_type.
+ const bool first_new_field = !prev_new_field;
+ if (first_new_field)
+ {
+ TYPE_FIELDS (new_record) = new_field;
+ }
+ else
+ {
+ DECL_CHAIN (prev_new_field) = new_field;
+ }
+
+ prev_new_field = new_field;
}
- prev_new_field = new_field;
- }
-
-
- layout_type(new_record);
-
+ layout_type (new_record);
- for(tree new_field = TYPE_FIELDS(new_record); new_field; new_field= DECL_CHAIN(new_field))
- {
- const char* new_field_name = get_field_name(new_field);
- int new_offset = get_field_offset(new_field);
- test_log("offset,%s,%s,%d", 0, new_name, new_field_name, new_offset);
- }
-
- const_tree *ptr = mod_type_map->get(old);
- if (ptr) return *ptr;
+ for (tree new_field = TYPE_FIELDS (new_record); new_field;
+ new_field = DECL_CHAIN (new_field))
+ {
+ const char *new_field_name = get_field_name (new_field);
+ int new_offset = get_field_offset (new_field);
+ test_log ("offset,%s,%s,%d", 0, new_name, new_field_name, new_offset);
+ }
+ const_tree *ptr = mod_type_map->get (old);
+ if (ptr)
+ return *ptr;
- //WONTFIX: Think about: Create pointers and arrays to record up to a limit...
- //Will this ensure that typedefs shouldn't matter, up to the limit?
- //No, because we do not have the old type to provide a map between the old
- //and the new...
+ // WONTFIX: Think about: Create pointers and arrays to record up to a limit...
+ // Will this ensure that typedefs shouldn't matter, up to the limit?
+ // No, because we do not have the old type to provide a map between the old
+ // and the new...
- mod_type_map->put(old, new_record);
+ mod_type_map->put (old, new_record);
return new_record;
}
const_tree
-make_new_array_based_on_old(const_tree old_type,
- hash_map<const_tree, const_tree>* mod_type_map)
-{
- gcc_assert(TREE_CODE(old_type) == ARRAY_TYPE);
- const_tree *new_type_ptr = mod_type_map->get(old_type);
- gcc_assert(!new_type_ptr);
-
- const char* ptr = make_array_name_based_on_old(old_type);
- tree new_array = make_node(ARRAY_TYPE);
- TYPE_NAME(new_array) = get_identifier(ptr);
- TYPE_DOMAIN(new_array) = TYPE_DOMAIN(old_type);
- tree old_array_type = TREE_TYPE(old_type);
- const_tree possibly_new = make_new_type_based_on_old(old_array_type, mod_type_map);
- if (possibly_new == old_array_type) return old_type;
- TREE_TYPE(new_array) = (tree) possibly_new;
- layout_type(new_array);
-
- const_tree *ptr_2 = mod_type_map->get(old_type);
- if (ptr_2) return *ptr_2;
-
- mod_type_map->put(old_type, new_array);
+make_new_array_based_on_old (const_tree old_type,
+ hash_map<const_tree, const_tree> *mod_type_map)
+{
+ gcc_assert (TREE_CODE (old_type) == ARRAY_TYPE);
+ const_tree *new_type_ptr = mod_type_map->get (old_type);
+ gcc_assert (!new_type_ptr);
+
+ const char *ptr = make_array_name_based_on_old (old_type);
+ tree new_array = make_node (ARRAY_TYPE);
+ TYPE_NAME (new_array) = get_identifier (ptr);
+ TYPE_DOMAIN (new_array) = TYPE_DOMAIN (old_type);
+ tree old_array_type = TREE_TYPE (old_type);
+ const_tree possibly_new
+ = make_new_type_based_on_old (old_array_type, mod_type_map);
+ if (possibly_new == old_array_type)
+ return old_type;
+ TREE_TYPE (new_array) = (tree) possibly_new;
+ layout_type (new_array);
+
+ const_tree *ptr_2 = mod_type_map->get (old_type);
+ if (ptr_2)
+ return *ptr_2;
+
+ mod_type_map->put (old_type, new_array);
return new_array;
}
-
static const_tree
-make_new_pointer_based_on_old(const_tree old,
- hash_map<const_tree, const_tree>* mod_type_map)
+make_new_pointer_based_on_old (const_tree old,
+ hash_map<const_tree, const_tree> *mod_type_map)
{
- test_log("make_new_pointer_based_on_old %s", 0, get_type_name(old));
- const_tree *already_computed = mod_type_map->get(old);
- gcc_assert(!already_computed);
+ test_log ("make_new_pointer_based_on_old %s", 0, get_type_name (old));
+ const_tree *already_computed = mod_type_map->get (old);
+ gcc_assert (!already_computed);
- gcc_assert(TREE_CODE(old) == POINTER_TYPE);
+ gcc_assert (TREE_CODE (old) == POINTER_TYPE);
- tree new_pointer = make_node(POINTER_TYPE);
- const char* ptr = make_pointer_name_based_on_old(old);
+ tree new_pointer = make_node (POINTER_TYPE);
+ const char *ptr = make_pointer_name_based_on_old (old);
- TYPE_NAME(new_pointer) = get_identifier(ptr);
- SET_TYPE_MODE(new_pointer, TYPE_MODE(old));
- tree old_type = TREE_TYPE(old);
- gcc_assert(old_type);
- const_tree new_type = make_new_type_based_on_old(old_type, mod_type_map);
- //We do not need it...
- if (new_type == old_type) return old;
+ TYPE_NAME (new_pointer) = get_identifier (ptr);
+ SET_TYPE_MODE (new_pointer, TYPE_MODE (old));
+ tree old_type = TREE_TYPE (old);
+ gcc_assert (old_type);
+ const_tree new_type = make_new_type_based_on_old (old_type, mod_type_map);
+ // We do not need it...
+ if (new_type == old_type)
+ return old;
- TREE_TYPE(new_pointer) = (tree) new_type;
- layout_type(new_pointer);
+ TREE_TYPE (new_pointer) = (tree) new_type;
+ layout_type (new_pointer);
- const_tree *ptr_2 = mod_type_map->get(old);
- if (ptr_2) return *ptr_2;
+ const_tree *ptr_2 = mod_type_map->get (old);
+ if (ptr_2)
+ return *ptr_2;
- mod_type_map->put(old, new_pointer);
- test_log("putting %s %s", 0, get_type_name(old), get_type_name(new_pointer));
+ mod_type_map->put (old, new_pointer);
+ test_log ("putting %s %s", 0, get_type_name (old),
+ get_type_name (new_pointer));
return new_pointer;
-
}
-//TODO:
-//This needs a new parameter that allows
-//us to say **how** we modify the type.
-//Not all information can be derived
-//only from the old type.
-//This is only possible now because we are
-//basically hard coding examples.
+// TODO:
+// This needs a new parameter that allows
+// us to say **how** we modify the type.
+// Not all information can be derived
+// only from the old type.
+// This is only possible now because we are
+// basically hard coding examples.
static const_tree
-make_new_type_based_on_old(const_tree old,
- hash_map<const_tree, const_tree>* mod_type_map)
+make_new_type_based_on_old (const_tree old,
+ hash_map<const_tree, const_tree> *mod_type_map)
{
+ if (!old)
+ return old;
- if (!old) return old;
+ gcc_assert (old);
+ const_tree *new_base_ptr = mod_type_map->get (old);
+ if (new_base_ptr)
+ return *new_base_ptr;
- gcc_assert(old);
- const_tree *new_base_ptr = mod_type_map->get(old);
- if (new_base_ptr) return *new_base_ptr;
-
- switch(TREE_CODE(old))
- {
+ switch (TREE_CODE (old))
+ {
case ARRAY_TYPE:
- return make_new_array_based_on_old(old, mod_type_map);
- break;
+ return make_new_array_based_on_old (old, mod_type_map);
+ break;
case POINTER_TYPE:
- return make_new_pointer_based_on_old(old, mod_type_map);
- break;
+ return make_new_pointer_based_on_old (old, mod_type_map);
+ break;
case RECORD_TYPE:
- return make_new_record_based_on_old(old, mod_type_map);
- break;
+ return make_new_record_based_on_old (old, mod_type_map);
+ break;
default:
return old;
- break;
- }
- gcc_unreachable();
+ break;
+ }
+ gcc_unreachable ();
return NULL;
}
-
-//Non-null values for type_map
-//will be the modified tree.
+// Non-null values for type_map
+// will be the modified tree.
bool
-compute_modified_structs_internal(const_tree const & old_type,
- tree* new_type,
- hash_map<const_tree, const_tree>* mod_type_map)
+compute_modified_structs_internal (
+ const_tree const &old_type, tree *new_type,
+ hash_map<const_tree, const_tree> *mod_type_map)
{
-
- const_tree *ptr = mod_type_map->get(old_type);
+ const_tree *ptr = mod_type_map->get (old_type);
// already in map
- if (ptr) return true;
+ if (ptr)
+ return true;
- const char* identifier = get_type_name(old_type);
- test_log("modifying,%s", 0, identifier);
+ const char *identifier = get_type_name (old_type);
+ test_log ("modifying,%s", 0, identifier);
- const_tree new_record = make_new_type_based_on_old(old_type, mod_type_map);
+ const_tree new_record = make_new_type_based_on_old (old_type, mod_type_map);
// We might have modified the mod_type_map inside make_new_type_based_on_old
// and therefore we no longer have the need to store this there again...
- const_tree *ptr_2 = mod_type_map->get(old_type);
- if (ptr_2) return true;
+ const_tree *ptr_2 = mod_type_map->get (old_type);
+ if (ptr_2)
+ return true;
- test_log("new_name,%s", 0, get_type_name(new_record));
- mod_type_map->put(old_type, new_record);
+ test_log ("new_name,%s", 0, get_type_name (new_record));
+ mod_type_map->put (old_type, new_record);
return true;
}
static void
-compute_modified_structs(hash_map<const_tree, tree> &type_map,
- hash_map<const_tree, const_tree> &mod_type_map)
+compute_modified_structs (hash_map<const_tree, tree> &type_map,
+ hash_map<const_tree, const_tree> &mod_type_map)
{
- type_map.traverse<hash_map<const_tree, const_tree>*, compute_modified_structs_internal>(&mod_type_map);
+ type_map.traverse<hash_map<const_tree, const_tree> *,
+ compute_modified_structs_internal> (&mod_type_map);
}
-
static bool
-rewrite_constructor_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_constructor_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
// These nodes represent the brace initializers
// for a structure or an array. They contain
// a sequence of component values made out of a vector
// of constructor_elt, which is a (INDEX, VALUE) pair.
- tree old_rhs_type = TREE_TYPE(expr);
- const_tree* new_rhs_type_ptr = type_map.get(old_rhs_type);
- if (!new_rhs_type_ptr) return false;
+ tree old_rhs_type = TREE_TYPE (expr);
+ const_tree *new_rhs_type_ptr = type_map.get (old_rhs_type);
+ if (!new_rhs_type_ptr)
+ return false;
tree new_rhs_type = (tree) *new_rhs_type_ptr;
- TREE_TYPE(expr) = new_rhs_type;
+ TREE_TYPE (expr) = new_rhs_type;
- tree new_type = TREE_TYPE(expr);
+ tree new_type = TREE_TYPE (expr);
// If the TREE_TYPE of the CONSTRUCTOR is a RECORD_TYPE
// UNION_TYPE or QUAL_UNION_TYPE, then the INDEX of each node
// in the sequence will be a FIELD_DECL and the VALUE will be the
@@ -1419,18 +1561,20 @@ rewrite_constructor_def(tree expr, hash_map<const_tree, const_tree> &type_map, c
// If TREE_TYPE of the CONSTRUCTOR is an ARRAY_TYPE, then
// the INDEX of each node in the sequence will be an INTEGER_CST
// or a RANGE_EXPR of two INTEGER_CSTs.
- if (TREE_CLOBBER_P(expr)) return true;
+ if (TREE_CLOBBER_P (expr))
+ return true;
- enum tree_code code = TREE_CODE(new_type);
+ enum tree_code code = TREE_CODE (new_type);
bool is_record = code == RECORD_TYPE;
bool is_union = code == UNION_TYPE;
bool is_qual = code == QUAL_UNION_TYPE;
bool is_array = code == ARRAY_TYPE;
bool is_interesting = is_record || is_union || is_qual || is_array;
- if (!is_interesting) return true;
+ if (!is_interesting)
+ return true;
// We have not tested this with other types...
- gcc_assert(is_record);
+ gcc_assert (is_record);
// FIXME, we would need some time to rewrite the
// API to allow gimple_stmt_iterator be passed
// around all rewrite expressions...
@@ -1438,106 +1582,121 @@ rewrite_constructor_def(tree expr, hash_map<const_tree, const_tree> &type_map, c
// Since not a lot of code uses this syntax,
// let's avoid it for now. But make a note
// we still need to fix this.
- gcc_unreachable();
+ gcc_unreachable ();
unsigned i;
tree val;
- FOR_EACH_CONSTRUCTOR_VALUE(CONSTRUCTOR_ELTS(expr), i, val)
- {
- rewrite_expr(val, type_map, indent + 4);
- }
-
-
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (expr), i, val)
+ {
+ rewrite_expr (val, type_map, indent + 4);
+ }
return true;
}
-
static bool
-rewrite_field_decl_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_field_decl_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- tree old_rhs_type = TREE_TYPE(expr);
- const_tree* new_rhs_type_ptr = type_map.get(old_rhs_type);
- if (!new_rhs_type_ptr) return false;
+ tree old_rhs_type = TREE_TYPE (expr);
+ const_tree *new_rhs_type_ptr = type_map.get (old_rhs_type);
+ if (!new_rhs_type_ptr)
+ return false;
tree new_rhs_type = (tree) *new_rhs_type_ptr;
- TREE_TYPE(expr) = new_rhs_type;
- gcc_assert(TREE_OPERAND(expr, 0) == NULL);
+ TREE_TYPE (expr) = new_rhs_type;
+ gcc_assert (TREE_OPERAND (expr, 0) == NULL);
return true;
}
static bool
-rewrite_integer_cst_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_integer_cst_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- tree old_rhs_type = TREE_TYPE(expr);
- const_tree *new_rhs_type_ptr = type_map.get(old_rhs_type);
- if (!new_rhs_type_ptr) return false;
+ tree old_rhs_type = TREE_TYPE (expr);
+ const_tree *new_rhs_type_ptr = type_map.get (old_rhs_type);
+ if (!new_rhs_type_ptr)
+ return false;
- tree new_rhs_type = (tree) *new_rhs_type_ptr;
- TREE_TYPE(expr) = new_rhs_type;
- return true;
+ tree new_rhs_type = (tree) *new_rhs_type_ptr;
+ TREE_TYPE (expr) = new_rhs_type;
+ return true;
}
-static void rewrite_function_parms(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
-static void rewrite_function_return_type(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent);
+static void
+rewrite_function_parms (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent);
+static void
+rewrite_function_return_type (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent);
static bool
-rewrite_function_decl_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- rewrite_function_parms(expr, type_map, indent + 4);
- rewrite_function_return_type(expr, type_map, indent + 4);
+rewrite_function_decl_def (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ rewrite_function_parms (expr, type_map, indent + 4);
+ rewrite_function_return_type (expr, type_map, indent + 4);
return false;
}
static bool
-rewrite_component_ref_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- gcc_assert(expr);
- tree expr_type = TREE_TYPE(expr);
- gcc_assert(expr_type);
- const_tree *new_expr_type_ptr = type_map.get(expr_type);
- if (new_expr_type_ptr) TREE_TYPE(expr) = (tree) *new_expr_type_ptr;
-
- tree _struct = TREE_OPERAND(expr, 0);
- gcc_assert(_struct);
- tree _struct_type = TREE_TYPE(_struct);
- gcc_assert(_struct_type);
- const_tree* new_struct_type_ptr = type_map.get(_struct_type);
-
- bool retval = rewrite_expr(_struct, type_map, indent);
-
- tree new_type = new_struct_type_ptr ? (tree)*new_struct_type_ptr : _struct_type;
- tree field_decl = TREE_OPERAND(expr, 1);
- const char* field_name = get_field_name(field_decl);
- if (strcmp(field_name, "anonymous") == 0) return false;
-
- const_tree new_field = get_field_with_name(new_type, field_name);
- //INFO: We need to rewrite the whole operand
- //not just its type.
- //INFO: When rewriting an operand we **must**
- //be in -flto-partition=none
- //INFO: setting the type and calling relayout_decl
- //doesn't work.
- //TODO: FIXME: In order to remove this assertion
- //you need to use clones.
- gcc_assert(in_lto_p && !flag_ltrans && !flag_wpa);
- TREE_OPERAND(expr, 1) = (tree) new_field;
- int offset = get_field_offset(new_field);
- test_log("rewrite,field_offset,%s,%d", indent, field_name, offset);
- gcc_assert(TREE_OPERAND(expr, 2) == NULL);
+rewrite_component_ref_def (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ gcc_assert (expr);
+ tree expr_type = TREE_TYPE (expr);
+ gcc_assert (expr_type);
+ const_tree *new_expr_type_ptr = type_map.get (expr_type);
+ if (new_expr_type_ptr)
+ TREE_TYPE (expr) = (tree) *new_expr_type_ptr;
+
+ tree _struct = TREE_OPERAND (expr, 0);
+ gcc_assert (_struct);
+ tree _struct_type = TREE_TYPE (_struct);
+ gcc_assert (_struct_type);
+ const_tree *new_struct_type_ptr = type_map.get (_struct_type);
+
+ bool retval = rewrite_expr (_struct, type_map, indent);
+
+ tree new_type
+ = new_struct_type_ptr ? (tree) *new_struct_type_ptr : _struct_type;
+ tree field_decl = TREE_OPERAND (expr, 1);
+ const char *field_name = get_field_name (field_decl);
+ if (strcmp (field_name, "anonymous") == 0)
+ return false;
+
+ const_tree new_field = get_field_with_name (new_type, field_name);
+ // INFO: We need to rewrite the whole operand
+ // not just its type.
+ // INFO: When rewriting an operand we **must**
+ // be in -flto-partition=none
+ // INFO: setting the type and calling relayout_decl
+ // doesn't work.
+ // TODO: FIXME: In order to remove this assertion
+ // you need to use clones.
+ gcc_assert (in_lto_p && !flag_ltrans && !flag_wpa);
+ TREE_OPERAND (expr, 1) = (tree) new_field;
+ int offset = get_field_offset (new_field);
+ test_log ("rewrite,field_offset,%s,%d", indent, field_name, offset);
+ gcc_assert (TREE_OPERAND (expr, 2) == NULL);
return true;
}
static bool
-rewrite_addr_expr_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- tree type = TREE_TYPE(expr);
- gcc_assert(TREE_CODE(expr) == ADDR_EXPR);
- const_tree *new_type_ptr = type_map.get(type);
- if (new_type_ptr) TREE_TYPE(expr) = (tree) *new_type_ptr;
- tree op0 = TREE_OPERAND(expr, 0);
- bool retval = rewrite_expr(op0, type_map, indent);
+rewrite_addr_expr_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ tree type = TREE_TYPE (expr);
+ gcc_assert (TREE_CODE (expr) == ADDR_EXPR);
+ const_tree *new_type_ptr = type_map.get (type);
+ if (new_type_ptr)
+ TREE_TYPE (expr) = (tree) *new_type_ptr;
+ tree op0 = TREE_OPERAND (expr, 0);
+ bool retval = rewrite_expr (op0, type_map, indent);
// There isn't an operand here, but we also can't
// TREE_OPERAND(expr, 1)
// Accessing this won't fail.
@@ -1545,44 +1704,49 @@ rewrite_addr_expr_def(tree expr, hash_map<const_tree, const_tree> &type_map, con
}
static bool
-rewrite_var_decl_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_var_decl_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- tree type = TREE_TYPE(expr);
- gcc_assert(TREE_CODE(expr) == VAR_DECL);
+ tree type = TREE_TYPE (expr);
+ gcc_assert (TREE_CODE (expr) == VAR_DECL);
return false;
}
static bool
-rewrite_mem_ref_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- // Do we need to modify this value so that we op1 and calculate a constant value?
- gcc_assert(expr);
- gcc_assert(TREE_CODE(expr) == MEM_REF);
- tree type = TREE_TYPE(expr);
-
- const_tree *new_type_ptr = type_map.get(type);
- if (new_type_ptr) TREE_TYPE(expr) = (tree) *new_type_ptr;
-
- const char* old_expr = print_generic_expr_to_str(expr);
- tree op0 = TREE_OPERAND(expr, 0);
+rewrite_mem_ref_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ // Do we need to modify this value so that we op1 and calculate a constant
+ // value?
+ gcc_assert (expr);
+ gcc_assert (TREE_CODE (expr) == MEM_REF);
+ tree type = TREE_TYPE (expr);
+
+ const_tree *new_type_ptr = type_map.get (type);
+ if (new_type_ptr)
+ TREE_TYPE (expr) = (tree) *new_type_ptr;
+
+ const char *old_expr = print_generic_expr_to_str (expr);
+ tree op0 = TREE_OPERAND (expr, 0);
// The first operand is the pointer being dereferenced
- bool retval = rewrite_expr(op0, type_map, indent);
+ bool retval = rewrite_expr (op0, type_map, indent);
// The second operand is a pointer constant. Its type specifying the type
// to be used for type-based alias analysis.
- tree op1 = TREE_OPERAND(expr, 1);
- rewrite_expr(op1, type_map, indent);
- gcc_assert(TREE_CODE(op1) == INTEGER_CST);
- int old_offset = tree_to_uhwi(op1);
- if (old_offset == 0 || !new_type_ptr) return retval;
-
- tree old_struct_size = TYPE_SIZE_UNIT(type);
- int old_type_size_int = tree_to_shwi(old_struct_size);
- test_log("old_type = %s", 0, get_type_name(type));
- test_log("old_type_size = %d", 0, tree_to_shwi(old_struct_size));
- tree new_struct_size = TYPE_SIZE_UNIT((tree)*new_type_ptr);
- int new_type_size_int = tree_to_shwi(new_struct_size);
- test_log("new_type = %s", 0, get_type_name((tree)*new_type_ptr));
- test_log("new_type_size = %d", 0, tree_to_shwi(new_struct_size));
+ tree op1 = TREE_OPERAND (expr, 1);
+ rewrite_expr (op1, type_map, indent);
+ gcc_assert (TREE_CODE (op1) == INTEGER_CST);
+ int old_offset = tree_to_uhwi (op1);
+ if (old_offset == 0 || !new_type_ptr)
+ return retval;
+
+ tree old_struct_size = TYPE_SIZE_UNIT (type);
+ int old_type_size_int = tree_to_shwi (old_struct_size);
+ test_log ("old_type = %s", 0, get_type_name (type));
+ test_log ("old_type_size = %d", 0, tree_to_shwi (old_struct_size));
+ tree new_struct_size = TYPE_SIZE_UNIT ((tree) *new_type_ptr);
+ int new_type_size_int = tree_to_shwi (new_struct_size);
+ test_log ("new_type = %s", 0, get_type_name ((tree) *new_type_ptr));
+ test_log ("new_type_size = %d", 0, tree_to_shwi (new_struct_size));
int multiple = old_offset / old_type_size_int;
int offset = multiple * new_type_size_int;
int remainder = old_offset % old_type_size_int;
@@ -1593,326 +1757,359 @@ rewrite_mem_ref_def(tree expr, hash_map<const_tree, const_tree> &type_map, const
// for now, we can only guarantee this transformation if
// old_offset is multiple of old_type_size_int;
int new_offset = offset + remainder;
- if (new_offset == old_offset) return retval;
+ if (new_offset == old_offset)
+ return retval;
- tree new_offset_tree = build_int_cst(TREE_TYPE(op1), new_offset);
- TREE_OPERAND(expr, 1) = new_offset_tree;
- gcc_assert(old_offset % old_type_size_int == 0);
+ tree new_offset_tree = build_int_cst (TREE_TYPE (op1), new_offset);
+ TREE_OPERAND (expr, 1) = new_offset_tree;
+ gcc_assert (old_offset % old_type_size_int == 0);
// TREE_OPERAND(expr, 2) cannot be accessed.
return retval;
}
-
static bool
-rewrite_ssa_name_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- const char* old_expr = print_generic_expr_to_str(expr);
- tree type = TREE_TYPE(expr);
- tree ssa_name_var = SSA_NAME_VAR(expr);
- const_tree *new_type_ptr = type_map.get(type);
- if (new_type_ptr) {
- TREE_TYPE(expr) = (tree) *new_type_ptr;
- //TODO: I had some cases where ssa_name_var was not set.
- //Not sure why...
- //I need to investigate
- //Could this be the variables that I create?
- //If so, then the temporary variables should have SSA_NAMES
- //and there is something else that I need to change
- if (ssa_name_var) TREE_TYPE(ssa_name_var) = (tree) *new_type_ptr;
- if (ssa_name_var) relayout_decl(ssa_name_var);
- }
-
+rewrite_ssa_name_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ const char *old_expr = print_generic_expr_to_str (expr);
+ tree type = TREE_TYPE (expr);
+ tree ssa_name_var = SSA_NAME_VAR (expr);
+ const_tree *new_type_ptr = type_map.get (type);
+ if (new_type_ptr)
+ {
+ TREE_TYPE (expr) = (tree) *new_type_ptr;
+ // TODO: I had some cases where ssa_name_var was not set.
+ // Not sure why...
+ // I need to investigate
+ // Could this be the variables that I create?
+ // If so, then the temporary variables should have SSA_NAMES
+ // and there is something else that I need to change
+ if (ssa_name_var)
+ TREE_TYPE (ssa_name_var) = (tree) *new_type_ptr;
+ if (ssa_name_var)
+ relayout_decl (ssa_name_var);
+ }
+
return new_type_ptr;
}
static bool
-rewrite_bin_expr_default_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_bin_expr_default_def (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- gcc_assert(expr);
- tree op0 = TREE_OPERAND(expr, 0);
- tree op1 = TREE_OPERAND(expr, 1);
- gcc_assert(op0 && op1);
+ gcc_assert (expr);
+ tree op0 = TREE_OPERAND (expr, 0);
+ tree op1 = TREE_OPERAND (expr, 1);
+ gcc_assert (op0 && op1);
bool retval = false;
- retval |= rewrite_expr(op0, type_map, indent);
- retval |= rewrite_expr(op1, type_map, indent);
+ retval |= rewrite_expr (op0, type_map, indent);
+ retval |= rewrite_expr (op1, type_map, indent);
// Why is this unreachable?
- gcc_unreachable();
- gcc_assert(TREE_OPERAND(expr, 2) == NULL);
+ gcc_unreachable ();
+ gcc_assert (TREE_OPERAND (expr, 2) == NULL);
return retval;
}
static bool
-rewrite_pointer_plus_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- gcc_assert(expr);
- gcc_assert(TREE_CODE(expr) == POINTER_PLUS_EXPR);
- const char* old_expr = print_generic_expr_to_str(expr);
- tree type = TREE_TYPE(expr);
- const_tree *new_type_ptr = type_map.get(type);
- if (new_type_ptr) TREE_TYPE(expr) = (tree) *new_type_ptr;
- gcc_unreachable();
+rewrite_pointer_plus_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ gcc_assert (expr);
+ gcc_assert (TREE_CODE (expr) == POINTER_PLUS_EXPR);
+ const char *old_expr = print_generic_expr_to_str (expr);
+ tree type = TREE_TYPE (expr);
+ const_tree *new_type_ptr = type_map.get (type);
+ if (new_type_ptr)
+ TREE_TYPE (expr) = (tree) *new_type_ptr;
+ gcc_unreachable ();
return true;
}
static bool
-rewrite_plus_expr_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- gcc_assert(expr);
- gcc_assert(TREE_CODE(expr) == PLUS_EXPR);
- gcc_unreachable();
- const char* old_expr = print_generic_expr_to_str(expr);
- bool retval = rewrite_bin_expr_default(expr, type_map, indent);
+rewrite_plus_expr_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ gcc_assert (expr);
+ gcc_assert (TREE_CODE (expr) == PLUS_EXPR);
+ gcc_unreachable ();
+ const char *old_expr = print_generic_expr_to_str (expr);
+ bool retval = rewrite_bin_expr_default (expr, type_map, indent);
return retval;
}
static bool
-rewrite_pointer_diff_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_pointer_diff_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- gcc_unreachable();
+ gcc_unreachable ();
bool retval = false;
return retval;
}
-
static bool
-rewrite_array_ref_def(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
-{
- gcc_assert(expr);
- gcc_assert(TREE_CODE(expr) == ARRAY_REF);
- tree type = TREE_TYPE(expr);
- const_tree *up_ptr = type_map.get(type);
- if (up_ptr) TREE_TYPE(expr) = (tree) *up_ptr;
- tree old_rhs_type = TREE_TYPE(expr);
- const_tree* new_rhs_type_ptr = type_map.get(old_rhs_type);
-
- rewrite_expr(TREE_OPERAND(expr, 0), type_map, indent+4);
- rewrite_expr(TREE_OPERAND(expr, 1), type_map, indent+4);
- gcc_assert(TREE_OPERAND(expr, 2) == NULL);
+rewrite_array_ref_def (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
+{
+ gcc_assert (expr);
+ gcc_assert (TREE_CODE (expr) == ARRAY_REF);
+ tree type = TREE_TYPE (expr);
+ const_tree *up_ptr = type_map.get (type);
+ if (up_ptr)
+ TREE_TYPE (expr) = (tree) *up_ptr;
+ tree old_rhs_type = TREE_TYPE (expr);
+ const_tree *new_rhs_type_ptr = type_map.get (old_rhs_type);
+
+ rewrite_expr (TREE_OPERAND (expr, 0), type_map, indent + 4);
+ rewrite_expr (TREE_OPERAND (expr, 1), type_map, indent + 4);
+ gcc_assert (TREE_OPERAND (expr, 2) == NULL);
return true;
}
static void
-rewrite_pointer_diff_def_rhs_variable_replace_constants_implementation
-(gimple_stmt_iterator &gsi, tree lhs, tree pointer, tree variable, const_tree old_type)
+rewrite_pointer_diff_def_rhs_variable_replace_constants_implementation (
+ gimple_stmt_iterator &gsi, tree lhs, tree pointer, tree variable,
+ const_tree old_type)
{
// We will need this later
- tree old_type_size = TYPE_SIZE_UNIT(TREE_TYPE(old_type));
- int old_type_size_int = tree_to_shwi(old_type_size);
+ tree old_type_size = TYPE_SIZE_UNIT (TREE_TYPE (old_type));
+ int old_type_size_int = tree_to_shwi (old_type_size);
// lhs = op0 - op1 // <-- we are here
// ... SNIP ...
// var = lhs / [ex] old_struct_size // <-- we want to be here
- //
+ //
// Let's explore the uses of lhs
gimple *stmt;
imm_use_iterator iterator;
- FOR_EACH_IMM_USE_STMT(stmt, iterator, lhs)
- {
- // stmt is a use of lhs
- // gimple_expr_code is only valid for non-debug statements
- bool is_debug = is_gimple_debug(stmt);
- if (is_debug) continue;
-
- test_log("is not debug", 0);
- enum tree_code code = gimple_expr_code(stmt);
- bool is_exact_div = code == EXACT_DIV_EXPR;
- if (!is_exact_div) continue;
-
- test_log("is exact div expr", 0);
- tree divisor = gimple_op(stmt, 2);
- enum tree_code divisor_code = TREE_CODE(divisor);
- bool is_constant = divisor_code == INTEGER_CST;
- if (!is_constant) continue;
-
- test_log("is constant", 0);
- int divisor_int = tree_to_shwi(divisor);
- test_log("size %d %d", 0, divisor_int, old_type_size_int);
- bool is_same_size = divisor_int == old_type_size_int;
- if (!is_same_size) continue;
-
- const_tree new_base_type = TREE_TYPE(TREE_TYPE(pointer));
- tree new_struct_size_tree_1 = TYPE_SIZE_UNIT(new_base_type);
- int new_struct_size_int = tree_to_shwi(new_struct_size_tree_1);
- tree new_struct_size_const = build_int_cst(TREE_TYPE(divisor), new_struct_size_int);
- gimple_set_op(stmt, 2, new_struct_size_const);
- }
+ FOR_EACH_IMM_USE_STMT (stmt, iterator, lhs)
+ {
+ // stmt is a use of lhs
+ // gimple_expr_code is only valid for non-debug statements
+ bool is_debug = is_gimple_debug (stmt);
+ if (is_debug)
+ continue;
+
+ test_log ("is not debug", 0);
+ enum tree_code code = gimple_expr_code (stmt);
+ bool is_exact_div = code == EXACT_DIV_EXPR;
+ if (!is_exact_div)
+ continue;
+
+ test_log ("is exact div expr", 0);
+ tree divisor = gimple_op (stmt, 2);
+ enum tree_code divisor_code = TREE_CODE (divisor);
+ bool is_constant = divisor_code == INTEGER_CST;
+ if (!is_constant)
+ continue;
+
+ test_log ("is constant", 0);
+ int divisor_int = tree_to_shwi (divisor);
+ test_log ("size %d %d", 0, divisor_int, old_type_size_int);
+ bool is_same_size = divisor_int == old_type_size_int;
+ if (!is_same_size)
+ continue;
+
+ const_tree new_base_type = TREE_TYPE (TREE_TYPE (pointer));
+ tree new_struct_size_tree_1 = TYPE_SIZE_UNIT (new_base_type);
+ int new_struct_size_int = tree_to_shwi (new_struct_size_tree_1);
+ tree new_struct_size_const
+ = build_int_cst (TREE_TYPE (divisor), new_struct_size_int);
+ gimple_set_op (stmt, 2, new_struct_size_const);
+ }
}
static tree
-rewrite_pointer_plus_def_rhs_variable_replace_constants_implementation
-(gimple_stmt_iterator &gsi, tree lhs, tree pointer, tree variable, const_tree old_type)
+rewrite_pointer_plus_def_rhs_variable_replace_constants_implementation (
+ gimple_stmt_iterator &gsi, tree lhs, tree pointer, tree variable,
+ const_tree old_type)
{
-
// We need to find the definition of the 3rd operand
// _1 = _0 * 72
// ... SNIP ...
// _2 = _1 + CONSTANT;
// ... SNIP ...
// _3 = &array + _2; < -- this is where we are
- gcc_assert(TREE_CODE(variable) == SSA_NAME);
- gimple *def_for_variable = SSA_NAME_DEF_STMT(variable);
+ gcc_assert (TREE_CODE (variable) == SSA_NAME);
+ gimple *def_for_variable = SSA_NAME_DEF_STMT (variable);
-
// It is also possible that we are in a negation statement.
// Example:
// _2 = _1 * 72;
// ... SNIP ...
// _3 = -_2; < -- def_for_variable **might** be this stmt.
// ... SNIP ...
- // _4 = &array + _3;
+ // _4 = &array + _3;
// Let's find out how many operands we have
- unsigned num_operands = gimple_num_ops(def_for_variable);
- test_log("how many operands ? %d", 0, num_operands);
+ unsigned num_operands = gimple_num_ops (def_for_variable);
+ test_log ("how many operands ? %d", 0, num_operands);
bool need_to_skip = num_operands == 2;
- gimple* to_change = need_to_skip ? SSA_NAME_DEF_STMT(gimple_op(def_for_variable, 1)) : def_for_variable;
+ gimple *to_change = need_to_skip
+ ? SSA_NAME_DEF_STMT (gimple_op (def_for_variable, 1))
+ : def_for_variable;
-
// _2 = _1 * 72; <-- to change
// _3 = &array + _2;
- enum tree_code code = gimple_expr_code(to_change);
- const_tree old_base_type = TREE_TYPE(old_type);
- tree old_struct_size_tree_1 = TYPE_SIZE_UNIT(old_base_type);
- int old_struct_size_int = tree_to_shwi(old_struct_size_tree_1);
- const_tree pointer_to_unit_type = TREE_TYPE(lhs);
- tree new_struct_pointer_tree = TYPE_SIZE_UNIT(pointer_to_unit_type);
- int new_struct_pointer_int = tree_to_shwi(new_struct_pointer_tree);
- const_tree unit_type = TREE_TYPE(pointer_to_unit_type);
- tree new_struct_size_tree_1 = TYPE_SIZE_UNIT(unit_type);
- int new_struct_size_int = tree_to_shwi(new_struct_size_tree_1);
-
- if (code == PLUS_EXPR) {
-
- // If we are here it is because we are adding an offset.
- // It is usually whenever we do somehting like
- // _2 = _1 + CONSTANT; <-- to change
- // _3 = &array + _2;
- gcc_assert(code == PLUS_EXPR);
-
- tree constant_plus = gimple_op(to_change, 2);
- gcc_assert(TREE_CODE(constant_plus) == INTEGER_CST);
-
- int old_unit_size_one_plus = tree_to_uhwi(constant_plus);
- // This used to work for unprofiled code.
- // However, with profiling, I guess we can jump wherever we want...
- // So, we need to find out which field we were intending to access
- // and where that field maps to the new struct...
- // gcc_assert(is_modulo);
-
- bool is_modulo_old = old_unit_size_one_plus % old_struct_size_int == 0;
- bool is_modulo_new = old_unit_size_one_plus % new_struct_size_int == 0;
- // If we are not in flag_profile_use
- // we will always be a modulo
- if (!flag_profile_use) gcc_assert(is_modulo_old);
-
- test_log("old plus constant = %d", 0, old_unit_size_one_plus);
- test_log("old struct size int = %d", 0, old_struct_size_int);
- test_log("new struct size int = %d", 0, new_struct_size_int);
- test_log("old_unit_size_one_plus modulo new_struct_pointer_int = %d", 0, old_unit_size_one_plus % new_struct_size_int);
-
- //FIXME:
- //The problem is that if flag_profile_use is enabled,
- //then we can potentially **predict** the offset
- //to be the correct one. But not always?
- //Therefore, we really do not have an idea if we are using
- //a value obtained from profiling or one from "correctness".
- if (flag_profile_use) {
- bool is_from_profiling = is_modulo_new;
- bool is_from_correctness = is_modulo_old;
- gcc_assert(is_from_correctness || is_from_profiling);
- }
-
- int field_accessed_offset = old_unit_size_one_plus % old_struct_size_int;
-
- if (flag_profile_use && is_modulo_new) gcc_assert(field_accessed_offset != 0);
- /*
-
- int field_accessed_offset = 0;
- bool is_modulo = old_unit_size_one_plus % old_struct_size_int == 0;
- if (!is_modulo) {
- // TODO: I believe that all field_accessed will be modulo.
- // The only time I have encountered where it is not modulo,
- // is when we use profile information from a previous run
- // that has been modified...
- // I want an assertion that sa
- int field_accessed = old_unit_size_one_plus % old_struct_size_int;
- test_log("offset_accessed = %d type_name = %s", 0, field_accessed, get_type_name(old_base_type));
- const_tree field_accessed_tree = get_field_with_offset_unsafe(old_base_type, field_accessed);
- const char* field_accessed_name = field_accessed_tree ? get_field_name(field_accessed_tree) : "NONE";
- const_tree new_field_accessed = field_accessed_tree ? get_field_with_name(unit_type, field_accessed_name) : NULL;
- field_accessed_offset = field_accessed_tree ? get_field_offset(new_field_accessed) : field_accessed;
- }
-
- */
- int new_plus_constant_int = old_unit_size_one_plus / old_struct_size_int * new_struct_size_int + field_accessed_offset;
-
- //if (flag_profile_use && is_modulo_new) gcc_assert(field_accessed_offset % new_struct_size_int == 0);
-
- tree new_plus_constant = build_int_cst(TREE_TYPE(constant_plus), new_plus_constant_int);
- gimple_set_op(to_change, 2, new_plus_constant);
-
- // And now we need to get the defintion of _1
- variable = gimple_op(to_change, 1);
- gcc_assert(TREE_CODE(variable) == SSA_NAME);
- def_for_variable = SSA_NAME_DEF_STMT(variable);
- num_operands = gimple_num_ops(def_for_variable);
- test_log("how many operands ? %d", 0, num_operands);
- need_to_skip = num_operands == 2;
- to_change = need_to_skip ? SSA_NAME_DEF_STMT(gimple_op(def_for_variable, 1)) : def_for_variable;
- code = gimple_expr_code(to_change);
-
- }
-
-
- if (code == MULT_EXPR) {
- // How do we know what type we need to change?
- // That is _3 (or lhs) is the result of the pointer arithmetic.
- // So we need one level of dereference in order to find
- // the underlying type.
-
- // We need to get the second operand
- test_print_gimple_stmt(to_change);
- tree constant = gimple_op(to_change, 2);
- gcc_assert(TREE_CODE(constant) == INTEGER_CST);
-
- int old_unit_size_one = tree_to_shwi(constant);
- // We should have the same size...
- // Is this always true?
- //gcc_assert(old_unit_size_one == old_struct_size_int);
+ enum tree_code code = gimple_expr_code (to_change);
+ const_tree old_base_type = TREE_TYPE (old_type);
+ tree old_struct_size_tree_1 = TYPE_SIZE_UNIT (old_base_type);
+ int old_struct_size_int = tree_to_shwi (old_struct_size_tree_1);
+ const_tree pointer_to_unit_type = TREE_TYPE (lhs);
+ tree new_struct_pointer_tree = TYPE_SIZE_UNIT (pointer_to_unit_type);
+ int new_struct_pointer_int = tree_to_shwi (new_struct_pointer_tree);
+ const_tree unit_type = TREE_TYPE (pointer_to_unit_type);
+ tree new_struct_size_tree_1 = TYPE_SIZE_UNIT (unit_type);
+ int new_struct_size_int = tree_to_shwi (new_struct_size_tree_1);
+
+ if (code == PLUS_EXPR)
+ {
+ // If we are here it is because we are adding an offset.
+ // It is usually whenever we do somehting like
+ // _2 = _1 + CONSTANT; <-- to change
+ // _3 = &array + _2;
+ gcc_assert (code == PLUS_EXPR);
+
+ tree constant_plus = gimple_op (to_change, 2);
+ gcc_assert (TREE_CODE (constant_plus) == INTEGER_CST);
+
+ int old_unit_size_one_plus = tree_to_uhwi (constant_plus);
+ // This used to work for unprofiled code.
+ // However, with profiling, I guess we can jump wherever we want...
+ // So, we need to find out which field we were intending to access
+ // and where that field maps to the new struct...
+ // gcc_assert(is_modulo);
+
+ bool is_modulo_old = old_unit_size_one_plus % old_struct_size_int == 0;
+ bool is_modulo_new = old_unit_size_one_plus % new_struct_size_int == 0;
+ // If we are not in flag_profile_use
+ // we will always be a modulo
+ if (!flag_profile_use)
+ gcc_assert (is_modulo_old);
+
+ test_log ("old plus constant = %d", 0, old_unit_size_one_plus);
+ test_log ("old struct size int = %d", 0, old_struct_size_int);
+ test_log ("new struct size int = %d", 0, new_struct_size_int);
+ test_log ("old_unit_size_one_plus modulo new_struct_pointer_int = %d", 0,
+ old_unit_size_one_plus % new_struct_size_int);
+
+ // FIXME:
+ // The problem is that if flag_profile_use is enabled,
+ // then we can potentially **predict** the offset
+ // to be the correct one. But not always?
+ // Therefore, we really do not have an idea if we are using
+ // a value obtained from profiling or one from "correctness".
+ if (flag_profile_use)
+ {
+ bool is_from_profiling = is_modulo_new;
+ bool is_from_correctness = is_modulo_old;
+ gcc_assert (is_from_correctness || is_from_profiling);
+ }
+
+ int field_accessed_offset = old_unit_size_one_plus % old_struct_size_int;
+
+ if (flag_profile_use && is_modulo_new)
+ gcc_assert (field_accessed_offset != 0);
+ /*
+
+ int field_accessed_offset = 0;
+ bool is_modulo = old_unit_size_one_plus % old_struct_size_int == 0;
+ if (!is_modulo) {
+ // TODO: I believe that all field_accessed will be modulo.
+ // The only time I have encountered where it is not modulo,
+ // is when we use profile information from a previous run
+ // that has been modified...
+ // I want an assertion that sa
+ int field_accessed = old_unit_size_one_plus %
+ old_struct_size_int; test_log("offset_accessed = %d type_name = %s", 0,
+ field_accessed, get_type_name(old_base_type)); const_tree
+ field_accessed_tree = get_field_with_offset_unsafe(old_base_type,
+ field_accessed); const char* field_accessed_name = field_accessed_tree ?
+ get_field_name(field_accessed_tree) : "NONE"; const_tree
+ new_field_accessed = field_accessed_tree ? get_field_with_name(unit_type,
+ field_accessed_name) : NULL; field_accessed_offset = field_accessed_tree
+ ? get_field_offset(new_field_accessed) : field_accessed;
+ }
+
+ */
+ int new_plus_constant_int
+ = old_unit_size_one_plus / old_struct_size_int * new_struct_size_int
+ + field_accessed_offset;
+
+ // if (flag_profile_use && is_modulo_new) gcc_assert(field_accessed_offset
+ // % new_struct_size_int == 0);
+
+ tree new_plus_constant
+ = build_int_cst (TREE_TYPE (constant_plus), new_plus_constant_int);
+ gimple_set_op (to_change, 2, new_plus_constant);
+
+ // And now we need to get the defintion of _1
+ variable = gimple_op (to_change, 1);
+ gcc_assert (TREE_CODE (variable) == SSA_NAME);
+ def_for_variable = SSA_NAME_DEF_STMT (variable);
+ num_operands = gimple_num_ops (def_for_variable);
+ test_log ("how many operands ? %d", 0, num_operands);
+ need_to_skip = num_operands == 2;
+ to_change = need_to_skip
+ ? SSA_NAME_DEF_STMT (gimple_op (def_for_variable, 1))
+ : def_for_variable;
+ code = gimple_expr_code (to_change);
+ }
- // Now we need to modify the second operand...
- tree new_constant = build_int_cst(TREE_TYPE(constant), new_struct_size_int);
- gimple_set_op(to_change, 2, new_constant);
- }
+ if (code == MULT_EXPR)
+ {
+ // How do we know what type we need to change?
+ // That is _3 (or lhs) is the result of the pointer arithmetic.
+ // So we need one level of dereference in order to find
+ // the underlying type.
+
+ // We need to get the second operand
+ test_print_gimple_stmt (to_change);
+ tree constant = gimple_op (to_change, 2);
+ gcc_assert (TREE_CODE (constant) == INTEGER_CST);
+
+ int old_unit_size_one = tree_to_shwi (constant);
+ // We should have the same size...
+ // Is this always true?
+ // gcc_assert(old_unit_size_one == old_struct_size_int);
+
+ // Now we need to modify the second operand...
+ tree new_constant
+ = build_int_cst (TREE_TYPE (constant), new_struct_size_int);
+ gimple_set_op (to_change, 2, new_constant);
+ }
return NULL;
}
-//TODO:
-//rewrite_pointer_plus_def_rhs_constant is a special case of
-//rewrite_pointer_plus_def_rhs_variable.
-//Maybe variable should subsume constant?
+// TODO:
+// rewrite_pointer_plus_def_rhs_constant is a special case of
+// rewrite_pointer_plus_def_rhs_variable.
+// Maybe variable should subsume constant?
static tree
-rewrite_pointer_plus_def_rhs_variable(gimple_stmt_iterator &gsi, tree lhs, tree pointer, tree variable, const_tree old_type)
-{
- tree pointer_type = TREE_TYPE(pointer);
- gcc_assert(TREE_CODE(pointer_type) == POINTER_TYPE);
- enum tree_code code = TREE_CODE(variable);
- gcc_assert(TREE_CODE(variable) == SSA_NAME);
- tree variable_type = TREE_TYPE(variable);
- gcc_assert(TREE_CODE(variable_type) == INTEGER_TYPE);
- const_tree old_base_type = TREE_TYPE(old_type);
- tree old_struct_size_tree_1 = TYPE_SIZE_UNIT(old_base_type);
- int old_struct_size_int = tree_to_shwi(old_struct_size_tree_1);
- const_tree new_base_type = TREE_TYPE(TREE_TYPE(pointer));
- tree new_struct_size_tree_1 = TYPE_SIZE_UNIT(new_base_type);
- int new_struct_size_int = tree_to_shwi(new_struct_size_tree_1);
+rewrite_pointer_plus_def_rhs_variable (gimple_stmt_iterator &gsi, tree lhs,
+ tree pointer, tree variable,
+ const_tree old_type)
+{
+ tree pointer_type = TREE_TYPE (pointer);
+ gcc_assert (TREE_CODE (pointer_type) == POINTER_TYPE);
+ enum tree_code code = TREE_CODE (variable);
+ gcc_assert (TREE_CODE (variable) == SSA_NAME);
+ tree variable_type = TREE_TYPE (variable);
+ gcc_assert (TREE_CODE (variable_type) == INTEGER_TYPE);
+ const_tree old_base_type = TREE_TYPE (old_type);
+ tree old_struct_size_tree_1 = TYPE_SIZE_UNIT (old_base_type);
+ int old_struct_size_int = tree_to_shwi (old_struct_size_tree_1);
+ const_tree new_base_type = TREE_TYPE (TREE_TYPE (pointer));
+ tree new_struct_size_tree_1 = TYPE_SIZE_UNIT (new_base_type);
+ int new_struct_size_int = tree_to_shwi (new_struct_size_tree_1);
// avoid modifications
- if (old_struct_size_int == new_struct_size_int) return NULL;
+ if (old_struct_size_int == new_struct_size_int)
+ return NULL;
// the variable holds the offset
// variable = anotherthing * old_type_size
@@ -1920,58 +2117,64 @@ rewrite_pointer_plus_def_rhs_variable(gimple_stmt_iterator &gsi, tree lhs, tree
// Let's first create a temporary variable
// variable = anotherthing * old_type_size;
// tmpvar = variable / old_struct_size;
- tree tmpvar = create_tmp_var(TREE_TYPE(variable));
+ tree tmpvar = create_tmp_var (TREE_TYPE (variable));
// Good.
// Now, we can make an integer constant
// that is old_struct_size;
// tmpvar = variable / old_struct_size;
- tree old_struct_size = build_int_cst(TREE_TYPE(variable), old_struct_size_int);
+ tree old_struct_size
+ = build_int_cst (TREE_TYPE (variable), old_struct_size_int);
// Good.
// Now we need to create a division operation between the two
// Because there is no pointer division.
- gassign *assign_stmt_1 = gimple_build_assign(tmpvar, TRUNC_DIV_EXPR, variable, old_struct_size);
+ gassign *assign_stmt_1
+ = gimple_build_assign (tmpvar, TRUNC_DIV_EXPR, variable, old_struct_size);
// Now we need to insert assign_stmt_1 before us...
- gsi_insert_before(&gsi, assign_stmt_1, GSI_SAME_STMT);
+ gsi_insert_before (&gsi, assign_stmt_1, GSI_SAME_STMT);
// Ok now we need a new temporary variable
// tmpvar2 = tmpvar * new_struct_size;
- tree tmpvar2 = create_tmp_var(TREE_TYPE(variable));
+ tree tmpvar2 = create_tmp_var (TREE_TYPE (variable));
// Good.
// Now we need we need another integer constant
- test_log("old_struct_size_int = %d", 0, old_struct_size_int);
- test_log("new_struct_size_int = %d", 0, new_struct_size_int);
- tree new_struct_size = build_int_cst(TREE_TYPE(variable), new_struct_size_int);
+ test_log ("old_struct_size_int = %d", 0, old_struct_size_int);
+ test_log ("new_struct_size_int = %d", 0, new_struct_size_int);
+ tree new_struct_size
+ = build_int_cst (TREE_TYPE (variable), new_struct_size_int);
- //Good. Now we need to multiply...
+ // Good. Now we need to multiply...
// tmpvar2 = tmpvar * new_struct_size;
- gassign *assign_stmt_2 = gimple_build_assign(tmpvar2, MULT_EXPR, tmpvar, new_struct_size);
-
+ gassign *assign_stmt_2
+ = gimple_build_assign (tmpvar2, MULT_EXPR, tmpvar, new_struct_size);
+
// Now we need to insert assign_stmt_2 before us...
- gsi_insert_before(&gsi, assign_stmt_2, GSI_SAME_STMT);
+ gsi_insert_before (&gsi, assign_stmt_2, GSI_SAME_STMT);
return tmpvar2;
}
static tree
-rewrite_pointer_diff_def_rhs_variable(gimple_stmt_iterator &gsi, tree lhs, tree op0, tree op1, const_tree old_type)
-{
- tree pointer_type = TREE_TYPE(op0);
- gcc_assert(TREE_CODE(pointer_type) == POINTER_TYPE);
- enum tree_code code = TREE_CODE(op1);
- gcc_assert(TREE_CODE(op1) == SSA_NAME);
- tree variable_type = TREE_TYPE(op1);
- gcc_assert(TREE_CODE(TREE_TYPE(lhs)) == INTEGER_TYPE);
- const_tree old_base_type = TREE_TYPE(old_type);
- tree old_struct_size_tree_1 = TYPE_SIZE_UNIT(old_base_type);
- int old_struct_size_int = tree_to_shwi(old_struct_size_tree_1);
- const_tree new_base_type = TREE_TYPE(TREE_TYPE(op0));
- tree new_struct_size_tree_1 = TYPE_SIZE_UNIT(new_base_type);
- int new_struct_size_int = tree_to_shwi(new_struct_size_tree_1);
-
- test_log("old_struct_size_int = %d", 0, old_struct_size_int);
- test_log("new_struct_size_int = %d", 0, new_struct_size_int);
+rewrite_pointer_diff_def_rhs_variable (gimple_stmt_iterator &gsi, tree lhs,
+ tree op0, tree op1, const_tree old_type)
+{
+ tree pointer_type = TREE_TYPE (op0);
+ gcc_assert (TREE_CODE (pointer_type) == POINTER_TYPE);
+ enum tree_code code = TREE_CODE (op1);
+ gcc_assert (TREE_CODE (op1) == SSA_NAME);
+ tree variable_type = TREE_TYPE (op1);
+ gcc_assert (TREE_CODE (TREE_TYPE (lhs)) == INTEGER_TYPE);
+ const_tree old_base_type = TREE_TYPE (old_type);
+ tree old_struct_size_tree_1 = TYPE_SIZE_UNIT (old_base_type);
+ int old_struct_size_int = tree_to_shwi (old_struct_size_tree_1);
+ const_tree new_base_type = TREE_TYPE (TREE_TYPE (op0));
+ tree new_struct_size_tree_1 = TYPE_SIZE_UNIT (new_base_type);
+ int new_struct_size_int = tree_to_shwi (new_struct_size_tree_1);
+
+ test_log ("old_struct_size_int = %d", 0, old_struct_size_int);
+ test_log ("new_struct_size_int = %d", 0, new_struct_size_int);
// avoid modifications
- if (old_struct_size_int == new_struct_size_int) return NULL;
+ if (old_struct_size_int == new_struct_size_int)
+ return NULL;
// the variable holds the offset without multiplication by type size
// lhs = op0 - op1 <-- we are here
@@ -1985,631 +2188,707 @@ rewrite_pointer_diff_def_rhs_variable(gimple_stmt_iterator &gsi, tree lhs, tree
//
// Let's first create a temporary variable
// tmpvar = lhs * old_size
- tree tmpvar = create_tmp_var(TREE_TYPE(lhs));
+ tree tmpvar = create_tmp_var (TREE_TYPE (lhs));
// Good.
// Now, we can make an integer constant
// that is old_struct_size;
// tmpvar = lhs * old_size
- tree old_struct_size = build_int_cst(TREE_TYPE(lhs), old_struct_size_int);
+ tree old_struct_size = build_int_cst (TREE_TYPE (lhs), old_struct_size_int);
// Good.
// Now we need to create a mult operation between the two
// Because there is no pointer division.
- gassign *assign_stmt_1 = gimple_build_assign(tmpvar, MULT_EXPR, lhs, old_struct_size);
+ gassign *assign_stmt_1
+ = gimple_build_assign (tmpvar, MULT_EXPR, lhs, old_struct_size);
// Ok now we need a new temporary variable
// tmpvar2 = tmpvar / new_size
- tree tmpvar2 = create_tmp_var(TREE_TYPE(lhs));
+ tree tmpvar2 = create_tmp_var (TREE_TYPE (lhs));
// Good.
// Now we need we need another integer constant
- tree new_struct_size = build_int_cst(TREE_TYPE(lhs), new_struct_size_int);
+ tree new_struct_size = build_int_cst (TREE_TYPE (lhs), new_struct_size_int);
- //Good. Now we need to divide...
+ // Good. Now we need to divide...
// tmpvar2 = tmpvar / new_size
- gassign *assign_stmt_2 = gimple_build_assign(tmpvar2, EXACT_DIV_EXPR, tmpvar, new_struct_size);
-
+ gassign *assign_stmt_2
+ = gimple_build_assign (tmpvar2, EXACT_DIV_EXPR, tmpvar, new_struct_size);
+
// Now we need to insert assign_stmt_1 after us...
- gsi_insert_after(&gsi, assign_stmt_1, GSI_NEW_STMT);
+ gsi_insert_after (&gsi, assign_stmt_1, GSI_NEW_STMT);
// Now we need to insert assign_stmt_2 after us...
- gsi_insert_after(&gsi, assign_stmt_2, GSI_NEW_STMT);
+ gsi_insert_after (&gsi, assign_stmt_2, GSI_NEW_STMT);
return tmpvar2;
}
static tree
-rewrite_pointer_plus_def_rhs_integer_constant(tree pointer, tree integer_constant, const_tree old_type)
+rewrite_pointer_plus_def_rhs_integer_constant (tree pointer,
+ tree integer_constant,
+ const_tree old_type)
{
- gcc_assert(TREE_CODE(integer_constant) == INTEGER_CST);
- tree pointer_type = TREE_TYPE(pointer);
- gcc_assert(TREE_CODE(pointer_type) == POINTER_TYPE);
+ gcc_assert (TREE_CODE (integer_constant) == INTEGER_CST);
+ tree pointer_type = TREE_TYPE (pointer);
+ gcc_assert (TREE_CODE (pointer_type) == POINTER_TYPE);
- const_tree base_type = TREE_TYPE(TREE_TYPE(pointer));
+ const_tree base_type = TREE_TYPE (TREE_TYPE (pointer));
- tree size = TYPE_SIZE_UNIT(base_type);
- int new_struct_size = tree_to_shwi(size);
- int old_offset = tree_to_uhwi(integer_constant);
+ tree size = TYPE_SIZE_UNIT (base_type);
+ int new_struct_size = tree_to_shwi (size);
+ int old_offset = tree_to_uhwi (integer_constant);
- const_tree old_base_type = TREE_TYPE(old_type);
+ const_tree old_base_type = TREE_TYPE (old_type);
- tree old_type_size = TYPE_SIZE_UNIT(old_base_type);
- int old_struct_size = tree_to_shwi(old_type_size);
- test_log("old_struct_size = %d", 0, old_struct_size);
+ tree old_type_size = TYPE_SIZE_UNIT (old_base_type);
+ int old_struct_size = tree_to_shwi (old_type_size);
+ test_log ("old_struct_size = %d", 0, old_struct_size);
bool addition = old_offset > 0;
- tree integer_constant_type = TREE_TYPE(integer_constant);
-
+ tree integer_constant_type = TREE_TYPE (integer_constant);
+
int new_offset = old_offset / old_struct_size * new_struct_size;
- tree new_constant = build_int_cst(integer_constant_type, new_offset);
+ tree new_constant = build_int_cst (integer_constant_type, new_offset);
return new_constant;
}
static bool
-rewrite_pointer_plus_def_rhs(gimple *stmt, gimple_stmt_iterator &gsi, tree lhs, tree op0, tree op1, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree>& inverse)
-{
- gcc_assert(op0 && op1);
- tree op0_type = TREE_TYPE(lhs);
- const_tree *new_op0_type = type_map.get(op0_type);
- test_log("rewrite_pointer_plus has old_type %s", 0, new_op0_type ? "true" : "false");
- //gcc_assert(!new_op0_type);
- test_log("rewrite_pointer_plus op0_type %s", 0, get_type_name(op0_type));
+rewrite_pointer_plus_def_rhs (gimple *stmt, gimple_stmt_iterator &gsi, tree lhs,
+ tree op0, tree op1,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
+{
+ gcc_assert (op0 && op1);
+ tree op0_type = TREE_TYPE (lhs);
+ const_tree *new_op0_type = type_map.get (op0_type);
+ test_log ("rewrite_pointer_plus has old_type %s", 0,
+ new_op0_type ? "true" : "false");
+ // gcc_assert(!new_op0_type);
+ test_log ("rewrite_pointer_plus op0_type %s", 0, get_type_name (op0_type));
if (new_op0_type)
- test_log("rewrite_pointer_plus new_op0_type %s", 0, get_type_name(*new_op0_type));
-
- rewrite_expr(op0, type_map, 0);
- rewrite_expr(op1, type_map, 0);
-
- tree rhs_type = TREE_TYPE(op0);
- const char* new_type_name = new_op0_type ? get_type_name(*new_op0_type) : get_type_name(op0_type);
- //TODO: I'd prefer to have a parameter
- //that tells me what to change
- test_log("rewrite_pointer_plus new_type_name %s", 0, new_type_name);
- //several stack frames above.
- const_tree *inverse_type_ptr = inverse.get(op0_type);
+ test_log ("rewrite_pointer_plus new_op0_type %s", 0,
+ get_type_name (*new_op0_type));
+
+ rewrite_expr (op0, type_map, 0);
+ rewrite_expr (op1, type_map, 0);
+
+ tree rhs_type = TREE_TYPE (op0);
+ const char *new_type_name
+ = new_op0_type ? get_type_name (*new_op0_type) : get_type_name (op0_type);
+ // TODO: I'd prefer to have a parameter
+ // that tells me what to change
+ test_log ("rewrite_pointer_plus new_type_name %s", 0, new_type_name);
+ // several stack frames above.
+ const_tree *inverse_type_ptr = inverse.get (op0_type);
bool not_in_map_nor_inverse = !new_op0_type && !inverse_type_ptr;
- test_log("continuing? %s", 0, not_in_map_nor_inverse ? "false" : "true");
- if (not_in_map_nor_inverse) return false;
+ test_log ("continuing? %s", 0, not_in_map_nor_inverse ? "false" : "true");
+ if (not_in_map_nor_inverse)
+ return false;
+ const_tree old_type
+ = new_op0_type ? (const_tree) op0_type : *inverse_type_ptr;
+ test_log ("what is the old_type name ? %s", 0, get_type_name (old_type));
- const_tree old_type = new_op0_type ? (const_tree) op0_type : *inverse_type_ptr;
- test_log("what is the old_type name ? %s", 0, get_type_name(old_type));
-
-
- bool is_op1_int_cst = TREE_CODE(op1) == INTEGER_CST;
+ bool is_op1_int_cst = TREE_CODE (op1) == INTEGER_CST;
tree integer_constant = is_op1_int_cst ? op1 : op0;
- bool has_integer_constant = (TREE_CODE(integer_constant) == INTEGER_CST);
+ bool has_integer_constant = (TREE_CODE (integer_constant) == INTEGER_CST);
// I want to know if this is an invariant.
- if (has_integer_constant) gcc_assert(TREE_CODE(op1) == INTEGER_CST);
+ if (has_integer_constant)
+ gcc_assert (TREE_CODE (op1) == INTEGER_CST);
- switch(has_integer_constant)
- {
- case true:
+ switch (has_integer_constant)
{
- tree pointer = is_op1_int_cst ? op0 : op1;
- tree pointer_type = TREE_TYPE(pointer);
- tree new_constant = rewrite_pointer_plus_def_rhs_integer_constant(pointer, integer_constant, old_type);
- unsigned int operand = is_op1_int_cst ? 2 : 1;
- gimple_set_op(stmt, operand, new_constant);
- }
- break;
+ case true:
+ {
+ tree pointer = is_op1_int_cst ? op0 : op1;
+ tree pointer_type = TREE_TYPE (pointer);
+ tree new_constant
+ = rewrite_pointer_plus_def_rhs_integer_constant (pointer,
+ integer_constant,
+ old_type);
+ unsigned int operand = is_op1_int_cst ? 2 : 1;
+ gimple_set_op (stmt, operand, new_constant);
+ }
+ break;
case false:
- {
- tree variable = op1;
- tree pointer = op0;
- // I want to know if this is an invariant.
- tree pointer_type = TREE_TYPE(pointer);
- gcc_assert(TREE_CODE(pointer_type) == POINTER_TYPE);
- tree new_variable = rewrite_pointer_plus_def_rhs_variable_replace_constants_implementation(gsi, lhs, pointer, variable, old_type);
- if (!new_variable) return false;
- unsigned int operand = TREE_CODE(TREE_TYPE(op0)) == POINTER_TYPE ? 2 : 1;
- gimple_set_op(stmt, operand, new_variable);
- }
- break;
+ {
+ tree variable = op1;
+ tree pointer = op0;
+ // I want to know if this is an invariant.
+ tree pointer_type = TREE_TYPE (pointer);
+ gcc_assert (TREE_CODE (pointer_type) == POINTER_TYPE);
+ tree new_variable
+ = rewrite_pointer_plus_def_rhs_variable_replace_constants_implementation (
+ gsi, lhs, pointer, variable, old_type);
+ if (!new_variable)
+ return false;
+ unsigned int operand
+ = TREE_CODE (TREE_TYPE (op0)) == POINTER_TYPE ? 2 : 1;
+ gimple_set_op (stmt, operand, new_variable);
+ }
+ break;
default:
- gcc_unreachable();
- break;
- }
+ gcc_unreachable ();
+ break;
+ }
return true;
}
static bool
-rewrite_pointer_diff_def_rhs(gimple *stmt, gimple_stmt_iterator &gsi, tree lhs, tree op0, tree op1, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree>& inverse)
-{
- gcc_assert(op0 && op1);
- tree op0_type = TREE_TYPE(lhs);
- const_tree *new_op0_type = type_map.get(op0_type);
- test_log("rewrite_pointer_diff has old_type %s", 0, new_op0_type ? "true" : "false");
- test_log("rewrite_pointer_diff op0_type %s", 0, get_type_name(op0_type));
+rewrite_pointer_diff_def_rhs (gimple *stmt, gimple_stmt_iterator &gsi, tree lhs,
+ tree op0, tree op1,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
+{
+ gcc_assert (op0 && op1);
+ tree op0_type = TREE_TYPE (lhs);
+ const_tree *new_op0_type = type_map.get (op0_type);
+ test_log ("rewrite_pointer_diff has old_type %s", 0,
+ new_op0_type ? "true" : "false");
+ test_log ("rewrite_pointer_diff op0_type %s", 0, get_type_name (op0_type));
if (new_op0_type)
- test_log("rewrite_pointer_diff new_op0_type %s", 0, get_type_name(*new_op0_type));
-
- rewrite_expr(op0, type_map, 0);
- rewrite_expr(op1, type_map, 0);
-
- tree rhs_type = TREE_TYPE(op0);
- const char* new_type_name = new_op0_type ? get_type_name(*new_op0_type) : get_type_name(op0_type);
- //TODO: I'd prefer to have a parameter
- //that tells me what to change
- test_log("rewrite_pointer_diff new_type_name %s", 0, new_type_name);
- //several stack frames above.
- const_tree *inverse_type_ptr = inverse.get(op0_type);
+ test_log ("rewrite_pointer_diff new_op0_type %s", 0,
+ get_type_name (*new_op0_type));
+
+ rewrite_expr (op0, type_map, 0);
+ rewrite_expr (op1, type_map, 0);
+
+ tree rhs_type = TREE_TYPE (op0);
+ const char *new_type_name
+ = new_op0_type ? get_type_name (*new_op0_type) : get_type_name (op0_type);
+ // TODO: I'd prefer to have a parameter
+ // that tells me what to change
+ test_log ("rewrite_pointer_diff new_type_name %s", 0, new_type_name);
+ // several stack frames above.
+ const_tree *inverse_type_ptr = inverse.get (op0_type);
bool not_in_map_nor_inverse = !new_op0_type && !inverse_type_ptr;
- test_log("continuing? %s", 0, not_in_map_nor_inverse ? "false" : "true");
- if (not_in_map_nor_inverse) return false;
+ test_log ("continuing? %s", 0, not_in_map_nor_inverse ? "false" : "true");
+ if (not_in_map_nor_inverse)
+ return false;
- const_tree old_type = new_op0_type ? (const_tree) op0_type : *inverse_type_ptr;
+ const_tree old_type
+ = new_op0_type ? (const_tree) op0_type : *inverse_type_ptr;
- bool is_op1_int_cst = TREE_CODE(op1) == INTEGER_CST;
+ bool is_op1_int_cst = TREE_CODE (op1) == INTEGER_CST;
tree integer_constant = is_op1_int_cst ? op1 : op0;
- bool has_integer_constant = (TREE_CODE(integer_constant) == INTEGER_CST);
+ bool has_integer_constant = (TREE_CODE (integer_constant) == INTEGER_CST);
// I want to know if this is an invariant.
- if (has_integer_constant) gcc_unreachable();
+ if (has_integer_constant)
+ gcc_unreachable ();
// I want to know if this is an invariant.
- gcc_assert(TREE_CODE(op0_type) == POINTER_TYPE);
- rewrite_pointer_diff_def_rhs_variable_replace_constants_implementation(gsi, lhs, op0, op1, old_type);
+ gcc_assert (TREE_CODE (op0_type) == POINTER_TYPE);
+ rewrite_pointer_diff_def_rhs_variable_replace_constants_implementation (
+ gsi, lhs, op0, op1, old_type);
return true;
}
static bool
-rewrite_assign_rhs(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_assign_rhs (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
bool is_stmt_rewritten = false;
- //WONTFIX, It looks like there is no way to obtain
- //the expression for the rhs. So instead, we have to do
- //this hack.
- //Which expressions can be toplevel?
- enum tree_code code = gimple_expr_code(stmt);
- switch(code)
- {
+ // WONTFIX, It looks like there is no way to obtain
+ // the expression for the rhs. So instead, we have to do
+ // this hack.
+ // Which expressions can be toplevel?
+ enum tree_code code = gimple_expr_code (stmt);
+ switch (code)
+ {
case POINTER_PLUS_EXPR:
{
- tree rhs2 = gimple_assign_rhs2(stmt);
- tree rhs1 = gimple_assign_rhs1(stmt);
- tree lhs = gimple_assign_lhs(stmt);
- tree lhs_type = TREE_TYPE(lhs);
- gcc_assert(lhs_type);
- const_tree* new_type_ptr = type_map.get(lhs_type);
- gcc_assert(lhs && rhs2 && rhs1);
- bool retval = rewrite_pointer_plus_def_rhs(stmt, gsi, lhs, rhs1, rhs2, type_map, inverse);
- if (new_type_ptr) TREE_TYPE(lhs) = (tree)*new_type_ptr;
- return retval;
+ tree rhs2 = gimple_assign_rhs2 (stmt);
+ tree rhs1 = gimple_assign_rhs1 (stmt);
+ tree lhs = gimple_assign_lhs (stmt);
+ tree lhs_type = TREE_TYPE (lhs);
+ gcc_assert (lhs_type);
+ const_tree *new_type_ptr = type_map.get (lhs_type);
+ gcc_assert (lhs && rhs2 && rhs1);
+ bool retval = rewrite_pointer_plus_def_rhs (stmt, gsi, lhs, rhs1, rhs2,
+ type_map, inverse);
+ if (new_type_ptr)
+ TREE_TYPE (lhs) = (tree) *new_type_ptr;
+ return retval;
}
case POINTER_DIFF_EXPR:
{
- tree rhs2 = gimple_assign_rhs2(stmt);
- tree rhs1 = gimple_assign_rhs1(stmt);
- tree lhs = gimple_assign_lhs(stmt);
- tree lhs_type = TREE_TYPE(lhs);
- gcc_assert(lhs_type);
- const_tree* new_type_ptr = type_map.get(lhs_type);
- gcc_assert(lhs && rhs2 && rhs1);
- bool retval = rewrite_pointer_diff_def_rhs(stmt, gsi, lhs, rhs1, rhs2, type_map, inverse);
- if (new_type_ptr) TREE_TYPE(lhs) = (tree)*new_type_ptr;
- return retval;
+ tree rhs2 = gimple_assign_rhs2 (stmt);
+ tree rhs1 = gimple_assign_rhs1 (stmt);
+ tree lhs = gimple_assign_lhs (stmt);
+ tree lhs_type = TREE_TYPE (lhs);
+ gcc_assert (lhs_type);
+ const_tree *new_type_ptr = type_map.get (lhs_type);
+ gcc_assert (lhs && rhs2 && rhs1);
+ bool retval = rewrite_pointer_diff_def_rhs (stmt, gsi, lhs, rhs1, rhs2,
+ type_map, inverse);
+ if (new_type_ptr)
+ TREE_TYPE (lhs) = (tree) *new_type_ptr;
+ return retval;
}
- break;
+ break;
default:
- {
- print_gimple_stmt(dump_file, stmt, 0);
- test_log("DEFAULT HERE: %s", 0, get_tree_code_name(code));
+ {
+ print_gimple_stmt (dump_file, stmt, 0);
+ test_log ("DEFAULT HERE: %s", 0, get_tree_code_name (code));
+ }
+ break;
}
- break;
- }
- switch (gimple_assign_rhs_class(stmt))
- {
- case GIMPLE_TERNARY_RHS:
+ switch (gimple_assign_rhs_class (stmt))
{
- tree rhs3 = gimple_assign_rhs3(stmt);
- is_stmt_rewritten |= rewrite_expr(rhs3, type_map, 0);
- }
+ case GIMPLE_TERNARY_RHS:
+ {
+ tree rhs3 = gimple_assign_rhs3 (stmt);
+ is_stmt_rewritten |= rewrite_expr (rhs3, type_map, 0);
+ }
/* fall through */
case GIMPLE_BINARY_RHS:
- {
- tree rhs2 = gimple_assign_rhs2(stmt);
- is_stmt_rewritten |= rewrite_expr(rhs2, type_map, 0);
- }
+ {
+ tree rhs2 = gimple_assign_rhs2 (stmt);
+ is_stmt_rewritten |= rewrite_expr (rhs2, type_map, 0);
+ }
/* fall through */
case GIMPLE_SINGLE_RHS:
case GIMPLE_UNARY_RHS:
- {
- tree rhs1 = gimple_assign_rhs1(stmt);
- is_stmt_rewritten |= rewrite_expr(rhs1, type_map, 0);
- }
- break;
+ {
+ tree rhs1 = gimple_assign_rhs1 (stmt);
+ is_stmt_rewritten |= rewrite_expr (rhs1, type_map, 0);
+ }
+ break;
default:
- gcc_unreachable();
- break;
- }
+ gcc_unreachable ();
+ break;
+ }
return is_stmt_rewritten;
}
static void
-rewrite_call_lhs(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_call_lhs (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- gcc_assert(stmt);
- test_print_gimple_stmt(stmt);
+ gcc_assert (stmt);
+ test_print_gimple_stmt (stmt);
tree lhs = gimple_call_lhs (stmt);
- //LHS can be null. Example `foo()`
- if (!lhs) return;
+ // LHS can be null. Example `foo()`
+ if (!lhs)
+ return;
- rewrite_expr(lhs, type_map, 0);
+ rewrite_expr (lhs, type_map, 0);
}
static void
-rewrite_call_rhs(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_call_rhs (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- gcc_assert(stmt);
+ gcc_assert (stmt);
tree fn = gimple_call_fn (stmt);
- gcc_assert(fn);
- gcall *call = dyn_cast<gcall*>(stmt);
- tree return_type = gimple_call_return_type(call);
- test_log("what is the return type %s", 0, get_type_name(return_type));
- gcc_assert(return_type);
+ gcc_assert (fn);
+ gcall *call = dyn_cast<gcall *> (stmt);
+ tree return_type = gimple_call_return_type (call);
+ test_log ("what is the return type %s", 0, get_type_name (return_type));
+ gcc_assert (return_type);
- unsigned args = gimple_call_num_args(stmt);
+ unsigned args = gimple_call_num_args (stmt);
for (unsigned i = 0; i < args; i++)
- {
- tree arg = gimple_call_arg(stmt, i);
- rewrite_expr(arg, type_map, 0);
- }
+ {
+ tree arg = gimple_call_arg (stmt, i);
+ rewrite_expr (arg, type_map, 0);
+ }
}
static void
-rewrite_call(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_call (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- rewrite_call_lhs(stmt, gsi, type_map, inverse);
- rewrite_call_rhs(stmt, gsi, type_map, inverse);
+ rewrite_call_lhs (stmt, gsi, type_map, inverse);
+ rewrite_call_rhs (stmt, gsi, type_map, inverse);
}
static void
-rewrite_cond(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_cond (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- tree lhs = gimple_cond_lhs(stmt);
- tree rhs = gimple_cond_rhs(stmt);
- rewrite_expr(lhs, type_map, 0);
- rewrite_expr(rhs, type_map, 0);
+ tree lhs = gimple_cond_lhs (stmt);
+ tree rhs = gimple_cond_rhs (stmt);
+ rewrite_expr (lhs, type_map, 0);
+ rewrite_expr (rhs, type_map, 0);
}
static void
-rewrite_phi(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
-{
- test_log("rewriting phi result", 0);
- tree ssa_result = gimple_phi_result(stmt);
- rewrite_expr(ssa_result, type_map, 0);
- unsigned args = gimple_phi_num_args(stmt);
+rewrite_phi (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
+{
+ test_log ("rewriting phi result", 0);
+ tree ssa_result = gimple_phi_result (stmt);
+ rewrite_expr (ssa_result, type_map, 0);
+ unsigned args = gimple_phi_num_args (stmt);
for (unsigned i = 0; i < args; i++)
- {
- test_log("rewriting phi arg", 0);
- tree arg = gimple_phi_arg_def(stmt, i);
- rewrite_expr(arg, type_map, 0);
- }
+ {
+ test_log ("rewriting phi arg", 0);
+ tree arg = gimple_phi_arg_def (stmt, i);
+ rewrite_expr (arg, type_map, 0);
+ }
}
-
static void
-rewrite_assign(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_assign (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- gcc_assert(stmt);
- test_print_gimple_stmt(stmt);
+ gcc_assert (stmt);
+ test_print_gimple_stmt (stmt);
tree lhs = gimple_assign_lhs (stmt);
- const bool lhs_rewrite = rewrite_expr(lhs, type_map, 0);
- const bool rhs_rewrite = rewrite_assign_rhs(stmt, gsi, type_map, inverse);
- test_print_gimple_stmt(stmt);
+ const bool lhs_rewrite = rewrite_expr (lhs, type_map, 0);
+ const bool rhs_rewrite = rewrite_assign_rhs (stmt, gsi, type_map, inverse);
+ test_print_gimple_stmt (stmt);
}
static void
-rewrite_stmt(gimple *stmt, gimple_stmt_iterator &gsi, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_stmt (gimple *stmt, gimple_stmt_iterator &gsi,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- gcc_assert(stmt);
- const enum gimple_code code = gimple_code(stmt);
+ gcc_assert (stmt);
+ const enum gimple_code code = gimple_code (stmt);
switch (code)
- {
+ {
case GIMPLE_ASSIGN:
- rewrite_assign(stmt, gsi, type_map, inverse);
- break;
+ rewrite_assign (stmt, gsi, type_map, inverse);
+ break;
case GIMPLE_CALL:
- rewrite_call(stmt, gsi, type_map, inverse);
- break;
+ rewrite_call (stmt, gsi, type_map, inverse);
+ break;
case GIMPLE_COND:
- rewrite_cond(stmt, gsi, type_map, inverse);
- break;
+ rewrite_cond (stmt, gsi, type_map, inverse);
+ break;
case GIMPLE_PHI:
- rewrite_phi(stmt, gsi, type_map, inverse);
- break;
+ rewrite_phi (stmt, gsi, type_map, inverse);
+ break;
default:
{
- const char* const gimple_code_str = gimple_code_name[code];
- test_log("gimple_code %s", 0, gimple_code_str);
- test_print_gimple_stmt(stmt);
+ const char *const gimple_code_str = gimple_code_name[code];
+ test_log ("gimple_code %s", 0, gimple_code_str);
+ test_print_gimple_stmt (stmt);
}
- break;
- }
+ break;
+ }
return;
}
static void
-rewrite_basic_block(basic_block bb, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_basic_block (basic_block bb, hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- gcc_assert(bb);
- for (gimple_stmt_iterator gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi))
- {
- gimple *stmt = gsi_stmt(gsi);
- rewrite_stmt(stmt, gsi, type_map, inverse);
- }
- for (gimple_stmt_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gimple *stmt = gsi_stmt(gsi);
- rewrite_stmt(stmt, gsi, type_map, inverse);
- }
+ gcc_assert (bb);
+ for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gimple *stmt = gsi_stmt (gsi);
+ rewrite_stmt (stmt, gsi, type_map, inverse);
+ }
+ for (gimple_stmt_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
+ gsi_next (&gsi))
+ {
+ gimple *stmt = gsi_stmt (gsi);
+ rewrite_stmt (stmt, gsi, type_map, inverse);
+ }
}
static void
-rewrite_function_body(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_function_body (cgraph_node *cnode,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- gcc_assert(cnode);
- cnode->get_untransformed_body();
+ gcc_assert (cnode);
+ cnode->get_untransformed_body ();
basic_block bb = NULL;
function *func = DECL_STRUCT_FUNCTION (cnode->decl);
- push_cfun(func);
+ push_cfun (func);
FOR_EACH_BB_FN (bb, func)
- {
- rewrite_basic_block(bb, type_map, inverse);
- }
+ {
+ rewrite_basic_block (bb, type_map, inverse);
+ }
// TODO:
// can we move this logic into the above?
// Thanks!
size_t i;
tree name;
- FOR_EACH_SSA_NAME(i, name, cfun)
+ FOR_EACH_SSA_NAME (i, name, cfun)
{
- if (SSA_NAME_VAR (name) != NULL_TREE
- && TREE_TYPE(name) != TREE_TYPE(SSA_NAME_VAR(name)))
- {
- TREE_TYPE(name) = TREE_TYPE(SSA_NAME_VAR(name));
- test_log("changing to %s", 0, get_type_name(TREE_TYPE(SSA_NAME_VAR(name))));
- }
+ if (SSA_NAME_VAR (name) != NULL_TREE
+ && TREE_TYPE (name) != TREE_TYPE (SSA_NAME_VAR (name)))
+ {
+ TREE_TYPE (name) = TREE_TYPE (SSA_NAME_VAR (name));
+ test_log ("changing to %s", 0,
+ get_type_name (TREE_TYPE (SSA_NAME_VAR (name))));
+ }
}
- pop_cfun();
- print_function(cnode);
+ pop_cfun ();
+ print_function (cnode);
}
-
static void
-rewrite_local_decl(tree var_decl, hash_map<const_tree, const_tree> &type_map)
+rewrite_local_decl (tree var_decl, hash_map<const_tree, const_tree> &type_map)
{
- gcc_assert(var_decl);
- gcc_assert(TREE_CODE(var_decl) == VAR_DECL);
- const_tree type = TREE_TYPE(var_decl);
- gcc_assert(type);
- const_tree* new_type_ptr = type_map.get(type);
+ gcc_assert (var_decl);
+ gcc_assert (TREE_CODE (var_decl) == VAR_DECL);
+ const_tree type = TREE_TYPE (var_decl);
+ gcc_assert (type);
+ const_tree *new_type_ptr = type_map.get (type);
- if (!new_type_ptr) return;
+ if (!new_type_ptr)
+ return;
const_tree new_type = *new_type_ptr;
- gcc_assert(new_type);
- const char* identifier_old = get_type_name(type);
- const char* identifier_new = get_type_name(new_type);
- test_write("rewriting,local_decl");
- test_print_generic_decl(var_decl);
- test_write(",");
- TREE_TYPE(var_decl) = (tree) new_type;
+ gcc_assert (new_type);
+ const char *identifier_old = get_type_name (type);
+ const char *identifier_new = get_type_name (new_type);
+ test_write ("rewriting,local_decl");
+ test_print_generic_decl (var_decl);
+ test_write (",");
+ TREE_TYPE (var_decl) = (tree) new_type;
// Keep this relayout_decl
- relayout_decl(var_decl);
- test_print_generic_decl(var_decl);
- test_write("\n");
+ relayout_decl (var_decl);
+ test_print_generic_decl (var_decl);
+ test_write ("\n");
}
static void
-rewrite_local_decls(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map)
+rewrite_local_decls (cgraph_node *cnode,
+ hash_map<const_tree, const_tree> &type_map)
{
- gcc_assert(cnode);
+ gcc_assert (cnode);
tree decl = cnode->decl;
- gcc_assert(decl);
- gcc_assert(TREE_CODE(decl) == FUNCTION_DECL);
- function *func = DECL_STRUCT_FUNCTION(decl);
- gcc_assert(func);
+ gcc_assert (decl);
+ gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
+ function *func = DECL_STRUCT_FUNCTION (decl);
+ gcc_assert (func);
tree var_decl = NULL;
int i = 0;
- FOR_EACH_LOCAL_DECL(func, i, var_decl)
- {
- rewrite_local_decl(var_decl, type_map);
- }
- print_function(cnode);
+ FOR_EACH_LOCAL_DECL (func, i, var_decl)
+ {
+ rewrite_local_decl (var_decl, type_map);
+ }
+ print_function (cnode);
}
static void
-rewrite_function_parms(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_function_parms (tree expr, hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- enum tree_code code = TREE_CODE(expr);
+ enum tree_code code = TREE_CODE (expr);
bool is_function_decl = code == FUNCTION_DECL;
- gcc_assert(is_function_decl);
-
- for (tree parm = DECL_ARGUMENTS(expr); parm; parm = DECL_CHAIN(parm))
- {
- tree parm_type = TREE_TYPE(parm);
- const_tree *type_ptr = type_map.get(parm_type);
- if (!type_ptr) continue;
-
- test_log("before rewrite_function_arg %s", 0, get_type_name(parm_type));
- TREE_TYPE(parm) = (tree) *type_ptr;
- relayout_decl(parm);
- tree parm_type_2 = TREE_TYPE(parm);
- test_log("after rewrite_function_arg %s", 0, get_type_name(parm_type_2));
- }
+ gcc_assert (is_function_decl);
+ for (tree parm = DECL_ARGUMENTS (expr); parm; parm = DECL_CHAIN (parm))
+ {
+ tree parm_type = TREE_TYPE (parm);
+ const_tree *type_ptr = type_map.get (parm_type);
+ if (!type_ptr)
+ continue;
+
+ test_log ("before rewrite_function_arg %s", 0, get_type_name (parm_type));
+ TREE_TYPE (parm) = (tree) *type_ptr;
+ relayout_decl (parm);
+ tree parm_type_2 = TREE_TYPE (parm);
+ test_log ("after rewrite_function_arg %s", 0,
+ get_type_name (parm_type_2));
+ }
}
static void
-rewrite_function_parms(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map)
+rewrite_function_parms (cgraph_node *cnode,
+ hash_map<const_tree, const_tree> &type_map)
{
- //TODO: Do we need to do get_untransformed_body here?
- //TODO: Do we need to somehow relayout the whole function itself?
- rewrite_function_parms(cnode->decl, type_map, 0);
+ // TODO: Do we need to do get_untransformed_body here?
+ // TODO: Do we need to somehow relayout the whole function itself?
+ rewrite_function_parms (cnode->decl, type_map, 0);
}
static void
-rewrite_function_return_type(tree expr, hash_map<const_tree, const_tree> &type_map, const int indent)
+rewrite_function_return_type (tree expr,
+ hash_map<const_tree, const_tree> &type_map,
+ const int indent)
{
- enum tree_code code = TREE_CODE(expr);
- bool is_function_decl = code == FUNCTION_DECL;
- gcc_assert(is_function_decl);
+ enum tree_code code = TREE_CODE (expr);
+ bool is_function_decl = code == FUNCTION_DECL;
+ gcc_assert (is_function_decl);
- tree function_type = TREE_TYPE(expr);
+ tree function_type = TREE_TYPE (expr);
// TODO: We do not support method's yet.
- gcc_assert(TREE_CODE(function_type) == FUNCTION_TYPE);
- tree function_return_type = TREE_TYPE(function_type);
- gcc_assert(function_return_type);
-
- test_log("before rewrite_function_return_type %s", indent, get_type_name(function_return_type));
- const_tree *new_type_ptr = type_map.get(function_return_type);
- if (!new_type_ptr) return;
+ gcc_assert (TREE_CODE (function_type) == FUNCTION_TYPE);
+ tree function_return_type = TREE_TYPE (function_type);
+ gcc_assert (function_return_type);
+
+ test_log ("before rewrite_function_return_type %s", indent,
+ get_type_name (function_return_type));
+ const_tree *new_type_ptr = type_map.get (function_return_type);
+ if (!new_type_ptr)
+ return;
- TREE_TYPE(function_type) = (tree) *new_type_ptr;
- //relayout_decl(cnode->decl);
- tree function_type_2 = TREE_TYPE(expr);
- tree function_return_type_2 = TREE_TYPE(function_type_2);
- test_log("after rewrite_function_return_type %s", indent, get_type_name(function_return_type_2));
+ TREE_TYPE (function_type) = (tree) *new_type_ptr;
+ // relayout_decl(cnode->decl);
+ tree function_type_2 = TREE_TYPE (expr);
+ tree function_return_type_2 = TREE_TYPE (function_type_2);
+ test_log ("after rewrite_function_return_type %s", indent,
+ get_type_name (function_return_type_2));
}
static void
-rewrite_function_return_type(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map)
+rewrite_function_return_type (cgraph_node *cnode,
+ hash_map<const_tree, const_tree> &type_map)
{
-
- gcc_assert(TREE_CODE(cnode->decl) == FUNCTION_DECL);
- tree function_type = TREE_TYPE(cnode->decl);
- gcc_assert(function_type);
- rewrite_function_return_type(cnode->decl, type_map, 0);
+ gcc_assert (TREE_CODE (cnode->decl) == FUNCTION_DECL);
+ tree function_type = TREE_TYPE (cnode->decl);
+ gcc_assert (function_type);
+ rewrite_function_return_type (cnode->decl, type_map, 0);
}
static void
-rewrite_global_decl(varpool_node *vnode, hash_map<const_tree, const_tree> &type_map)
+rewrite_global_decl (varpool_node *vnode,
+ hash_map<const_tree, const_tree> &type_map)
{
int i;
struct ipa_ref *ref;
/* Only IPA_REF_STORE and IPA_REF_LOAD left. */
for (i = 0; vnode->iterate_referring (i, ref); i++)
- {
- symtab_node *f_node = ref->referring;
- cgraph_node *f_cnode = dyn_cast<cgraph_node *> (f_node);
-
- test_log("rewriting global declaration", 0);
- rewrite_local_decl(vnode->decl, type_map);
- test_print_generic_decl(vnode->decl);
- }
+ {
+ symtab_node *f_node = ref->referring;
+ cgraph_node *f_cnode = dyn_cast<cgraph_node *> (f_node);
+ test_log ("rewriting global declaration", 0);
+ rewrite_local_decl (vnode->decl, type_map);
+ test_print_generic_decl (vnode->decl);
+ }
}
static void
-rewrite_global_decls(hash_map<const_tree, const_tree> &type_map)
+rewrite_global_decls (hash_map<const_tree, const_tree> &type_map)
{
varpool_node *vnode;
- FOR_EACH_VARIABLE(vnode)
- {
- rewrite_global_decl(vnode, type_map);
- }
+ FOR_EACH_VARIABLE (vnode)
+ {
+ rewrite_global_decl (vnode, type_map);
+ }
}
static void
-rewrite_function(cgraph_node *cnode, hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
-{
- //rewrite_function_body should be before
- //rewrite_local_decls to make work easier.
- //Why? Because if we rewrite local decl types
- //first, then we might need to look for
- //old AND new types in rewrite_function_body.
- //If we rewrite local decl types later,
- //then in rewrite_function_body we only
- //need to look for old types.
- rewrite_function_parms(cnode, type_map);
- rewrite_function_return_type(cnode, type_map);
- rewrite_function_body(cnode, type_map, inverse);
- rewrite_local_decls(cnode, type_map);
+rewrite_function (cgraph_node *cnode,
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
+{
+ // rewrite_function_body should be before
+ // rewrite_local_decls to make work easier.
+ // Why? Because if we rewrite local decl types
+ // first, then we might need to look for
+ // old AND new types in rewrite_function_body.
+ // If we rewrite local decl types later,
+ // then in rewrite_function_body we only
+ // need to look for old types.
+ rewrite_function_parms (cnode, type_map);
+ rewrite_function_return_type (cnode, type_map);
+ rewrite_function_body (cnode, type_map, inverse);
+ rewrite_local_decls (cnode, type_map);
}
static void
-rewrite_functions(hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_functions (hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
cgraph_node *cnode = NULL;
- FOR_EACH_DEFINED_FUNCTION(cnode)
- {
- rewrite_function(cnode, type_map, inverse);
- }
+ FOR_EACH_DEFINED_FUNCTION (cnode)
+ {
+ rewrite_function (cnode, type_map, inverse);
+ }
}
-//TODO:
-//Get rid of this function but make sure test still pass
+// TODO:
+// Get rid of this function but make sure test still pass
bool
-rewrite_references_to_modified_structs_internal(const_tree const &old_type,
- const_tree* new_type,
- __attribute__((unused))void*)
-{
- const char* identifier = get_type_name(old_type);
- tree old_struct_size_tree_1 = TYPE_SIZE_UNIT(*new_type);
- tree old_struct_size_tree_2 = TYPE_SIZE_UNIT(old_type);
- int old_struct_size_int = old_struct_size_tree_1 && (old_struct_size_tree_1 != NULL_TREE) ? tree_to_shwi(old_struct_size_tree_1) : -1;
- int old_struct_size_int_2 = old_struct_size_tree_2 && (old_struct_size_tree_2 != NULL_TREE) ? tree_to_shwi(old_struct_size_tree_2) : -1;
- test_log("rewriting,%s,%s,%d,%d", 0, identifier, get_type_name(*new_type), old_struct_size_int_2, old_struct_size_int);
+rewrite_references_to_modified_structs_internal (
+ const_tree const &old_type, const_tree *new_type,
+ __attribute__ ((unused)) void *)
+{
+ const char *identifier = get_type_name (old_type);
+ tree old_struct_size_tree_1 = TYPE_SIZE_UNIT (*new_type);
+ tree old_struct_size_tree_2 = TYPE_SIZE_UNIT (old_type);
+ int old_struct_size_int
+ = old_struct_size_tree_1 && (old_struct_size_tree_1 != NULL_TREE)
+ ? tree_to_shwi (old_struct_size_tree_1)
+ : -1;
+ int old_struct_size_int_2
+ = old_struct_size_tree_2 && (old_struct_size_tree_2 != NULL_TREE)
+ ? tree_to_shwi (old_struct_size_tree_2)
+ : -1;
+ test_log ("rewriting,%s,%s,%d,%d", 0, identifier, get_type_name (*new_type),
+ old_struct_size_int_2, old_struct_size_int);
return true;
}
static void
-rewrite_references_to_modified_structs(hash_map<const_tree, const_tree> &type_map, hash_map<const_tree, const_tree> &inverse)
+rewrite_references_to_modified_structs (
+ hash_map<const_tree, const_tree> &type_map,
+ hash_map<const_tree, const_tree> &inverse)
{
- type_map.traverse<void*, rewrite_references_to_modified_structs_internal>(NULL);
- rewrite_functions(type_map, inverse);
- rewrite_global_decls(type_map);
+ type_map.traverse<void *, rewrite_references_to_modified_structs_internal> (
+ NULL);
+ rewrite_functions (type_map, inverse);
+ rewrite_global_decls (type_map);
}
bool
-compute_inverse_type_map_internal(const_tree const & old_type,
- const_tree* new_type,
- hash_map<const_tree, const_tree>* inverse_map)
-{
- gcc_assert(new_type && *new_type);
- gcc_assert(inverse_map);
- inverse_map->put(*new_type, old_type);
- const char* old_identifier = get_type_name(old_type);
- const char* new_identifier = get_type_name(*new_type);
- test_log("inverse,%s,%s", 0, new_identifier,old_identifier);
+compute_inverse_type_map_internal (
+ const_tree const &old_type, const_tree *new_type,
+ hash_map<const_tree, const_tree> *inverse_map)
+{
+ gcc_assert (new_type && *new_type);
+ gcc_assert (inverse_map);
+ inverse_map->put (*new_type, old_type);
+ const char *old_identifier = get_type_name (old_type);
+ const char *new_identifier = get_type_name (*new_type);
+ test_log ("inverse,%s,%s", 0, new_identifier, old_identifier);
return true;
}
static void
-compute_inverse_type_map(hash_map<const_tree, const_tree> &mod_type_map,
- hash_map<const_tree, const_tree> &inverse_map)
+compute_inverse_type_map (hash_map<const_tree, const_tree> &mod_type_map,
+ hash_map<const_tree, const_tree> &inverse_map)
{
- mod_type_map.traverse<hash_map<const_tree, const_tree>*, compute_inverse_type_map_internal>(&inverse_map);
+ mod_type_map.traverse<hash_map<const_tree, const_tree> *,
+ compute_inverse_type_map_internal> (&inverse_map);
}
static unsigned int
-iphw_execute()
+iphw_execute ()
{
- test_log("Executing structreorg", 0);
-
- //TODO: change orig_type_map to hash_set.
+ test_log ("Executing structreorg", 0);
+
+ // TODO: change orig_type_map to hash_set.
hash_map<const_tree, tree> orig_type_map;
- collect_orig_structs(orig_type_map);
+ collect_orig_structs (orig_type_map);
- //TODO: ideally mod_type_map would be a bidirectional map.
- //but we work with what we have.
+ // TODO: ideally mod_type_map would be a bidirectional map.
+ // but we work with what we have.
hash_map<const_tree, const_tree> mod_type_map;
- compute_modified_structs(orig_type_map, mod_type_map);
+ compute_modified_structs (orig_type_map, mod_type_map);
hash_map<const_tree, const_tree> inverse_type_map;
- compute_inverse_type_map(mod_type_map, inverse_type_map);
- rewrite_references_to_modified_structs(mod_type_map, inverse_type_map);
+ compute_inverse_type_map (mod_type_map, inverse_type_map);
+ rewrite_references_to_modified_structs (mod_type_map, inverse_type_map);
return 0;
}
int
-str_reorg_dead_field_eliminate( Info *info)
+str_reorg_dead_field_eliminate (Info *info)
{
- gcc_assert(in_lto_p);
- return iphw_execute();
+ gcc_assert (in_lto_p);
+ return iphw_execute ();
}
-
diff --git a/gcc/ipa-str-reorg-field-reorder.c b/gcc/ipa-str-reorg-field-reorder.c
index c5030d9cc41..5c9a2bb0b9b 100644
--- a/gcc/ipa-str-reorg-field-reorder.c
+++ b/gcc/ipa-str-reorg-field-reorder.c
@@ -39,9 +39,9 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
int
-str_reorg_field_reorder( Info *info)
+str_reorg_field_reorder (Info *info)
{
// TBD
- //DEBUG ( "Running str_reorg_field_reorder\n");
+ // DEBUG ( "Running str_reorg_field_reorder\n");
return 0;
}
diff --git a/gcc/ipa-str-reorg-instance-interleave.c b/gcc/ipa-str-reorg-instance-interleave.c
index b6488ec6dfb..2b5d4afd81b 100644
--- a/gcc/ipa-str-reorg-instance-interleave.c
+++ b/gcc/ipa-str-reorg-instance-interleave.c
@@ -40,7 +40,7 @@ along with GCC; see the file COPYING3. If not see
int
// Returns one if something was done and zero otherwise.
-str_reorg_instance_interleave( Info *info)
+str_reorg_instance_interleave (Info *info)
{
// TBD
// DEBUG ( "Running str_reorg_instance_interleave\n");
diff --git a/gcc/ipa-structure-reorg.c b/gcc/ipa-structure-reorg.c
index 43e0de0da3f..603d160349b 100644
--- a/gcc/ipa-structure-reorg.c
+++ b/gcc/ipa-structure-reorg.c
@@ -39,215 +39,223 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
// TBD more includes go here
-
-static void setup_debug_flags ( Info *);
-static void final_debug_info ( Info *);
-static unsigned int reorg_analysis ( Info_t *);
-static void reorg_analysis_debug ( Info *, ReorgType *);
-static bool find_decls_and_types ( Info_t *);
-static void disqualify_struct_in_struct_or_union ( Info_t *);
-static void initial_reorg_debug ( Info *info, ReorgType *reorg );
-static void disqualify_struct_in_struct_or_union_debug ( Info *,
- ReorgType *);
-static void disq_str_in_str_or_union_helper ( tree,
- std::set<tree> *,
- Info_t *);
-static unsigned int reorg_qualification ( Info_t *);
+static void
+setup_debug_flags (Info *);
+static void
+final_debug_info (Info *);
+static unsigned int
+reorg_analysis (Info_t *);
+static void
+reorg_analysis_debug (Info *, ReorgType *);
+static bool
+find_decls_and_types (Info_t *);
+static void
+disqualify_struct_in_struct_or_union (Info_t *);
+static void
+initial_reorg_debug (Info *info, ReorgType *reorg);
+static void
+disqualify_struct_in_struct_or_union_debug (Info *, ReorgType *);
+static void
+disq_str_in_str_or_union_helper (tree, std::set<tree> *, Info_t *);
+static unsigned int
+reorg_qualification (Info_t *);
// Name changed and moved to its own file
-//static void reorg_transformation ( Info_t *);
+// static void reorg_transformation ( Info_t *);
// made extern
-//static void delete_reorgtype ( ReorgType_t *, Info_t *);
-//static void undelete_reorgtype ( ReorgType_t *, Info_t *);
-//static void remove_deleted_types ( Info *, ReorgFn);
-static tree base_type_of ( tree);
-static bool is_reorg_alloc_trigger ( gimple *);
-static ReorgType_t *find_struct_type_ptr_to_struct ( tree, Info *);
-static ReorgType_t *get_reorgtype_info ( tree type, Info_t* info);
-static void print_reorg_with_msg ( FILE *, ReorgType_t *, int, const char *);
-static void dump_reorg ( ReorgType_t *reorg);
-static void print_reorgs ( FILE *, int, Info *);
-static void print_reorg ( FILE *, int, ReorgType_t *);
+// static void delete_reorgtype ( ReorgType_t *, Info_t *);
+// static void undelete_reorgtype ( ReorgType_t *, Info_t *);
+// static void remove_deleted_types ( Info *, ReorgFn);
+static tree base_type_of (tree);
+static bool
+is_reorg_alloc_trigger (gimple *);
+static ReorgType_t *
+find_struct_type_ptr_to_struct (tree, Info *);
+static ReorgType_t *
+get_reorgtype_info (tree type, Info_t *info);
+static void
+print_reorg_with_msg (FILE *, ReorgType_t *, int, const char *);
+static void
+dump_reorg (ReorgType_t *reorg);
+static void
+print_reorgs (FILE *, int, Info *);
+static void
+print_reorg (FILE *, int, ReorgType_t *);
//-- debugging only --
-static const char *code_str( enum tree_code);
+static const char *code_str (enum tree_code);
//---------------- Code Follows ----------------
-
+
static unsigned int
-ipa_structure_reorg ( void)
+ipa_structure_reorg (void)
{
- std::vector <ReorgType_t> Reorg_Type;
- std::vector <ReorgType_t> Saved_Reorg_Type;
- std::vector <ProgDecl_t> Prog_Decl;
- std::map <tree,BoolPair_t> StructTypes; // TBD horrible type name
+ std::vector<ReorgType_t> Reorg_Type;
+ std::vector<ReorgType_t> Saved_Reorg_Type;
+ std::vector<ProgDecl_t> Prog_Decl;
+ std::map<tree, BoolPair_t> StructTypes; // TBD horrible type name
- //DEBUG( "Running ipa_structure_reorg\n");
+ // DEBUG( "Running ipa_structure_reorg\n");
// TBD we must have run the IPA points-to analysis and
// be running in a single LTRANS partition. Sanity check
// these here.
- Info_t info = { &Reorg_Type,
- &Saved_Reorg_Type,
- &Prog_Decl,
- &StructTypes,
- 0,
- 0.0,
- false,
- false,
- false,
- false,
- false,
- false};
-
- setup_debug_flags ( &info);
-
- if( flag_ipa_dead_field_eliminate ) {
- str_reorg_dead_field_eliminate ( &info);
- }
-
- if ( !reorg_analysis ( &info) )
- {
- return true;
- }
+ Info_t info = {&Reorg_Type, &Saved_Reorg_Type,
+ &Prog_Decl, &StructTypes,
+ 0, 0.0,
+ false, false,
+ false, false,
+ false, false};
+ setup_debug_flags (&info);
- if ( reorg_qualification ( &info) )
- {
- // Each of these do their own performance qualification and
- // if they delete any types they must invoke restore_deleted_types
- // so the next subpass has all the types to consider.
- // Also, if they change the shape of a type the must create my
- // type and update the ReorgTypes to reflect this.
-
- if( flag_ipa_structure_reorg || flag_ipa_field_reorder ) {
- str_reorg_field_reorder ( &info);
- }
- if( flag_ipa_structure_reorg || flag_ipa_instance_interleave ) {
- str_reorg_instance_interleave ( &info);
+ if (flag_ipa_dead_field_eliminate)
+ {
+ str_reorg_dead_field_eliminate (&info);
}
- }
- final_debug_info ( &info);
+ if (!reorg_analysis (&info))
+ {
+ return true;
+ }
+
+ if (reorg_qualification (&info))
+ {
+ // Each of these do their own performance qualification and
+ // if they delete any types they must invoke restore_deleted_types
+ // so the next subpass has all the types to consider.
+ // Also, if they change the shape of a type the must create my
+ // type and update the ReorgTypes to reflect this.
+
+ if (flag_ipa_structure_reorg || flag_ipa_field_reorder)
+ {
+ str_reorg_field_reorder (&info);
+ }
+ if (flag_ipa_structure_reorg || flag_ipa_instance_interleave)
+ {
+ str_reorg_instance_interleave (&info);
+ }
+ }
+
+ final_debug_info (&info);
return true;
}
static void
-setup_debug_flags ( Info *info)
+setup_debug_flags (Info *info)
{
// The normal way of doing this would be to
// set the flags with dump_file && (dump_flags & TDF_XXX
// where XXX is some level of dump control but
// I think the code here would work better
// (where each flag is set off the dump_flags.)
-
- if ( dump_file )
- {
- info->show_all_reorg_cands = true;
- info->show_all_reorg_cands_in_detail = dump_flags & TDF_DETAILS;
- info->show_delete = dump_flags & TDF_DETAILS;
- info->show_new_BBs = dump_flags & TDF_DETAILS;
- info->show_transforms = dump_flags & TDF_DETAILS;
- info->show_bounds = dump_flags & TDF_DETAILS;
- }
+
+ if (dump_file)
+ {
+ info->show_all_reorg_cands = true;
+ info->show_all_reorg_cands_in_detail = dump_flags & TDF_DETAILS;
+ info->show_delete = dump_flags & TDF_DETAILS;
+ info->show_new_BBs = dump_flags & TDF_DETAILS;
+ info->show_transforms = dump_flags & TDF_DETAILS;
+ info->show_bounds = dump_flags & TDF_DETAILS;
+ }
}
static void
-final_debug_info ( Info *info)
+final_debug_info (Info *info)
{
// TBD
}
static unsigned int
-reorg_analysis ( Info_t *info)
+reorg_analysis (Info_t *info)
{
struct cgraph_node *node;
- find_decls_and_types ( info);
+ find_decls_and_types (info);
// Skip computing numbOfGlobalArrays initially.
// Skip computing numbOfLocalArrays initially.
// Compute numbOfDynmAllocs per type in regtype
- FOR_EACH_FUNCTION ( node) {
- basic_block bb;
-
- struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
-
- // This is a work around
- if( func == NULL )
- {
- continue;
- }
-
- FOR_EACH_BB_FN ( bb, func)
- {
- gimple_stmt_iterator gsi;
- for ( gsi = gsi_start_bb ( bb);
- !gsi_end_p ( gsi);
- gsi_next ( &gsi) )
- {
- gimple *stmt = gsi_stmt ( gsi);
- //DEBUG_F ( print_gimple_stmt, stderr, stmt, (dump_flags_t)-1);
- //DEBUG ( "\n");
- if ( is_gimple_call ( stmt) )
+ FOR_EACH_FUNCTION (node)
+ {
+ basic_block bb;
+
+ struct function *func = DECL_STRUCT_FUNCTION (node->decl);
+
+ // This is a work around
+ if (func == NULL)
{
- // next line has issues but the mechanism is sound
- tree t = *gimple_call_lhs_ptr ( stmt);
- //DEBUG( "t %p\n", t);
- // Calls to a function returning void are skipped.
- if ( t != NULL )
- {
- tree bt = base_type_of ( t);
- if ( TREE_CODE( bt) != RECORD_TYPE )
- {
- continue;
- }
- // find if in reorgtypes and get the info (in one call)
- ReorgType_t *ri = get_reorgtype_info ( bt, info);
- if ( ri != NULL && is_reorg_alloc_trigger ( stmt) )
+ continue;
+ }
+
+ FOR_EACH_BB_FN (bb, func)
+ {
+ gimple_stmt_iterator gsi;
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
- ri->numbOfDynmAllocs++;
+ gimple *stmt = gsi_stmt (gsi);
+ // DEBUG_F ( print_gimple_stmt, stderr, stmt, (dump_flags_t)-1);
+ // DEBUG ( "\n");
+ if (is_gimple_call (stmt))
+ {
+ // next line has issues but the mechanism is sound
+ tree t = *gimple_call_lhs_ptr (stmt);
+ // DEBUG( "t %p\n", t);
+ // Calls to a function returning void are skipped.
+ if (t != NULL)
+ {
+ tree bt = base_type_of (t);
+ if (TREE_CODE (bt) != RECORD_TYPE)
+ {
+ continue;
+ }
+ // find if in reorgtypes and get the info (in one call)
+ ReorgType_t *ri = get_reorgtype_info (bt, info);
+ if (ri != NULL && is_reorg_alloc_trigger (stmt))
+ {
+ ri->numbOfDynmAllocs++;
+ }
+ }
+ }
}
- }
}
- }
}
- }
// It's LOT clear to use an iterator here TBD
- for ( int i = 0; i < info->reorg_type->size (); i++ )
- {
- int n = (*(info->reorg_type))[i].numbOfGlobalArrays
- + (*(info->reorg_type))[i].numbOfLocalArrays
- + (*(info->reorg_type))[i].numbOfDynmAllocs;
- if ( n > 1 )
+ for (int i = 0; i < info->reorg_type->size (); i++)
{
- (*(info->reorg_type))[i].multi_pool = true;
- }
- if ( n == 0 )
- {
- delete_reorgtype ( &(*(info->reorg_type))[i], info);
+ int n = (*(info->reorg_type))[i].numbOfGlobalArrays
+ + (*(info->reorg_type))[i].numbOfLocalArrays
+ + (*(info->reorg_type))[i].numbOfDynmAllocs;
+ if (n > 1)
+ {
+ (*(info->reorg_type))[i].multi_pool = true;
+ }
+ if (n == 0)
+ {
+ delete_reorgtype (&(*(info->reorg_type))[i], info);
+ }
}
- }
- remove_deleted_types ( info, &reorg_analysis_debug);
+ remove_deleted_types (info, &reorg_analysis_debug);
return !info->reorg_type->empty ();
}
void
-reorg_analysis_debug ( Info *info, ReorgType *reorg )
+reorg_analysis_debug (Info *info, ReorgType *reorg)
{
- if ( info->show_delete )
- {
- print_reorg_with_msg ( dump_file, reorg, 2,
- "Was not allocated");
- }
+ if (info->show_delete)
+ {
+ print_reorg_with_msg (dump_file, reorg, 2, "Was not allocated");
+ }
}
-static bool find_decls_and_types ( Info_t *info)
+static bool
+find_decls_and_types (Info_t *info)
{
// Don't keep any structure types if they aren't
// used in an array or have a pointer type (which
@@ -256,101 +264,101 @@ static bool find_decls_and_types ( Info_t *info)
// allocated arrays.
//
// This initializes them too of course.
-
+
// Find all struct types for initial ReorgTypes
// marking them all to initially be deleted.
// This is done by walking all variables.
std::set<tree> typeset;
varpool_node *var;
- FOR_EACH_VARIABLE ( var)
- {
- tree decl = var->decl;
- //DEBUG( "L# %d Consider var->decl\n", __LINE__);
- //DEBUG_F( print_generic_decl, stderr, decl, (dump_flags_t)-1);
- tree base = base_type_of ( decl);
- //DEBUG( "\nBase\n");
- //DEBUG( "TREE_CODE = %s\n", code_str( TREE_CODE ( base)));
- //DEBUG_F( print_generic_expr, stderr, base, (dump_flags_t)-1);
- //DEBUG( "\n");
-
- if ( TREE_CODE ( base) == RECORD_TYPE )
- {
- // skip if found before
- if( typeset.find ( base) != typeset.end () )
- {
- //DEBUG( "not found\n");
- continue;
- } else {
- //DEBUG( "found\n")
- ;
- }
- ReorgType_t rt =
- { 0, base, 0, 0, 0, 0.0, 0.0, false, true, NULL, NULL };
- info->reorg_type->push_back ( rt);
- typeset.insert ( base); // ???
+ FOR_EACH_VARIABLE (var)
+ {
+ tree decl = var->decl;
+ // DEBUG( "L# %d Consider var->decl\n", __LINE__);
+ // DEBUG_F( print_generic_decl, stderr, decl, (dump_flags_t)-1);
+ tree base = base_type_of (decl);
+ // DEBUG( "\nBase\n");
+ // DEBUG( "TREE_CODE = %s\n", code_str( TREE_CODE ( base)));
+ // DEBUG_F( print_generic_expr, stderr, base, (dump_flags_t)-1);
+ // DEBUG( "\n");
+
+ if (TREE_CODE (base) == RECORD_TYPE)
+ {
+ // skip if found before
+ if (typeset.find (base) != typeset.end ())
+ {
+ // DEBUG( "not found\n");
+ continue;
+ }
+ else
+ {
+ // DEBUG( "found\n")
+ ;
+ }
+ ReorgType_t rt
+ = {0, base, 0, 0, 0, 0.0, 0.0, false, true, NULL, NULL};
+ info->reorg_type->push_back (rt);
+ typeset.insert (base); // ???
+ }
}
- }
-
+
// NOTE, the scheme above leaves out local variables so
// I'll repeat the for the local variable of functions.
// TBD Am I doing something actually, after this, that
// is actually done here or above... it seems likely.
- cgraph_node* node;
- FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
- {
- tree decl;
- unsigned i;
-
- node->get_untransformed_body ();
-
- struct function *fn = DECL_STRUCT_FUNCTION ( node->decl);
- // enable this to see error in test_1_8
- //DEBUG( "L# %d, function name = %s\n",
- //__LINE__, lang_hooks.decl_printable_name ( node->decl, 2));
- if( fn == NULL )
+ cgraph_node *node;
+ FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
{
- //DEBUG( " EMPTY\n");
- continue;
- }
+ tree decl;
+ unsigned i;
- FOR_EACH_LOCAL_DECL ( fn, i, decl)
- {
- tree base = base_type_of ( decl);
+ node->get_untransformed_body ();
+
+ struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
// enable this to see error in test_1_8
- //DEBUG( "L# %d Consider local var decl\n", __LINE__);
- //DEBUG_F( print_generic_decl, stderr, decl, (dump_flags_t)-1);
- //DEBUG( "\n");
-
- if ( TREE_CODE ( base) == RECORD_TYPE)
- {
- if( typeset.find ( base) != typeset.end () )
- {
+ // DEBUG( "L# %d, function name = %s\n",
+ //__LINE__, lang_hooks.decl_printable_name ( node->decl, 2));
+ if (fn == NULL)
+ {
+ // DEBUG( " EMPTY\n");
continue;
}
- ReorgType_t rt =
- { 0, base, 0, 0, 0, 0.0, 0.0, false, true, NULL, NULL };
- info->reorg_type->push_back ( rt);
- typeset.insert ( base); // ???
- }
+ FOR_EACH_LOCAL_DECL (fn, i, decl)
+ {
+ tree base = base_type_of (decl);
+ // enable this to see error in test_1_8
+ // DEBUG( "L# %d Consider local var decl\n", __LINE__);
+ // DEBUG_F( print_generic_decl, stderr, decl, (dump_flags_t)-1);
+ // DEBUG( "\n");
+
+ if (TREE_CODE (base) == RECORD_TYPE)
+ {
+ if (typeset.find (base) != typeset.end ())
+ {
+ continue;
+ }
+
+ ReorgType_t rt
+ = {0, base, 0, 0, 0, 0.0, 0.0, false, true, NULL, NULL};
+ info->reorg_type->push_back (rt);
+ typeset.insert (base); // ???
+ }
+ }
}
- }
-
// We need this later for creating new types
- for ( std::set<tree>::iterator ti = typeset.begin ();
- ti != typeset.end ();
- ti++ )
- {
- (*(info->struct_types))[*ti] = { false, false };
- }
+ for (std::set<tree>::iterator ti = typeset.begin (); ti != typeset.end ();
+ ti++)
+ {
+ (*(info->struct_types))[*ti] = {false, false};
+ }
- if ( info->show_all_reorg_cands_in_detail )
- {
- fprintf ( dump_file, "All possible candidates:\n");
- print_reorgs ( dump_file, 2, info);
- }
+ if (info->show_all_reorg_cands_in_detail)
+ {
+ fprintf (dump_file, "All possible candidates:\n");
+ print_reorgs (dump_file, 2, info);
+ }
// Scan all declarations for pointers to ReorgTypes
// and in a later version array of them. When found
@@ -358,54 +366,54 @@ static bool find_decls_and_types ( Info_t *info)
// Note, there is no mechanism for looking at global declarations
// so use FOR_EACH_VARIABLE instead. I'm not 100% this is the thing
// actuall do here... but...
- FOR_EACH_VARIABLE ( var)
- {
- tree decl = var->decl;
- ReorgType_t *rtype = find_struct_type_ptr_to_struct ( decl, info);
- if ( rtype != NULL )
+ FOR_EACH_VARIABLE (var)
{
- undelete_reorgtype ( rtype, info);
+ tree decl = var->decl;
+ ReorgType_t *rtype = find_struct_type_ptr_to_struct (decl, info);
+ if (rtype != NULL)
+ {
+ undelete_reorgtype (rtype, info);
+ }
}
- }
- FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
- {
- tree decl;
- unsigned i;
-
- // Only need to do this once in the program and it was done
- // above!
- //Node->get_untransformed_body ();
-
- struct function *fn = DECL_STRUCT_FUNCTION ( node->decl);
-
- //DEBUG( "fn %p\n", fn);
- //DEBUG_F( print_generic_decl, stderr, node->decl, (dump_flags_t)-1);
- //DEBUG( "\n");
- // I don't know why this is coming up null.... but I'll
- // skip it for now.
- if( fn == NULL )
- {
- continue;
- }
-
- FOR_EACH_LOCAL_DECL ( fn, i, decl)
- {
- // Does this work... see tree.c:6132
- ReorgType_t *rtype = find_struct_type_ptr_to_struct ( decl, info);
- if ( rtype != NULL )
- {
- undelete_reorgtype ( rtype, info);
- }
+ FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
+ {
+ tree decl;
+ unsigned i;
+
+ // Only need to do this once in the program and it was done
+ // above!
+ // Node->get_untransformed_body ();
+
+ struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
+
+ // DEBUG( "fn %p\n", fn);
+ // DEBUG_F( print_generic_decl, stderr, node->decl, (dump_flags_t)-1);
+ // DEBUG( "\n");
+ // I don't know why this is coming up null.... but I'll
+ // skip it for now.
+ if (fn == NULL)
+ {
+ continue;
+ }
+
+ FOR_EACH_LOCAL_DECL (fn, i, decl)
+ {
+ // Does this work... see tree.c:6132
+ ReorgType_t *rtype = find_struct_type_ptr_to_struct (decl, info);
+ if (rtype != NULL)
+ {
+ undelete_reorgtype (rtype, info);
+ }
+ }
+ }
+
+ if (info->show_all_reorg_cands)
+ {
+ fprintf (dump_file, "All preliminary ReorgTypes:\n");
+ // print_reorgs ( dump_file, 2, info);
}
- }
- if ( info->show_all_reorg_cands )
- {
- fprintf ( dump_file, "All preliminary ReorgTypes:\n");
- //print_reorgs ( dump_file, 2, info);
- }
-
// Scan all types in ReorgTypes for structure fields
// and if they are pointers to a type Q in ReorgTypes
// then clear the deletion mark of Q. Note, at this
@@ -419,186 +427,179 @@ static bool find_decls_and_types ( Info_t *info)
// that type. This of course assumes sane programming
// practices and if they violate those structure reorg has
// every right to punt.
- for ( std::vector<ReorgType_t>::iterator ri = info->reorg_type->begin ();
- ri != info->reorg_type->end ();
- ri++ )
- {
- for ( tree fld = TYPE_FIELDS ( ri->gcc_type);
- fld;
- fld = DECL_CHAIN ( fld) )
+ for (std::vector<ReorgType_t>::iterator ri = info->reorg_type->begin ();
+ ri != info->reorg_type->end (); ri++)
{
- ReorgType_t *rtype =
- find_struct_type_ptr_to_struct ( fld, info);
- if ( rtype != NULL )
- {
- undelete_reorgtype ( rtype, info);
- }
+ for (tree fld = TYPE_FIELDS (ri->gcc_type); fld; fld = DECL_CHAIN (fld))
+ {
+ ReorgType_t *rtype = find_struct_type_ptr_to_struct (fld, info);
+ if (rtype != NULL)
+ {
+ undelete_reorgtype (rtype, info);
+ }
+ }
}
- }
- remove_deleted_types ( info, &initial_reorg_debug);
+ remove_deleted_types (info, &initial_reorg_debug);
// Disqualifying structures in interior to structures is optional
- // (see comment at end of type escape section) but if it's not
+ // (see comment at end of type escape section) but if it's not
// done it commits the optimization to do something a little too
// involved for the initial version.
- disqualify_struct_in_struct_or_union ( info);
-
- if ( info->reorg_type->empty () )
- {
- if ( info->show_all_reorg_cands_in_detail )
+ disqualify_struct_in_struct_or_union (info);
+
+ if (info->reorg_type->empty ())
{
- fprintf ( dump_file, "find_decls_and_types: Found no types\n");
+ if (info->show_all_reorg_cands_in_detail)
+ {
+ fprintf (dump_file, "find_decls_and_types: Found no types\n");
+ }
+ return false;
}
- return false;
- }
// initialize ids of ReorgTypes
int id = 0;
- for ( std::vector<ReorgType_t>::iterator ri = info->reorg_type->begin ();
- ri != info->reorg_type->end ();
- ri++ )
- {
- ri->id = id;
- id++;
- }
+ for (std::vector<ReorgType_t>::iterator ri = info->reorg_type->begin ();
+ ri != info->reorg_type->end (); ri++)
+ {
+ ri->id = id;
+ id++;
+ }
// Scan all declarations. If their type is in ReorgTypes
// add them to ProgDecl.
// Note, there is no mechanism for looking at global declarations
// so use FOR_EACH_VARIABLE instead. I'm not 100% this is the thing
// actuall do here... but...
- FOR_EACH_VARIABLE ( var)
- {
- tree decl = var->decl;
- tree type = base_type_of ( decl);
- if ( TREE_CODE ( type ) == RECORD_TYPE &&
- get_reorgtype_info ( type, info) != NULL )
+ FOR_EACH_VARIABLE (var)
{
- ProgDecl_t decl_info;
- decl_info.gcc_decl = decl;
- info->prog_decl->push_back ( decl_info);
+ tree decl = var->decl;
+ tree type = base_type_of (decl);
+ if (TREE_CODE (type) == RECORD_TYPE
+ && get_reorgtype_info (type, info) != NULL)
+ {
+ ProgDecl_t decl_info;
+ decl_info.gcc_decl = decl;
+ info->prog_decl->push_back (decl_info);
+ }
}
- }
-
- FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
- {
- // local declarations
- unsigned i;
- tree decl;
- struct function *fn = DECL_STRUCT_FUNCTION ( node->decl);
- FOR_EACH_LOCAL_DECL ( fn, i, decl)
- {
- tree type = base_type_of ( decl);
- if ( TREE_CODE ( type ) == RECORD_TYPE &&
- get_reorgtype_info ( type, info) != NULL ) {
- ProgDecl_t decl_info;
- decl_info.gcc_decl = decl;
- info->prog_decl->push_back ( decl_info);
- }
- }
-
- // parameter declarations
- tree parm;
- for ( parm = DECL_ARGUMENTS ( fn->decl);
- parm;
- parm = DECL_CHAIN ( parm) )
- {
- tree decl = TREE_TYPE ( parm);
- tree type = base_type_of ( decl);
- if ( TREE_CODE ( type ) == RECORD_TYPE &&
- get_reorgtype_info ( type, info) != NULL )
- {
- ProgDecl_t decl_info;
- decl_info.gcc_decl = decl;
- info->prog_decl->push_back ( decl_info);
- }
+
+ FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
+ {
+ // local declarations
+ unsigned i;
+ tree decl;
+ struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
+ FOR_EACH_LOCAL_DECL (fn, i, decl)
+ {
+ tree type = base_type_of (decl);
+ if (TREE_CODE (type) == RECORD_TYPE
+ && get_reorgtype_info (type, info) != NULL)
+ {
+ ProgDecl_t decl_info;
+ decl_info.gcc_decl = decl;
+ info->prog_decl->push_back (decl_info);
+ }
+ }
+
+ // parameter declarations
+ tree parm;
+ for (parm = DECL_ARGUMENTS (fn->decl); parm; parm = DECL_CHAIN (parm))
+ {
+ tree decl = TREE_TYPE (parm);
+ tree type = base_type_of (decl);
+ if (TREE_CODE (type) == RECORD_TYPE
+ && get_reorgtype_info (type, info) != NULL)
+ {
+ ProgDecl_t decl_info;
+ decl_info.gcc_decl = decl;
+ info->prog_decl->push_back (decl_info);
+ }
+ }
+ }
+
+ if (info->show_all_reorg_cands_in_detail)
+ {
+ fprintf (dump_file, "find_decls_and_types: Found the following types:\n");
+ print_reorgs (dump_file, 2, info);
}
- }
- if ( info->show_all_reorg_cands_in_detail )
- {
- fprintf ( dump_file, "find_decls_and_types: Found the following types:\n");
- print_reorgs( dump_file, 2, info);
- }
-
return true;
}
void
-disqualify_struct_in_struct_or_union ( Info_t *info)
+disqualify_struct_in_struct_or_union (Info_t *info)
{
varpool_node *var;
std::set<tree> typeset;
- FOR_EACH_VARIABLE ( var)
- {
- tree decl = var->decl;
- tree base = base_type_of ( decl);
- if ( TREE_CODE ( base) == RECORD_TYPE
- || TREE_CODE ( base) == UNION_TYPE )
+ FOR_EACH_VARIABLE (var)
{
- disq_str_in_str_or_union_helper ( base, &typeset, info);
- typeset.insert ( base);
+ tree decl = var->decl;
+ tree base = base_type_of (decl);
+ if (TREE_CODE (base) == RECORD_TYPE || TREE_CODE (base) == UNION_TYPE)
+ {
+ disq_str_in_str_or_union_helper (base, &typeset, info);
+ typeset.insert (base);
+ }
}
- }
-
- remove_deleted_types ( info,
- &disqualify_struct_in_struct_or_union_debug);
+
+ remove_deleted_types (info, &disqualify_struct_in_struct_or_union_debug);
}
static void
-initial_reorg_debug ( Info *info, ReorgType *reorg )
+initial_reorg_debug (Info *info, ReorgType *reorg)
{
- if ( info->show_delete )
- {
- print_reorg_with_msg ( dump_file, reorg, 2,
- "No Pointer to Structure");
- }
+ if (info->show_delete)
+ {
+ print_reorg_with_msg (dump_file, reorg, 2, "No Pointer to Structure");
+ }
}
-
+
static void
-disqualify_struct_in_struct_or_union_debug ( Info *info,
- ReorgType *reorg )
+disqualify_struct_in_struct_or_union_debug (Info *info, ReorgType *reorg)
{
- if ( info->show_delete )
- {
- print_reorg_with_msg ( dump_file, reorg, 2,
- "Interior Struct or Union");
- }
+ if (info->show_delete)
+ {
+ print_reorg_with_msg (dump_file, reorg, 2, "Interior Struct or Union");
+ }
}
-
static void
-disq_str_in_str_or_union_helper ( tree type,
- std::set<tree> *typeset,
- Info_t *info )
+disq_str_in_str_or_union_helper (tree type, std::set<tree> *typeset,
+ Info_t *info)
{
- if ( typeset->find ( type) != typeset->end ()) return;
+ if (typeset->find (type) != typeset->end ())
+ return;
tree fld;
- for ( tree fld = TYPE_FIELDS( type); fld; fld = DECL_CHAIN ( fld) )
- {
- if ( TREE_CODE ( fld) == RECORD_TYPE )
- {
- ReorgType_t *rinfo = get_reorgtype_info ( fld, info);
- if ( rinfo != NULL )
- {
- delete_reorgtype ( rinfo, info);
- } else {
- disq_str_in_str_or_union_helper ( fld, typeset, info );
- typeset->insert ( fld); // might be bug here
- }
- } else {
- if ( TREE_CODE ( fld) == UNION_TYPE ) {
- disq_str_in_str_or_union_helper ( fld, typeset, info );
- typeset->insert ( fld); // might be bug here
- }
+ for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
+ {
+ if (TREE_CODE (fld) == RECORD_TYPE)
+ {
+ ReorgType_t *rinfo = get_reorgtype_info (fld, info);
+ if (rinfo != NULL)
+ {
+ delete_reorgtype (rinfo, info);
+ }
+ else
+ {
+ disq_str_in_str_or_union_helper (fld, typeset, info);
+ typeset->insert (fld); // might be bug here
+ }
+ }
+ else
+ {
+ if (TREE_CODE (fld) == UNION_TYPE)
+ {
+ disq_str_in_str_or_union_helper (fld, typeset, info);
+ typeset->insert (fld); // might be bug here
+ }
+ }
}
- }
return;
}
-
+
static unsigned int
-reorg_qualification ( Info_t *info)
+reorg_qualification (Info_t *info)
{
// TBD
// This only does a generic legality qualification and each
@@ -606,87 +607,87 @@ reorg_qualification ( Info_t *info)
}
void
-delete_reorgtype ( ReorgType_t *rt, Info_t *info )
+delete_reorgtype (ReorgType_t *rt, Info_t *info)
{
- if ( !rt->delete_me )
- {
- info->num_deleted++;
- rt->delete_me = true;
- }
+ if (!rt->delete_me)
+ {
+ info->num_deleted++;
+ rt->delete_me = true;
+ }
}
void
-undelete_reorgtype ( ReorgType_t *rt, Info_t *info )
+undelete_reorgtype (ReorgType_t *rt, Info_t *info)
{
- if ( rt->delete_me )
- {
- info->num_deleted--;
- rt->delete_me = false;
- }
+ if (rt->delete_me)
+ {
+ info->num_deleted--;
+ rt->delete_me = false;
+ }
}
void
-clear_deleted_types( Info *info)
+clear_deleted_types (Info *info)
{
info->saved_reorg_type->clear ();
}
void
-restore_deleted_types ( Info *info)
+restore_deleted_types (Info *info)
{
- while ( !info->saved_reorg_type->empty () )
- {
- info->reorg_type->push_back ( info->saved_reorg_type->back () );
- info->saved_reorg_type->pop_back ();
- }
+ while (!info->saved_reorg_type->empty ())
+ {
+ info->reorg_type->push_back (info->saved_reorg_type->back ());
+ info->saved_reorg_type->pop_back ();
+ }
}
-void
-remove_deleted_types ( Info *info, ReorgFn reorg_fn)
+void
+remove_deleted_types (Info *info, ReorgFn reorg_fn)
{
- if ( info->show_delete )
- {
- fprintf ( dump_file, "DELETING REORG TYPES:\n");
- }
-
- if ( info->num_deleted > 0 )
- {
- // Do delete here and run reorg_fn on each
- // deleted type
- int n = info->reorg_type->size ();
- int to = 0;
- for ( int from = 0; from < n; from++ )
- {
- if ( !(*(info->reorg_type))[from].delete_me )
- {
- // Save copy of removed entry
- (*(info->reorg_type))[from].delete_me = false;
- info->saved_reorg_type->push_back ( (*(info->reorg_type))[from]);
-
- // Delete by not copying deleted elements
- if ( from != to )
+ if (info->show_delete)
+ {
+ fprintf (dump_file, "DELETING REORG TYPES:\n");
+ }
+
+ if (info->num_deleted > 0)
+ {
+ // Do delete here and run reorg_fn on each
+ // deleted type
+ int n = info->reorg_type->size ();
+ int to = 0;
+ for (int from = 0; from < n; from++)
{
- if( reorg_fn != NULL )
- {
- (*reorg_fn)( info, &(*(info->reorg_type))[ from]);
- }
- (*(info->reorg_type))[ to] = (*(info->reorg_type))[ from];
+ if (!(*(info->reorg_type))[from].delete_me)
+ {
+ // Save copy of removed entry
+ (*(info->reorg_type))[from].delete_me = false;
+ info->saved_reorg_type->push_back ((*(info->reorg_type))[from]);
+
+ // Delete by not copying deleted elements
+ if (from != to)
+ {
+ if (reorg_fn != NULL)
+ {
+ (*reorg_fn) (info, &(*(info->reorg_type))[from]);
+ }
+ (*(info->reorg_type))[to] = (*(info->reorg_type))[from];
+ }
+ to++;
+ }
}
- to++;
- }
+ info->reorg_type->resize (n - info->num_deleted);
+ info->num_deleted = 0;
}
- info->reorg_type->resize ( n - info->num_deleted);
- info->num_deleted = 0;
- }
}
static tree
-base_type_of ( tree type)
+base_type_of (tree type)
{
- for ( ; POINTER_TYPE_P ( type) ||
- TREE_CODE ( type) == ARRAY_TYPE ||
- TREE_CODE ( type) == VAR_DECL
- ; type = TREE_TYPE ( type) );
+ for (; POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE
+ || TREE_CODE (type) == VAR_DECL;
+ type = TREE_TYPE (type))
+ ;
return type;
}
@@ -696,23 +697,26 @@ base_type_of ( tree type)
// Also, we do handle realloc but it doesn't
// create a new pool of memory so we ignore it here.
static bool
-is_reorg_alloc_trigger ( gimple *stmt)
+is_reorg_alloc_trigger (gimple *stmt)
{
- return gimple_call_builtin_p ( stmt, BUILT_IN_MALLOC)
- || gimple_call_builtin_p ( stmt, BUILT_IN_CALLOC);
+ return gimple_call_builtin_p (stmt, BUILT_IN_MALLOC)
+ || gimple_call_builtin_p (stmt, BUILT_IN_CALLOC);
}
-static ReorgType_t *
-find_struct_type_ptr_to_struct ( tree type, Info *info)
+static ReorgType_t *
+find_struct_type_ptr_to_struct (tree type, Info *info)
{
- if ( !POINTER_TYPE_P ( type) ) {
- return NULL;
- }
- for ( ; POINTER_TYPE_P ( type); type = TREE_TYPE ( type) );
-
- if ( TREE_CODE ( type) == RECORD_TYPE ) {
- return get_reorgtype_info ( type, info);
- }
+ if (!POINTER_TYPE_P (type))
+ {
+ return NULL;
+ }
+ for (; POINTER_TYPE_P (type); type = TREE_TYPE (type))
+ ;
+
+ if (TREE_CODE (type) == RECORD_TYPE)
+ {
+ return get_reorgtype_info (type, info);
+ }
return NULL;
}
@@ -720,164 +724,159 @@ find_struct_type_ptr_to_struct ( tree type, Info *info)
// What's dicey about this is it may sort of work but then I
// can see places where it wouldn't... The language has a say
// in what types are equal so maybe language hooks are involved???
-bool same_type_p( tree a, tree b )
+bool
+same_type_p (tree a, tree b)
{
- //DEBUG( "same_type_p:\n");
- //DEBUG( " a: TREE_CODE = %s, name = %p\n ",code_str(TREE_CODE(a)),TYPE_NAME(a));
- //DEBUG_F( print_generic_expr, stderr, a, (dump_flags_t)-1);
- //DEBUG( "\n b TREE_CODE = %s, name = %p\n ",code_str(TREE_CODE(b)),TYPE_NAME(b));
- //DEBUG_F( print_generic_expr, stderr, b, (dump_flags_t)-1);
- //DEBUG( "\n");
- gcc_assert ( TREE_CODE ( a ) == RECORD_TYPE && TYPE_NAME ( a) != 0);
- gcc_assert ( TREE_CODE ( b ) == RECORD_TYPE && TYPE_NAME ( b) != 0);
- return TYPE_NAME ( a) == TYPE_NAME ( b);
+ // DEBUG( "same_type_p:\n");
+ // DEBUG( " a: TREE_CODE = %s, name = %p\n
+ // ",code_str(TREE_CODE(a)),TYPE_NAME(a)); DEBUG_F( print_generic_expr, stderr,
+ // a, (dump_flags_t)-1); DEBUG( "\n b TREE_CODE = %s, name = %p\n
+ // ",code_str(TREE_CODE(b)),TYPE_NAME(b)); DEBUG_F( print_generic_expr, stderr,
+ // b, (dump_flags_t)-1); DEBUG( "\n");
+ gcc_assert (TREE_CODE (a) == RECORD_TYPE && TYPE_NAME (a) != 0);
+ gcc_assert (TREE_CODE (b) == RECORD_TYPE && TYPE_NAME (b) != 0);
+ return TYPE_NAME (a) == TYPE_NAME (b);
}
// May need to add secondary map container to
// look them up or even modify the container
// type of ReorgType
static ReorgType_t *
-get_reorgtype_info ( tree type, Info_t* info)
+get_reorgtype_info (tree type, Info_t *info)
{
// Note, I'm going to use the most stupid and slowest possible way
// to do this. The advanage is it will be super easy and almost
// certainly correct. It will also almost certainly need to be
// improved but I get something out there now.
- for ( std::vector<ReorgType_t>::iterator ri = info->reorg_type->begin ();
- ri != info->reorg_type->end ();
- ri++ )
- {
- // TBD the internal docs lie and same_type_p doesn't exist
- // (at least it's not available here at LTO time)
- // so this is just a place holder until I can get an answer
- // from the gcc community. Note, this is a big issue.
- // Remember, the same_type_p here is my own temporary hack.
- if ( same_type_p ( ri->gcc_type, type) )
+ for (std::vector<ReorgType_t>::iterator ri = info->reorg_type->begin ();
+ ri != info->reorg_type->end (); ri++)
{
- return &(*ri);
+ // TBD the internal docs lie and same_type_p doesn't exist
+ // (at least it's not available here at LTO time)
+ // so this is just a place holder until I can get an answer
+ // from the gcc community. Note, this is a big issue.
+ // Remember, the same_type_p here is my own temporary hack.
+ if (same_type_p (ri->gcc_type, type))
+ {
+ return &(*ri);
+ }
}
- }
return NULL;
}
static void
-print_reorg_with_msg ( FILE *file,
- ReorgType_t *reorg,
- int leading_space,
- const char *msg )
+print_reorg_with_msg (FILE *file, ReorgType_t *reorg, int leading_space,
+ const char *msg)
{
- fprintf ( file, "%*s%s:\n", leading_space, "", msg);
- print_reorg ( file, leading_space + 2, reorg);
+ fprintf (file, "%*s%s:\n", leading_space, "", msg);
+ print_reorg (file, leading_space + 2, reorg);
}
static void
-dump_reorg ( ReorgType_t *reorg)
+dump_reorg (ReorgType_t *reorg)
{
- print_reorg ( stderr, 0, reorg);
+ print_reorg (stderr, 0, reorg);
}
static void
-print_reorgs ( FILE *file, int leading_space, Info *info)
+print_reorgs (FILE *file, int leading_space, Info *info)
{
- for ( int i = 0; i < info->reorg_type->size (); i++ ) {
- print_reorg ( file, leading_space, &(*(info->reorg_type))[i]);
- }
+ for (int i = 0; i < info->reorg_type->size (); i++)
+ {
+ print_reorg (file, leading_space, &(*(info->reorg_type))[i]);
+ }
}
static void
-print_reorg ( FILE *file, int leading_space, ReorgType_t *reorg )
+print_reorg (FILE *file, int leading_space, ReorgType_t *reorg)
{
// TBD
// note if reorg_perf & regular_perf are nonzero
// synthesize and display absolute_effect & raw_effect
-
+
// Note, the following is a stub.
const char *text
- = identifier_to_locale ( IDENTIFIER_POINTER ( TYPE_NAME ( reorg->gcc_type)));
- fprintf ( file, "%*s{ type:%s, id:%d, ... }\n",
- leading_space, "",
- text,
- reorg->id);
+ = identifier_to_locale (IDENTIFIER_POINTER (TYPE_NAME (reorg->gcc_type)));
+ fprintf (file, "%*s{ type:%s, id:%d, ... }\n", leading_space, "", text,
+ reorg->id);
}
//-- debugging only --
static const char *
-code_str( enum tree_code tc)
+code_str (enum tree_code tc)
{
- switch ( tc )
- {
- case POINTER_TYPE:
- return "POINTER_TYPE";
- case RECORD_TYPE:
- return "RECORD_TYPE";
- case UNION_TYPE:
- return "UNION_TYPE";
- case ARRAY_TYPE:
- return "ARRAY_TYPE";
- case REFERENCE_TYPE:
- return "REFERENCE_TYPE";
- case VAR_DECL:
- return "VAR_DECL";
- case TYPE_DECL:
- return "TYPE_DECL";
- case CONST_DECL:
- return "CONST_DECL";
- default:
- switch( TREE_CODE_CLASS( tc) )
- {
- case tcc_type:
- return "class type";
- case tcc_declaration:
- return "class declaration";
- case tcc_reference:
- return "class reference";
+ switch (tc)
+ {
+ case POINTER_TYPE:
+ return "POINTER_TYPE";
+ case RECORD_TYPE:
+ return "RECORD_TYPE";
+ case UNION_TYPE:
+ return "UNION_TYPE";
+ case ARRAY_TYPE:
+ return "ARRAY_TYPE";
+ case REFERENCE_TYPE:
+ return "REFERENCE_TYPE";
+ case VAR_DECL:
+ return "VAR_DECL";
+ case TYPE_DECL:
+ return "TYPE_DECL";
+ case CONST_DECL:
+ return "CONST_DECL";
default:
- return "unknown class";
+ switch (TREE_CODE_CLASS (tc))
+ {
+ case tcc_type:
+ return "class type";
+ case tcc_declaration:
+ return "class declaration";
+ case tcc_reference:
+ return "class reference";
+ default:
+ return "unknown class";
+ }
}
- }
}
//---------------- Pass Control Follows ----------------
-const pass_data pass_data_ipa_structure_reorg =
-{
- SIMPLE_IPA_PASS, /* type */
+const pass_data pass_data_ipa_structure_reorg = {
+ SIMPLE_IPA_PASS, /* type */
"structure-reorg", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- //TV_IPA_SRA, /* tv_id */ // TBD
+ OPTGROUP_NONE, /* optinfo_flags */
+ // TV_IPA_SRA, /* tv_id */ // TBD
TV_IPA_STRUCTURE_REORG, /* tv_id */
- 0, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
+ 0, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
//( TODO_dump_symtab | TODO_remove_functions ), /* todo_flags_finish */ // ???
- (TODO_update_ssa | TODO_update_address_taken | TODO_cleanup_cfg | TODO_remove_unused_locals), /* todo_flags_finish */ // ???
+ (TODO_update_ssa | TODO_update_address_taken | TODO_cleanup_cfg
+ | TODO_remove_unused_locals),
+ /* todo_flags_finish */ // ???
};
class pass_ipa_structure_reorg : public simple_ipa_opt_pass
{
public:
- pass_ipa_structure_reorg ( gcc::context *ctxt)
- : simple_ipa_opt_pass ( pass_data_ipa_structure_reorg, ctxt)
+ pass_ipa_structure_reorg (gcc::context *ctxt)
+ : simple_ipa_opt_pass (pass_data_ipa_structure_reorg, ctxt)
{}
/* opt_pass methods: */
- virtual bool gate ( function *)
- {
- return ( ( flag_ipa_structure_reorg ||
- flag_ipa_instance_interleave ||
- flag_ipa_field_reorder ||
- flag_ipa_dead_field_eliminate )
- );
- }
+ virtual bool gate (function *)
+ {
+ return ((flag_ipa_structure_reorg || flag_ipa_instance_interleave
+ || flag_ipa_field_reorder || flag_ipa_dead_field_eliminate));
+ }
- virtual unsigned int execute ( function *) { return ipa_structure_reorg (); }
+ virtual unsigned int execute (function *) { return ipa_structure_reorg (); }
}; // class ipa_structure_reorg
-//ipa_opt_pass_d *
+// ipa_opt_pass_d *
simple_ipa_opt_pass *
-make_pass_ipa_structure_reorg ( gcc::context *ctxt)
+make_pass_ipa_structure_reorg (gcc::context *ctxt)
{
- return new pass_ipa_structure_reorg ( ctxt);
+ return new pass_ipa_structure_reorg (ctxt);
}
diff --git a/gcc/ipa-structure-reorg.h b/gcc/ipa-structure-reorg.h
index 3235385ea53..910f066b677 100644
--- a/gcc/ipa-structure-reorg.h
+++ b/gcc/ipa-structure-reorg.h
@@ -20,119 +20,134 @@ along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
typedef struct ReorgType ReorgType_t;
-struct ReorgType {
- unsigned id;
- tree gcc_type;
- int numbOfGlobalArrays; // Statically allocated only
- int numbOfLocalArrays; // Statically allocated only
- int numbOfDynmAllocs;
- double reorg_perf;
- double regular_perf;
- bool multi_pool; // single pool if not set
- bool delete_me;
- tree clone; // the base
- tree pointer_rep; // new pointer format (multi-pool)
+struct ReorgType
+{
+ unsigned id;
+ tree gcc_type;
+ int numbOfGlobalArrays; // Statically allocated only
+ int numbOfLocalArrays; // Statically allocated only
+ int numbOfDynmAllocs;
+ double reorg_perf;
+ double regular_perf;
+ bool multi_pool; // single pool if not set
+ bool delete_me;
+ tree clone; // the base
+ tree pointer_rep; // new pointer format (multi-pool)
};
typedef struct ProgDecl ProgDecl_t;
-struct ProgDecl {
- tree gcc_decl;
+struct ProgDecl
+{
+ tree gcc_decl;
};
-enum ReorgOpTrans {
- ReorgT_Address, // "&x[i]"
- ReorgT_Pointer, // "a"
- ReorgT_Struct, // "s"
- ReorgT_Deref, // "*a"
- ReorgT_Array, // "x[i]"
- ReorgT_Scalar, // "z"
- ReorgT_Indirect, // "a->f"
- ReorgT_AryDir // "x[i].f"
+enum ReorgOpTrans
+{
+ ReorgT_Address, // "&x[i]"
+ ReorgT_Pointer, // "a"
+ ReorgT_Struct, // "s"
+ ReorgT_Deref, // "*a"
+ ReorgT_Array, // "x[i]"
+ ReorgT_Scalar, // "z"
+ ReorgT_Indirect, // "a->f"
+ ReorgT_AryDir // "x[i].f"
};
-enum CompressionControl {
+enum CompressionControl
+{
Initial,
Subsequent
};
-enum ReorgTransformation {
- ReorgT_StrAssign, // "*a = x[i]", "x[i] = y[j]", "s = *a", etc.
- ReorgT_ElemAssign, // "a->f = z", "z = x[i].f", etc.
- ReorgT_If_Null, // "if(a == 0)..."
- ReorgT_If_NotNull, // "if(a != 0)..."
- ReorgT_IfPtrEQ, // "if(a == b)..."
- ReorgT_IfPtrNE, // "if(a != b)..."
- ReorgT_IfPtrLT, // "if(a < b)..."
- ReorgT_IfPtrGT, // "if(a > b)..."
- ReorgT_IfPtrLE, // "if(a <= b)..."
- ReorgT_IfPtrGE, // "if(a >= b)..."
- ReorgT_PtrPlusInt, // "a = b + i"
- ReorgT_Ptr2Zero, // "a = 0"
- ReorgT_PtrDiff, // "i = a - b"
- ReorgT_Adr2Ptr, // "a = &x[i]"
- ReorgT_PtrNull, // "x = a == 0"
- ReorgT_PtrNotNull, // "x = a != 0"
- ReorgT_PtrEQ, // "x = a == b"
- ReorgT_PtrNE, // "x = a != b"
- ReorgT_PtrLT, // "x = a < b"
- ReorgT_PtrLE, // "x = a <= b"
- ReorgT_PtrGT, // "x = a > b"
- ReorgT_PtrGE, // "x = a >= b"
- ReorgT_Malloc, //
- ReorgT_Calloc, //
- ReorgT_Realloc, //
- ReorgT_Free, //
+enum ReorgTransformation
+{
+ ReorgT_StrAssign, // "*a = x[i]", "x[i] = y[j]", "s = *a", etc.
+ ReorgT_ElemAssign, // "a->f = z", "z = x[i].f", etc.
+ ReorgT_If_Null, // "if(a == 0)..."
+ ReorgT_If_NotNull, // "if(a != 0)..."
+ ReorgT_IfPtrEQ, // "if(a == b)..."
+ ReorgT_IfPtrNE, // "if(a != b)..."
+ ReorgT_IfPtrLT, // "if(a < b)..."
+ ReorgT_IfPtrGT, // "if(a > b)..."
+ ReorgT_IfPtrLE, // "if(a <= b)..."
+ ReorgT_IfPtrGE, // "if(a >= b)..."
+ ReorgT_PtrPlusInt, // "a = b + i"
+ ReorgT_Ptr2Zero, // "a = 0"
+ ReorgT_PtrDiff, // "i = a - b"
+ ReorgT_Adr2Ptr, // "a = &x[i]"
+ ReorgT_PtrNull, // "x = a == 0"
+ ReorgT_PtrNotNull, // "x = a != 0"
+ ReorgT_PtrEQ, // "x = a == b"
+ ReorgT_PtrNE, // "x = a != b"
+ ReorgT_PtrLT, // "x = a < b"
+ ReorgT_PtrLE, // "x = a <= b"
+ ReorgT_PtrGT, // "x = a > b"
+ ReorgT_PtrGE, // "x = a >= b"
+ ReorgT_Malloc, //
+ ReorgT_Calloc, //
+ ReorgT_Realloc, //
+ ReorgT_Free, //
Not_Supported
};
// Added as design bug fix
typedef struct BoolPair BoolPair_t;
-struct BoolPair {
+struct BoolPair
+{
bool processed;
bool layout_changed;
};
typedef struct Info Info_t;
-struct Info {
- std::vector <ReorgType_t> *reorg_type;
+struct Info
+{
+ std::vector<ReorgType_t> *reorg_type;
// Added to by remove_deleted_types
- std::vector <ReorgType_t> *saved_reorg_type;
- std::vector <ProgDecl_t> *prog_decl;
+ std::vector<ReorgType_t> *saved_reorg_type;
+ std::vector<ProgDecl_t> *prog_decl;
// Gcc doesn't have global decls readily available
// so this holds them
- std::map <tree,BoolPair_t> *struct_types; // desing bug fix
- int num_deleted;
- double total_cache_accesses;
+ std::map<tree, BoolPair_t> *struct_types; // desing bug fix
+ int num_deleted;
+ double total_cache_accesses;
// Debug flags
- bool show_all_reorg_cands;
- bool show_all_reorg_cands_in_detail;
- bool show_delete;
- bool show_new_BBs;
- bool show_transforms;
- bool show_bounds;
+ bool show_all_reorg_cands;
+ bool show_all_reorg_cands_in_detail;
+ bool show_delete;
+ bool show_new_BBs;
+ bool show_transforms;
+ bool show_bounds;
};
// This will perform a function on the supplied
// reorg type. It's primarily to support debugging.
-typedef void (*ReorgFn)( Info *, ReorgType_t *);
-
-extern int str_reorg_dead_field_eliminate ( Info *);
-extern int str_reorg_field_reorder ( Info *);
-extern int str_reorg_instance_interleave ( Info *);
-
-extern void delete_reorgtype ( ReorgType_t *, Info_t *);
-extern void undelete_reorgtype ( ReorgType_t *, Info_t *);
-extern void clear_deleted_types( Info *);
-extern void restore_deleted_types ( Info *);
-extern void remove_deleted_types ( Info *, ReorgFn reorg_fn);
+typedef void (*ReorgFn) (Info *, ReorgType_t *);
+
+extern int
+str_reorg_dead_field_eliminate (Info *);
+extern int
+str_reorg_field_reorder (Info *);
+extern int
+str_reorg_instance_interleave (Info *);
+
+extern void
+delete_reorgtype (ReorgType_t *, Info_t *);
+extern void
+undelete_reorgtype (ReorgType_t *, Info_t *);
+extern void
+clear_deleted_types (Info *);
+extern void
+restore_deleted_types (Info *);
+extern void
+remove_deleted_types (Info *, ReorgFn reorg_fn);
// I have no intention of leaving this or uses of the
// defined marcos in the code. However, some of uses
// should obviously be converted to dump file information.
#if 1
-#define DEBUG(...) fprintf( stderr, __VA_ARGS__)
-#define DEBUG_F(f,...) f( __VA_ARGS__)
+#define DEBUG(...) fprintf (stderr, __VA_ARGS__)
+#define DEBUG_F(f, ...) f (__VA_ARGS__)
#else
#define DEBUG(...)
#define DEBUG_F(...)
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 990dfcd7200..6dd64e2e455 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -237,8 +237,7 @@ enum lto_section_type
LTO_section_ipa_hsa,
LTO_section_lto,
LTO_section_ipa_sra,
- LTO_section_hello_world,
- LTO_N_SECTION_TYPES /* Must be last. */
+ LTO_N_SECTION_TYPES /* Must be last. */
};
/* Indices to the various function, type and symbol streams. */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c
index 483ee74fe2d..90e10864fe9 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-0-runs-0.c
@@ -1,11 +1,13 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
// Dummy test to find out if
// our optimization is registered
int
-main()
+main ()
{
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c
index 8db8e02796f..7e680d7d0ca 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-1-prints-structs-0.c
@@ -1,11 +1,17 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c
index bb9d616452b..d3014f00b6c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-10-array-0.c
@@ -1,12 +1,18 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s a;
struct astruct_s b[2];
a = b[0];
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c
index d5f8a1e41a6..a551cf10e1c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-11-rewrites-minus-expr-0.c
@@ -1,18 +1,24 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
_Bool *c_ptr = &(astruct.c);
_Bool *a_ptr = &(astruct.a);
ptrdiff_t diff = c_ptr - a_ptr;
- assert(diff == 1);
+ assert (diff == 1);
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c
index 5ee920c62b9..edbfbe16a3c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-12-delete-last-field-0.c
@@ -1,19 +1,25 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool c; _Bool b;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool c;
+ _Bool b;
+ };
struct astruct_s b[2];
_Bool *first_of_second = &(b[1].a);
_Bool *c_0 = &(b[0].c);
_Bool *a_1 = &(b[1].a);
- _Bool *a_1_from_c_0 = c_0+1;
+ _Bool *a_1_from_c_0 = c_0 + 1;
_Bool test = a_1_from_c_0 == a_1;
- char compile_test[test ? 1 : - 1];
- assert(test);
+ char compile_test[test ? 1 : -1];
+ assert (test);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c
index c439d1139de..b00787f98d8 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-13-modify-size-four-0.c
@@ -1,20 +1,27 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
struct astruct_s astruct;
_Bool *a = &(astruct.a);
_Bool *c = &(astruct.c);
_Bool *d = &(astruct.d);
ptrdiff_t diff_1 = c - a;
ptrdiff_t diff_2 = d - a;
- assert(diff_1 == 1);
- assert(diff_2 == 2);
+ assert (diff_1 == 1);
+ assert (diff_2 == 2);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c
index 70d870354d6..cfa8b4243fe 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-14-rewrite-plus-expr-0.c
@@ -1,20 +1,24 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
int d = astruct.c + 1;
- _Bool* a = &(astruct.a);
- _Bool* c = a + 1;
- assert(*c == 1);
+ _Bool *a = &(astruct.a);
+ _Bool *c = a + 1;
+ assert (*c == 1);
return 0;
}
-
-
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c
index d28d6d88173..5a4bd06974b 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-15-rewrite-mult-expr-0.c
@@ -1,20 +1,24 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <stddef.h>
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
int d = astruct.c * 2;
_Bool *a = &(astruct.a);
_Bool *c = a + 1;
- assert(*c == 0);
+ assert (*c == 0);
return 0;
}
-
-
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c
index 6c63d84e9db..3178e2577e1 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-16-rewrite-field-reads-ptr-0.c
@@ -1,22 +1,26 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
astruct.c = 1;
struct astruct_s *astruct_p = &astruct;
_Bool c = astruct_p->c;
_Bool *a = &(astruct.a);
_Bool *c_ptr = a + 1;
- assert(*c_ptr == c);
+ assert (*c_ptr == c);
return 0;
}
-
-
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c
index b3d48423b6c..089e112b16a 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-17-rewrite-field-write-ptr-0.c
@@ -1,20 +1,24 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
struct astruct_s *astruct_p = &astruct;
astruct_p->c = 1;
_Bool *a = &(astruct.a);
_Bool *c = a + 1;
- assert(*c == 1);
+ assert (*c == 1);
return 0;
}
-
-
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c
index e1162688421..81a55e4c2c8 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-18-field-writes-deref-0.c
@@ -1,10 +1,19 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool e; _Bool a; _Bool b; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool e;
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
struct astruct_s astruct;
_Bool *c_ptr = &astruct.c;
c_ptr--;
@@ -13,4 +22,3 @@ main()
e_ptr++;
return *e_ptr - 1;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c
index 1c966e06110..ff7f6acd2f3 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-19-middle-pointer-equal-0.c
@@ -1,19 +1,26 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
struct astruct_s astruct;
_Bool *a = &astruct.a;
_Bool *d = &astruct.d;
- _Bool *c_from_a = a+1;
- _Bool *c_from_d = d-1;
+ _Bool *c_from_a = a + 1;
+ _Bool *c_from_d = d - 1;
_Bool test = c_from_a == c_from_d;
char compile_test[test ? 1 : -1];
- assert(test);
+ assert (test);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c
index 424c4930735..29a2121430c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-2-modifies-0.c
@@ -1,10 +1,17 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c
index 38f6a4151a1..c978aa64393 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-20-array-offset-0.c
@@ -1,18 +1,25 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s b[2];
_Bool *first_of_second = &(b[1].a);
_Bool *a_ptr = &(b[0].a);
_Bool *c_from_a = ++a_ptr;
_Bool *c_from_array = --first_of_second;
_Bool test = c_from_a == c_from_array;
- assert(test);
- char compile_test[test ? 1 : - 1];
+ assert (test);
+ char compile_test[test ? 1 : -1];
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c
index f91f6d2baac..361209a542e 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-21-rewrites-clobber-type-0.c
@@ -1,10 +1,17 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c
index 2d2a9f8e447..effc200119c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-22-rewrites-addr-expr-read-0.c
@@ -1,17 +1,23 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
_Bool *a = &astruct.a;
_Bool *c = &astruct.c;
_Bool *c_1 = a + 1;
- assert(c_1 == c);
+ assert (c_1 == c);
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c
index 53890e3aed9..ccd73a9eacd 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-23-array-cast-0.c
@@ -1,19 +1,30 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main()
+main ()
{
-struct astruct_s { _Bool a; _Bool b; _Bool c; };
-struct astruct_s a[2];
-struct bstruct_s { _Bool a; _Bool c;};
-struct astruct_s *a_0 = &(a[0]);
-struct astruct_s *a_1 = a_0+1;
-struct bstruct_s *b_0 = (struct bstruct_s*) a_0;
-struct bstruct_s *b_1 = b_0+1;
-assert((struct bstruct_s*)a_1 == b_1);
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
+ struct astruct_s a[2];
+ struct bstruct_s
+ {
+ _Bool a;
+ _Bool c;
+ };
+ struct astruct_s *a_0 = &(a[0]);
+ struct astruct_s *a_1 = a_0 + 1;
+ struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
+ struct bstruct_s *b_1 = b_0 + 1;
+ assert ((struct bstruct_s *) a_1 == b_1);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c
index 7894dc42058..e4bd730ac48 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-24-array-cast-0.c
@@ -1,21 +1,33 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s a[2];
- struct bstruct_s { _Bool a; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s a[2];
+ struct bstruct_s
+ {
+ _Bool a;
+ _Bool c;
+ _Bool d;
+ };
- struct astruct_s *a_0 = &(a[0]);
- struct astruct_s *a_1 = a_0 + 1;
- struct bstruct_s *b_0 = (struct bstruct_s*) a_0;
- struct bstruct_s *b_1 = b_0 + 1;
- assert((struct bstruct_s*)a_1 == b_1);
+ struct astruct_s *a_0 = &(a[0]);
+ struct astruct_s *a_1 = a_0 + 1;
+ struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
+ struct bstruct_s *b_1 = b_0 + 1;
+ assert ((struct bstruct_s *) a_1 == b_1);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c
index 9f65bfc73ca..b2b2375a29b 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-25-array-cast-0.c
@@ -1,21 +1,33 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s a[2];
- struct bstruct_s { _Bool a; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s a[2];
+ struct bstruct_s
+ {
+ _Bool a;
+ _Bool c;
+ _Bool d;
+ };
- struct astruct_s *a_0 = &(a[1]);
- struct astruct_s *a_1 = a_0 - 1;
- struct bstruct_s *b_0 = (struct bstruct_s*) a_0;
- struct bstruct_s *b_1 = b_0 - 1;
- assert((struct bstruct_s*)a_1 == b_1);
+ struct astruct_s *a_0 = &(a[1]);
+ struct astruct_s *a_1 = a_0 - 1;
+ struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
+ struct bstruct_s *b_1 = b_0 - 1;
+ assert ((struct bstruct_s *) a_1 == b_1);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c
index 8d72290b581..47159228840 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-26-array-cast-0.c
@@ -1,21 +1,33 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s a[2];
- struct bstruct_s { _Bool a; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s a[2];
+ struct bstruct_s
+ {
+ _Bool a;
+ _Bool c;
+ _Bool d;
+ };
- struct astruct_s *a_0 = &(a[0]);
- struct astruct_s *a_1 = a_0 + argc;
- struct bstruct_s *b_0 = (struct bstruct_s*) a_0;
- struct bstruct_s *b_1 = b_0 + argc;
- assert((struct bstruct_s*)a_1 == b_1);
+ struct astruct_s *a_0 = &(a[0]);
+ struct astruct_s *a_1 = a_0 + argc;
+ struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
+ struct bstruct_s *b_1 = b_0 + argc;
+ assert ((struct bstruct_s *) a_1 == b_1);
}
-
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 0831cc2e2d5..fb8a7fb20cb 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,15 +1,22 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s a[2][2];
- struct astruct_s b = a[argc][argc];
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s a[2][2];
+ struct astruct_s b = a[argc][argc];
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c
index 6fe38dd52dc..2753587528a 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-28-array-cast-0.c
@@ -1,21 +1,33 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s a[3];
- struct bstruct_s { _Bool a; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s a[3];
+ struct bstruct_s
+ {
+ _Bool a;
+ _Bool c;
+ _Bool d;
+ };
- struct astruct_s *a_0 = &(a[0]);
- struct astruct_s *a_1 = a_0 + 2;
- struct bstruct_s *b_0 = (struct bstruct_s*) a_0;
- struct bstruct_s *b_1 = b_0 + 2;
- assert((struct bstruct_s*)a_1 == b_1);
+ struct astruct_s *a_0 = &(a[0]);
+ struct astruct_s *a_1 = a_0 + 2;
+ struct bstruct_s *b_0 = (struct bstruct_s *) a_0;
+ struct bstruct_s *b_1 = b_0 + 2;
+ assert ((struct bstruct_s *) a_1 == b_1);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c
index 44c8db7b7fa..a905d788285 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-29-heterogeneous-struct.c
@@ -1,18 +1,24 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main()
+main ()
{
- struct astruct_s { int a; _Bool b; int c;};
- struct astruct_s astruct;
- int *a = &(astruct.a);
- int *c = &(astruct.c);
- ptrdiff_t d = c - a;
- assert(d == 1);
+ struct astruct_s
+ {
+ int a;
+ _Bool b;
+ int c;
+ };
+ struct astruct_s astruct;
+ int *a = &(astruct.a);
+ int *c = &(astruct.c);
+ ptrdiff_t d = c - a;
+ assert (d == 1);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c
index 8db8e02796f..7e680d7d0ca 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-3-new-offsets-0.c
@@ -1,11 +1,17 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c
index 16d77c3ff4c..13ae7c4f259 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-30-heterogenous-struct-0.c
@@ -1,19 +1,28 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main()
+main ()
{
- // unmodified { a = 1, b = 4; c = 5; d = 8; e = 12
- // modified { a = 1, c = 2; d = 4, e = 8
-struct astruct_s { _Bool a; int b; _Bool c; int d; _Bool e;};
-struct astruct_s astruct;
-_Bool *a = &(astruct.a);
-_Bool *e = &(astruct.e);
-ptrdiff_t diff = e - a;
-assert(diff == 8);
+ // unmodified { a = 1, b = 4; c = 5; d = 8; e = 12
+ // modified { a = 1, c = 2; d = 4, e = 8
+ struct astruct_s
+ {
+ _Bool a;
+ int b;
+ _Bool c;
+ int d;
+ _Bool e;
+ };
+ struct astruct_s astruct;
+ _Bool *a = &(astruct.a);
+ _Bool *e = &(astruct.e);
+ ptrdiff_t diff = e - a;
+ assert (diff == 8);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c
index efc05156928..ad67cb3c55d 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-31-heterogenous-struct-0.c
@@ -1,20 +1,30 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main()
+main ()
{
-// unmodified a = 0, d = 1; e = 2; f = 3; b = 4; c = 8
-// modified a = 0, d = 1, e = 2, f = 3, c = 4;
-struct astruct_s { _Bool a; _Bool d; _Bool e; _Bool f; _Bool b; int c;};
-struct astruct_s astruct;
-struct astruct_s *p = &astruct;
-_Bool *a = &(p->a);
-_Bool *c = (_Bool*)&(p->c);
-ptrdiff_t d = c - a;
-assert(d == 4);
+ // unmodified a = 0, d = 1; e = 2; f = 3; b = 4; c = 8
+ // modified a = 0, d = 1, e = 2, f = 3, c = 4;
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool d;
+ _Bool e;
+ _Bool f;
+ _Bool b;
+ int c;
+ };
+ struct astruct_s astruct;
+ struct astruct_s *p = &astruct;
+ _Bool *a = &(p->a);
+ _Bool *c = (_Bool *) &(p->c);
+ ptrdiff_t d = c - a;
+ assert (d == 4);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c
index 7970af00313..03a5e18aed6 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-32-pointer-indirection-level-0.c
@@ -1,19 +1,25 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
- struct astruct_s astruct;
- struct astruct_s *p0 = &astruct;
- struct astruct_s **p1 = &p0;
- _Bool *a_ptr_0 = (_Bool *)p0;
- _Bool *c_ptr_0 = a_ptr_0 + 1;
- _Bool **a_ptr_1 = (_Bool **)p1;
- _Bool *c_ptr_1 = (_Bool*)((*a_ptr_1) + 1);
- assert(c_ptr_0 == c_ptr_1);
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
+ struct astruct_s astruct;
+ struct astruct_s *p0 = &astruct;
+ struct astruct_s **p1 = &p0;
+ _Bool *a_ptr_0 = (_Bool *) p0;
+ _Bool *c_ptr_0 = a_ptr_0 + 1;
+ _Bool **a_ptr_1 = (_Bool **) p1;
+ _Bool *c_ptr_1 = (_Bool *) ((*a_ptr_1) + 1);
+ assert (c_ptr_0 == c_ptr_1);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c
index 878da231920..ceb03ac00e4 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-nested-struct-0.c
@@ -1,28 +1,40 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d; };
- struct outerstruct_s { struct astruct_s a; struct astruct_s b; struct astruct_s c; struct astruct_s d;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct outerstruct_s
+ {
+ struct astruct_s a;
+ struct astruct_s b;
+ struct astruct_s c;
+ struct astruct_s d;
+ };
struct outerstruct_s outerstruct;
- _Bool *outer_a = (_Bool*) &outerstruct.a;
- _Bool *outer_b = (_Bool*) &outerstruct.b;
- _Bool *outer_c = (_Bool*) &outerstruct.c;
- _Bool *outer_d = (_Bool*) &outerstruct.d;
+ _Bool *outer_a = (_Bool *) &outerstruct.a;
+ _Bool *outer_b = (_Bool *) &outerstruct.b;
+ _Bool *outer_c = (_Bool *) &outerstruct.c;
+ _Bool *outer_d = (_Bool *) &outerstruct.d;
_Bool *outer_b_1 = outer_a + 3;
_Bool *outer_c_1 = outer_a + 6;
_Bool *outer_d_1 = outer_a + 9;
- assert(outer_b == outer_b_1);
- assert(outer_c == outer_c_1);
- assert(outer_d == outer_d_1);
+ assert (outer_b == outer_b_1);
+ assert (outer_c == outer_c_1);
+ assert (outer_d == outer_d_1);
}
-
-
/* " offset,astruct_s.reorg,a,0" "typelist" } } */
/* " offset,astruct_s.reorg,c,1" "typelist" } } */
/* " offset,astruct_s.reorg,d,2" "typelist" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c
index 30b3fc2d8a6..44d0862e760 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-33-pointer-indirection-level-0.c
@@ -1,18 +1,26 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s astruct;
- struct astruct_s *p0 = &astruct;
- struct astruct_s **p1 = &p0;
- _Bool *a_ptr = &(astruct.a);
- _Bool *c_ptr = a_ptr + 1;
- _Bool *a_ptr_2 = &((*p1)->a);
- _Bool *c_ptr_2 = a_ptr_2 + 1;
- assert(c_ptr == c_ptr_2);
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s astruct;
+ struct astruct_s *p0 = &astruct;
+ struct astruct_s **p1 = &p0;
+ _Bool *a_ptr = &(astruct.a);
+ _Bool *c_ptr = a_ptr + 1;
+ _Bool *a_ptr_2 = &((*p1)->a);
+ _Bool *c_ptr_2 = a_ptr_2 + 1;
+ assert (c_ptr == c_ptr_2);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c
index 0b8f8e87e37..ee37f74c24c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-34-array-cast-0.c
@@ -1,16 +1,23 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s a[2][2];
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s a[2][2];
- struct astruct_s b = a[argc][argc];
+ struct astruct_s b = a[argc][argc];
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c
index 0dd77bd3987..195e20d320b 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-35-array-cast-0.c
@@ -1,27 +1,40 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
- struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
- struct astruct_s a[2][2];
- struct bstruct_s { _Bool a; _Bool c; _Bool d;};
- struct bstruct_s *b_ptr = (struct bstruct_s*) &a;
- // a[0][0] = b_ptr + 0 + 0;
- // a[0][1] = b_ptr + 0 + sizeof(astruct_s)
- // a[1][0] = b_ptr + 2*sizeof(astruct_s) + 0;
- // a[1][1] = b_ptr + 2*sizeof(astruct_s) + sizeof(astruct_s);
- // as a function of argc
- // a[argc][argc] = b_ptr + 2*sizeof(astruct_s)* argc + sizeof(astruct_s)*argc
- // TODO: Can't put size of astruct_s because
- // we don't change sizeof yet...
- int size = sizeof(struct bstruct_s);
- struct bstruct_s *b_ptr_2 = b_ptr + 2*argc + argc;
- struct bstruct_s *b = (struct bstruct_s*)&(a[argc][argc]);
- assert(b_ptr_2 == b);
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s a[2][2];
+ struct bstruct_s
+ {
+ _Bool a;
+ _Bool c;
+ _Bool d;
+ };
+ struct bstruct_s *b_ptr = (struct bstruct_s *) &a;
+ // a[0][0] = b_ptr + 0 + 0;
+ // a[0][1] = b_ptr + 0 + sizeof(astruct_s)
+ // a[1][0] = b_ptr + 2*sizeof(astruct_s) + 0;
+ // a[1][1] = b_ptr + 2*sizeof(astruct_s) + sizeof(astruct_s);
+ // as a function of argc
+ // a[argc][argc] = b_ptr + 2*sizeof(astruct_s)* argc + sizeof(astruct_s)*argc
+ // TODO: Can't put size of astruct_s because
+ // we don't change sizeof yet...
+ int size = sizeof (struct bstruct_s);
+ struct bstruct_s *b_ptr_2 = b_ptr + 2 * argc + argc;
+ struct bstruct_s *b = (struct bstruct_s *) &(a[argc][argc]);
+ assert (b_ptr_2 == b);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c
index a5a5efc9bf3..d3c39b9fdd5 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-36-arguments-0.c
@@ -1,32 +1,39 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
+struct astruct_s
+{
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+};
-struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
-
-//PASS BY VALUE
+// PASS BY VALUE
_Bool
-foo(struct astruct_s astruct)
+foo (struct astruct_s astruct)
{
- _Bool *a = &astruct.a;
- assert(!*a);
- _Bool *c = a + 1;
- assert(*c);
- _Bool *d = a + 2;
- assert(*d);
- return *c;
+ _Bool *a = &astruct.a;
+ assert (!*a);
+ _Bool *c = a + 1;
+ assert (*c);
+ _Bool *d = a + 2;
+ assert (*d);
+ return *c;
}
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
- struct astruct_s astruct;
- astruct.a = 0;
- astruct.c = argc;
- astruct.d = 1;
- foo(astruct);
+ struct astruct_s astruct;
+ astruct.a = 0;
+ astruct.c = argc;
+ astruct.d = 1;
+ foo (astruct);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c
index ff053d48810..f830e0e283c 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-37-arguments-0.c
@@ -1,33 +1,39 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
+struct astruct_s
+{
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+};
-struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
-
-//PASS BY REFERENCE
+// PASS BY REFERENCE
_Bool
-foo(struct astruct_s *astruct)
+foo (struct astruct_s *astruct)
{
- _Bool *a = (_Bool*) &(astruct->a);
- assert(!*a);
- _Bool *c = a + 1;
- assert(*c);
- _Bool *d = a + 2;
- assert(*d);
- return *c;
+ _Bool *a = (_Bool *) &(astruct->a);
+ assert (!*a);
+ _Bool *c = a + 1;
+ assert (*c);
+ _Bool *d = a + 2;
+ assert (*d);
+ return *c;
}
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
- struct astruct_s astruct;
- astruct.a = 0;
- astruct.c = argc;
- astruct.d = 1;
- foo(&astruct);
-
+ struct astruct_s astruct;
+ astruct.a = 0;
+ astruct.c = argc;
+ astruct.d = 1;
+ foo (&astruct);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c
index 3e46e3304aa..e89a36c86fd 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-38-return-values-0.c
@@ -1,33 +1,40 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
+struct astruct_s
+{
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+};
-struct astruct_s { _Bool a; _Bool b; _Bool c; _Bool d;};
-
-//RETURN BY VALUE
+// RETURN BY VALUE
struct astruct_s
-foo(_Bool c)
+foo (_Bool c)
{
- struct astruct_s astruct;
- astruct.a = 0;
- astruct.c = c;
- astruct.d = 1;
- return astruct;
+ struct astruct_s astruct;
+ astruct.a = 0;
+ astruct.c = c;
+ astruct.d = 1;
+ return astruct;
}
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
- struct astruct_s astruct;
- astruct = foo(argc);
- _Bool *a = &(astruct.a);
- assert(!*a);
- _Bool *c = a + 1;
- assert(*c == argc);
- _Bool *d = a + 2;
- assert(*d);
+ struct astruct_s astruct;
+ astruct = foo (argc);
+ _Bool *a = &(astruct.a);
+ assert (!*a);
+ _Bool *c = a + 1;
+ assert (*c == argc);
+ _Bool *d = a + 2;
+ assert (*d);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c
index 8d61a51d87d..54daf6e2f9d 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-39-typedef-0.c
@@ -1,11 +1,17 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- typedef struct astruct_s { _Bool a; _Bool b; _Bool c;} astruct_s;
+ typedef struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ } astruct_s;
astruct_s astruct;
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c
index 7287e7f184f..47123e967a9 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-4-layout-compile-0.c
@@ -1,17 +1,24 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <stddef.h>
int
-main(int argc, char**argv)
+main (int argc, char **argv)
{
- struct astruct_s { int a; int b; int c;};
+ struct astruct_s
+ {
+ int a;
+ int b;
+ int c;
+ };
struct astruct_s astruct;
int *c = &astruct.c;
int *a = &astruct.a;
ptrdiff_t d = c - a;
- char ch[d == 1 ? 1 : - 1];
+ char ch[d == 1 ? 1 : -1];
}
/* "Executing structreorg" "typelist" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c
index 6cf391877d4..43e829d5d5d 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-40-typedef-0.c
@@ -1,12 +1,18 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
typedef struct astruct_s astruct_s;
astruct_s astruct;
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c
index ca4a2e8e377..5efbb63e2ee 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-41-deref-0.c
@@ -1,14 +1,20 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
struct astruct_s *t, copy;
t = &astruct;
copy = *t;
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c
index 5451cc76b5e..6b4a1af28b8 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-42-mem-ref-0.c
@@ -1,30 +1,31 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout
+ * -fipa-typelist-struct=arc" } */
#include <stdlib.h>
typedef struct arc arc_t;
typedef struct arc *arc_p;
-struct arc {
+struct arc
+{
int id;
long cost;
- void * tail, * head;
+ void *tail, *head;
short ident;
arc_p nextout, nextin;
long flow;
long org_cost;
};
-
-
int
-main()
+main ()
{
int num_threads = 10;
arc_p *deleted_arcs;
register arc_t *arcnew;
- deleted_arcs = (arc_p*) malloc(num_threads * sizeof(arc_p));
+ deleted_arcs = (arc_p *) malloc (num_threads * sizeof (arc_p));
deleted_arcs[num_threads][num_threads] = arcnew[0];
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c
index 64cb786adc7..54784d1daea 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-43-args-0.c
@@ -1,18 +1,32 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout
+ * -fipa-typelist-struct=arc" } */
#include <stdlib.h>
-struct astruct_s { _Bool a; _Bool b; _Bool c;};
-struct wrapper_s { struct astruct_s* a; };
+struct astruct_s
+{
+ _Bool a;
+ _Bool b;
+ _Bool c;
+};
+struct wrapper_s
+{
+ struct astruct_s *a;
+};
-void foo(struct wrapper_s* wrapper) { };
-void bar(struct wrapper_s* wrapper) { foo(wrapper); };
+void
+foo (struct wrapper_s *wrapper){};
+void
+bar (struct wrapper_s *wrapper)
+{
+ foo (wrapper);
+};
int
-main() {
-struct wrapper_s a_wrapper;
-bar(&a_wrapper);
+main ()
+{
+ struct wrapper_s a_wrapper;
+ bar (&a_wrapper);
}
-
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c
index 97bfaae2b8e..5db45e9b69b 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-44-cond-0.c
@@ -1,11 +1,16 @@
/* { dg-do link } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout
+ * -fipa-typelist-struct=arc" } */
-
-struct a {
+struct a
+{
struct arc *b;
-} c(struct a *d) {
+} c (struct a *d)
+{
while (d)
;
}
-void main() {}
+void
+main ()
+{}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c
index d119c462697..c1a4c11c489 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-45-phis-0.c
@@ -1,11 +1,16 @@
/* { dg-do link } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc" } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout
+ * -fipa-typelist-struct=arc" } */
-struct a {
+struct a
+{
struct arc *b;
-} c(struct a *d, struct a *e) {
+} c (struct a *d, struct a *e)
+{
while (e)
d = d;
}
-int main() {}
-
+int
+main ()
+{}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c
index 4c13adadd24..e1a5af1f0b5 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-46-static-0.c
@@ -1,20 +1,25 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc -o ipa-structreorg-46-static-0.exe " } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout
+ * -fipa-typelist-struct=arc -o ipa-structreorg-46-static-0.exe " } */
#include <assert.h>
#include <stddef.h>
-struct arc { _Bool a; _Bool nextout; _Bool c;};
+struct arc
+{
+ _Bool a;
+ _Bool nextout;
+ _Bool c;
+};
struct arc an_arc;
-int main() {
-
- _Bool *a = &(an_arc.a);
- _Bool *c = &(an_arc.c);
- ptrdiff_t diff = c - a;
- assert(diff == 1);
-
-
+int
+main ()
+{
+ _Bool *a = &(an_arc.a);
+ _Bool *c = &(an_arc.c);
+ ptrdiff_t diff = c - a;
+ assert (diff == 1);
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c
index b029dbd6c8a..4731962e302 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-47-constructor-0.c
@@ -1,15 +1,26 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc -o ipa-structreorg-46-static-0.exe " } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout
+ * -fipa-typelist-struct=arc -o ipa-structreorg-46-static-0.exe " } */
#include <assert.h>
#include <stddef.h>
-
-
-int main() {
- struct arc { _Bool a; _Bool nextout; _Bool c;};
- struct arc an_arc;
- struct another { _Bool a; struct arc d; _Bool c;};
- struct another an_another = { 0, { 0, 1}, 1};
+int
+main ()
+{
+ struct arc
+ {
+ _Bool a;
+ _Bool nextout;
+ _Bool c;
+ };
+ struct arc an_arc;
+ struct another
+ {
+ _Bool a;
+ struct arc d;
+ _Bool c;
+ };
+ struct another an_another = {0, {0, 1}, 1};
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c
index 063d8f76a32..b943b17048e 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-48-function-ptr-0.c
@@ -1,31 +1,40 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout -fipa-typelist-struct=arc " } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout
+ * -fipa-typelist-struct=arc " } */
#include <assert.h>
#include <stddef.h>
-struct arc { _Bool a; _Bool nextout; _Bool c;};
+struct arc
+{
+ _Bool a;
+ _Bool nextout;
+ _Bool c;
+};
-_Bool returnLast(struct arc anArc)
+_Bool
+returnLast (struct arc anArc)
{
- return anArc.c;
+ return anArc.c;
}
-_Bool returnLast2(struct arc anArc)
+_Bool
+returnLast2 (struct arc anArc)
{
- _Bool *ptr = &(anArc.a);
- ptr = ptr + 1;
- return *ptr;
+ _Bool *ptr = &(anArc.a);
+ ptr = ptr + 1;
+ return *ptr;
}
-
int
-main(int argc, char** argv) {
-_Bool(*func1)(struct arc);
-func1 = &returnLast;
-_Bool (*func2)(struct arc);
-func2 = &returnLast2;
-struct arc anArc;
-anArc.c = argc;
-assert(func1(anArc) == func2(anArc));
+main (int argc, char **argv)
+{
+ _Bool (*func1) (struct arc);
+ func1 = &returnLast;
+ _Bool (*func2) (struct arc);
+ func2 = &returnLast2;
+ struct arc anArc;
+ anArc.c = argc;
+ assert (func1 (anArc) == func2 (anArc));
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c
index 0701b8222d2..1cf22279a31 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-49-array-0.c
@@ -1,25 +1,50 @@
/* { dg-do run } */
-/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate -fdump-ipa-structure-reorg -fipa-typelist-field=nextout,nextin -fipa-typelist-struct=astruct_s " } */
+/* { dg-options "-flto -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=nextout,nextin
+ * -fipa-typelist-struct=astruct_s " } */
#include <assert.h>
#include <stddef.h>
int
-main(int argc, char** argv)
+main (int argc, char **argv)
{
-struct astruct_s { int id; long cost; void* tail; void *head; void* nextin; void* nextout; short ident; long flow; long org_cost;};
-struct cstruct_s { int id; long cost; void* tail; void *head; short ident; long flow; long org_cost;};
-struct bstruct_s { struct astruct_s *basic_arc;};
-long num = argc;
-struct astruct_s array[100];
-struct astruct_s *old_arcs = array;
-struct bstruct_s b;
-struct bstruct_s *c = &b;
-c->basic_arc = array + num;
-c->basic_arc->cost = num;
-struct cstruct_s *other = ((struct cstruct_s*)(array)) + num;
-size_t off = c->basic_arc - old_arcs;
-size_t off2 = other - (struct cstruct_s*)old_arcs;
-assert((struct cstruct_s*)c->basic_arc == other);
-assert(c->basic_arc->cost == other->cost);
+ struct astruct_s
+ {
+ int id;
+ long cost;
+ void *tail;
+ void *head;
+ void *nextin;
+ void *nextout;
+ short ident;
+ long flow;
+ long org_cost;
+ };
+ struct cstruct_s
+ {
+ int id;
+ long cost;
+ void *tail;
+ void *head;
+ short ident;
+ long flow;
+ long org_cost;
+ };
+ struct bstruct_s
+ {
+ struct astruct_s *basic_arc;
+ };
+ long num = argc;
+ struct astruct_s array[100];
+ struct astruct_s *old_arcs = array;
+ struct bstruct_s b;
+ struct bstruct_s *c = &b;
+ c->basic_arc = array + num;
+ c->basic_arc->cost = num;
+ struct cstruct_s *other = ((struct cstruct_s *) (array)) + num;
+ size_t off = c->basic_arc - old_arcs;
+ size_t off2 = other - (struct cstruct_s *) old_arcs;
+ assert ((struct cstruct_s *) c->basic_arc == other);
+ assert (c->basic_arc->cost == other->cost);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c
index f3052f6d6f7..fac0af18165 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-field-reads-0.c
@@ -1,15 +1,20 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
_Bool c = astruct.c;
return 0;
}
-
-
/* "rewrite,field_offset,c,1" "typelist" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c
index 8db8e02796f..7e680d7d0ca 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-5-rewrite-local-decl-0.c
@@ -1,11 +1,17 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
return 0;
}
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c
index a23482e50b4..40dad14f051 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-6-field-writes-0.c
@@ -1,14 +1,18 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { _Bool a; _Bool b; _Bool c;};
+ struct astruct_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ };
struct astruct_s astruct;
astruct.c = 0;
return 0;
}
-
-
-
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c
index 1c1b80fb7ff..55fad8b2436 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-7-delete-first-field-0.c
@@ -1,17 +1,25 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct astruct_s { _Bool b; _Bool a; _Bool c; _Bool d;};
+ struct astruct_s
+ {
+ _Bool b;
+ _Bool a;
+ _Bool c;
+ _Bool d;
+ };
struct astruct_s astruct;
_Bool *a_ptr = &astruct.a;
struct astruct_s *astruct_ptr = &astruct;
- _Bool test = (_Bool*)astruct_ptr == a_ptr;
+ _Bool test = (_Bool *) astruct_ptr == a_ptr;
char compile_test[test ? 1 : -1];
- assert(test);
+ assert (test);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c
index 88d8550866f..7b88617adf9 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-8-modify-double-struct-0.c
@@ -1,21 +1,35 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
#include <assert.h>
int
-main()
+main ()
{
- struct inner_s { _Bool a; _Bool b; _Bool c; _Bool d; };
- struct astruct_s { struct inner_s a; struct inner_s b; struct inner_s c; struct inner_s d;};
- struct astruct_s astruct;
- struct inner_s a = astruct.a;
- struct inner_s c = astruct.c;
- struct inner_s d = astruct.d;
- _Bool *pa = (_Bool*) &(astruct.a);
- _Bool *pc = (_Bool*) &(astruct.c);
- _Bool *pd = (_Bool*) &(astruct.d);
- _Bool *c_1 = pa+4;
- _Bool *d_1 = pa+8;
- assert(pc == c_1);
- assert(pd == d_1);
+ struct inner_s
+ {
+ _Bool a;
+ _Bool b;
+ _Bool c;
+ _Bool d;
+ };
+ struct astruct_s
+ {
+ struct inner_s a;
+ struct inner_s b;
+ struct inner_s c;
+ struct inner_s d;
+ };
+ struct astruct_s astruct;
+ struct inner_s a = astruct.a;
+ struct inner_s c = astruct.c;
+ struct inner_s d = astruct.d;
+ _Bool *pa = (_Bool *) &(astruct.a);
+ _Bool *pc = (_Bool *) &(astruct.c);
+ _Bool *pd = (_Bool *) &(astruct.d);
+ _Bool *c_1 = pa + 4;
+ _Bool *d_1 = pa + 8;
+ assert (pc == c_1);
+ assert (pd == d_1);
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c
index b145f93010c..854940105aa 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-structreorg-9-modify-int-struct-0.c
@@ -1,14 +1,20 @@
/* { 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 -flto-partition=none -fipa-dead-field-eliminate
+ * -fdump-ipa-structure-reorg -fipa-typelist-field=b
+ * -fipa-typelist-struct=astruct_s" } */
int
-main()
+main ()
{
- struct astruct_s { int a; int b; int c; int d;};
+ struct astruct_s
+ {
+ int a;
+ int b;
+ int c;
+ int d;
+ };
struct astruct_s astruct;
int a = astruct.a;
int c = astruct.c;
int d = astruct.d;
}
-
-
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index 184a43fb40a..44010d4f9f0 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -508,7 +508,8 @@ extern ipa_opt_pass_d *make_pass_ipa_devirt (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_reference (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_hsa (gcc::context *ctxt);
extern ipa_opt_pass_d *make_pass_ipa_pure_const (gcc::context *ctxt);
-extern simple_ipa_opt_pass *make_pass_ipa_structure_reorg (gcc::context *ctxt);
+extern simple_ipa_opt_pass *
+make_pass_ipa_structure_reorg (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_ipa_pta (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_ipa_tm (gcc::context *ctxt);
extern simple_ipa_opt_pass *make_pass_target_clone (gcc::context *ctxt);