diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-15 10:50:50 +0200 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-16 08:58:12 +0200 |
commit | 689c5c302269a564508238d96482ea1be933acae (patch) | |
tree | 89ea81241d1f8b884dcec84c76a66c67305cd007 | |
parent | def081f8c614ebda18a7bc8348f84292f52533ed (diff) |
wip
-rw-r--r-- | gcc/gimple-caster.c | 17 | ||||
-rw-r--r-- | gcc/gimple-escaper.c | 36 | ||||
-rw-r--r-- | gcc/gimple-escaper.hpp | 1 | ||||
-rw-r--r-- | gcc/ipa-prototype.c | 6 | ||||
-rw-r--r-- | gcc/ipa-prototype.h | 12 | ||||
-rw-r--r-- | gcc/type-escaper.c | 4 |
6 files changed, 48 insertions, 28 deletions
diff --git a/gcc/gimple-caster.c b/gcc/gimple-caster.c index 608e2af5e24..832651cdea5 100644 --- a/gcc/gimple-caster.c +++ b/gcc/gimple-caster.c @@ -46,11 +46,6 @@ GimpleCaster::_walk_pre(gassign *s) is_ssa = false; } - if (is_cast) { - print_gimple_expr(dump_file, s, 0); - log("%s == %s\n", name_l.c_str(), name_r.c_str()); - } - reason.is_escaping = is_cast; reason.type_is_casted = is_cast; exprEscaper.update(lhs, reason); exprEscaper.update(rhs, reason); @@ -70,7 +65,7 @@ GimpleCaster::_walk_pre(gcall *s) if (!fn) return; cgraph_node *node = cgraph_node::get(fn); - const bool known_function = GimpleEscaper::filter_known_function(node); + const bool known_function = GimpleEscaper::filter_known_function(node) || GimpleEscaper::filter_known_function(fn); if (known_function) return; const_tree f_t = TREE_TYPE(fn); @@ -92,12 +87,7 @@ GimpleCaster::_walk_pre(gcall *s) const bool is_casted = !equality.equal(formal_t, real_t); const std::string name_r = stringifier.stringify(real_t); const std::string name_f = stringifier.stringify(formal_t); - if (is_casted) { - print_gimple_expr(dump_file, s, 0); - log("not known ? == %s %s == %s\n", known_function ? "TRUE": " FALSE", name_f.c_str(), name_r.c_str()); - } Reason arg_reason; - arg_reason.is_escaping = is_casted; arg_reason.type_is_casted = is_casted; exprEscaper.update(real, arg_reason); i++; @@ -121,12 +111,7 @@ GimpleCaster::_walk_pre(gcall *s) const bool is_casted = !equality.equal(r_t, l_t); const std::string name_r_t = stringifier.stringify(r_t); const std::string name_l_t = stringifier.stringify(r_t); - if (is_casted) { - print_gimple_expr(dump_file, s, 0); - log("%s == %s\n", name_r_t.c_str(), name_l_t.c_str()); - } Reason ret_reason; - ret_reason.is_escaping = is_casted; ret_reason.type_is_casted = is_casted; exprEscaper.update(lhs, ret_reason); } diff --git a/gcc/gimple-escaper.c b/gcc/gimple-escaper.c index 199b57a5f57..3de1c26d038 100644 --- a/gcc/gimple-escaper.c +++ b/gcc/gimple-escaper.c @@ -92,12 +92,42 @@ GimpleEscaper::_walk_global(varpool_node *vnode) const_tree var_decl = vnode->decl; Reason reason {} ; const bool is_escaping = is_variable_escaping(vnode); - reason.is_escaping = is_escaping; reason.global_is_visible = is_escaping; exprEscaper.update(var_decl, reason); GimpleWalker::_walk_global(vnode); } +bool +GimpleEscaper::filter_known_function(const_tree fndecl) +{ + assert_is_type(fndecl, FUNCTION_DECL); + const_tree identifier_node = DECL_NAME(fndecl); + if (!identifier_node) return false; + + bool filter = false; + const char *_free = "free"; + const char *_malloc = "malloc"; + const char *_realloc = "realloc"; + const char *_calloc = "calloc"; + const char *_memset = "memset"; + const char *_specqsort= "spec_qsort"; + const char *_med3 = "arc_compare"; + const char *_getArcPosition = "getArcPosition"; + const char *_med3_ = "med3.part.0"; + const char* name = IDENTIFIER_POINTER(identifier_node); + gcc_assert(name); + filter |= strcmp(_free, name) == 0; + filter |= strcmp(_malloc, name) == 0; + filter |= strcmp(_realloc, name) == 0; + filter |= strcmp(_memset, name) == 0; + filter |= strcmp(_calloc, name) == 0; + filter |= strcmp(_specqsort, name) == 0; + filter |= strcmp(_med3, name) == 0; + filter |= strcmp(_med3_, name) == 0; + filter |= strcmp(_getArcPosition, name) == 0; + return filter; +} + bool GimpleEscaper::filter_known_function(cgraph_node *node) { @@ -111,6 +141,7 @@ GimpleEscaper::filter_known_function(cgraph_node *node) const char *_specqsort= "spec_qsort"; const char *_med3 = "arc_compare"; const char *_getArcPosition = "getArcPosition"; + const char *_med3_ = "med3.part.0"; const char *name = node->name(); gcc_assert(name); filter |= strcmp(_free, name) == 0; @@ -120,6 +151,7 @@ GimpleEscaper::filter_known_function(cgraph_node *node) filter |= strcmp(_calloc, name) == 0; filter |= strcmp(_specqsort, name) == 0; filter |= strcmp(_med3, name) == 0; + filter |= strcmp(_med3_, name) == 0; filter |= strcmp(_getArcPosition, name) == 0; return filter; } @@ -214,7 +246,6 @@ GimpleEscaper::_walk_pre(gcall *s) TypeStringifier stringifier; Reason arg_reason; - arg_reason.is_escaping = _is_escaping; arg_reason.parameter_is_visible = _is_escaping; arg_reason.is_indirect = !fn; unsigned n = gimple_call_num_args(s); @@ -228,7 +259,6 @@ GimpleEscaper::_walk_pre(gcall *s) const_tree lhs = gimple_call_lhs(s); if (!lhs) return; Reason return_reason; - return_reason.is_escaping = _is_escaping; return_reason.return_is_visible = _is_escaping; return_reason.is_indirect = !fn; exprEscaper.update(lhs, return_reason); diff --git a/gcc/gimple-escaper.hpp b/gcc/gimple-escaper.hpp index 5ae6d90f22a..490ebc20fe0 100644 --- a/gcc/gimple-escaper.hpp +++ b/gcc/gimple-escaper.hpp @@ -16,6 +16,7 @@ protected: undefset undefined; void _init(); static bool filter_known_function(cgraph_node *); + static bool filter_known_function(const_tree); static bool is_function_escaping(cgraph_node *); static bool is_function_escaping(const_tree); static bool is_variable_escaping(varpool_node *); diff --git a/gcc/ipa-prototype.c b/gcc/ipa-prototype.c index 477f6b29957..76d5b223900 100644 --- a/gcc/ipa-prototype.c +++ b/gcc/ipa-prototype.c @@ -53,14 +53,13 @@ typedef std::set<const_tree> undefset; void Reason::print() const { - log("g=%d p=%d r=%d c=%d v=%d u=%d i=%d\n", this->global_is_visible, this->parameter_is_visible, this->return_is_visible, this->type_is_casted, this->type_is_volatile, this->type_is_in_union, this->is_indirect); + log("e=%d g=%d p=%d r=%d c=%d v=%d u=%d i=%d\n", this->is_escaping(), this->global_is_visible, this->parameter_is_visible, this->return_is_visible, this->type_is_casted, this->type_is_volatile, this->type_is_in_union, this->is_indirect); } Reason Reason::operator|(const Reason &other) { Reason retval {}; - retval.is_escaping = this->is_escaping | other.is_escaping; retval.global_is_visible = this->global_is_visible | other.global_is_visible; retval.parameter_is_visible = this->parameter_is_visible | other.parameter_is_visible; retval.return_is_visible = this->return_is_visible | other.return_is_visible; @@ -74,7 +73,6 @@ Reason::operator|(const Reason &other) Reason& Reason::operator|=(const Reason &other) { - this->is_escaping |= other.is_escaping; this->global_is_visible |= other.global_is_visible; this->parameter_is_visible |= other.parameter_is_visible; this->return_is_visible |= other.return_is_visible; @@ -126,7 +124,7 @@ place_escaping_types_in_set(ptrset_t &types, typemap &calc) if (!types.in_points_to_record(type)) continue; const Reason reason = i->second; - reason.is_escaping ? types.escaping.insert(type) : types.non_escaping.insert(type); + reason.is_escaping() ? types.escaping.insert(type) : types.non_escaping.insert(type); } } diff --git a/gcc/ipa-prototype.h b/gcc/ipa-prototype.h index 83570562f9a..d0af35182b9 100644 --- a/gcc/ipa-prototype.h +++ b/gcc/ipa-prototype.h @@ -3,7 +3,15 @@ #include <map> struct Reason { - bool is_escaping : 1; + inline bool is_escaping() const { + return this->global_is_visible + || this->parameter_is_visible + || this->return_is_visible + || this->type_is_casted + || this->type_is_volatile + || this->type_is_in_union + || this->is_indirect; + } bool global_is_visible : 1; bool parameter_is_visible : 1; bool return_is_visible : 1; @@ -14,7 +22,7 @@ struct Reason { Reason operator|(const Reason &); Reason& operator|=(const Reason &); void print() const; - Reason() : is_escaping(0), global_is_visible(0), parameter_is_visible(0), return_is_visible(0), type_is_casted(0), type_is_volatile(0), type_is_in_union(0), is_indirect(0) {}; + Reason() : global_is_visible(0), parameter_is_visible(0), return_is_visible(0), type_is_casted(0), type_is_volatile(0), type_is_in_union(0), is_indirect(0) {}; }; diff --git a/gcc/type-escaper.c b/gcc/type-escaper.c index e03845fc570..edfb55eb44b 100644 --- a/gcc/type-escaper.c +++ b/gcc/type-escaper.c @@ -83,7 +83,7 @@ TypeEscaper::place_escaping_types_in_set() const Reason reason = i->second; std::string name = stringifier.stringify(type); - reason.is_escaping ? _ptrset.escaping.insert(type) : _ptrset.non_escaping.insert(type); + reason.is_escaping() ? _ptrset.escaping.insert(type) : _ptrset.non_escaping.insert(type); } } @@ -115,7 +115,6 @@ TypeEscaper::_update(const_tree t) // This is only the third option. const bool is_volatile = TYPE_VOLATILE(t); Reason _is_volatile; - _is_volatile.is_escaping = is_volatile; _is_volatile.type_is_volatile = is_volatile; Reason _inner = _reason | _is_volatile; _inner.type_is_casted = _inside_indirect_field ? false : _inner.type_is_casted; @@ -161,7 +160,6 @@ TypeEscaper::_walk_UNION_TYPE_pre(const_tree t) _update(t); // After us... so that we can see what is our previous value _reason.type_is_in_union |= is_escaping; - _reason.is_escaping |= is_escaping; } void |