This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, 4/6] Remove first_pass_instance from pass_object_sizes
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: David Malcolm <dmalcolm at redhat dot com>, "gcc-patches at gnu dot org" <gcc-patches at gnu dot org>
- Date: Sun, 15 Nov 2015 12:03:10 +0100
- Subject: [PATCH, 4/6] Remove first_pass_instance from pass_object_sizes
- Authentication-results: sourceware.org; auth=none
- References: <56447A09 dot 4070608 at mentor dot com> <CAFiYyc2KKjvDO1u5iWmgF7p+8niQq0ngHZUsbgQ8=zyOaFoEAg at mail dot gmail dot com> <564498CE dot 5010207 at mentor dot com> <CAFiYyc21qBe3aBSzs6H596-EkwooKEWpDstbZapxnhHM9sn=Pw at mail dot gmail dot com> <CAFiYyc1vpb_nU_ip9sk69P0P9r2rnBsOOWgJ-j-T9eMk5m3Xqw at mail dot gmail dot com> <1447342432 dot 7830 dot 21 dot camel at surprise> <CAFiYyc1dFYBK1SUSCgaRKFc1WL8jMpQkPuEpF6jNz=F8qDm=tQ at mail dot gmail dot com> <5645EC5A dot 9060005 at mentor dot com> <5646FC85 dot 2060802 at mentor dot com> <564864AA dot 6000101 at mentor dot com>
On 15/11/15 11:55, Tom de Vries wrote:
[ was: Re: [PATCH] Remove first_pass_instance from pass_vrp ]
This patch series removes first_pass_instance.
1 Remove first_pass_instance from pass_vrp
2 Remove first_pass_instance from pass_reassoc
3 Remove first_pass_instance from pass_dominator
4 Remove first_pass_instance from pass_object_sizes
5 Remove first_pass_instance from pass_ccp
6 Remove first_pass_instance
Bootstrapped and reg-tested on x86_64.
I will post the individual patches in reply to this email.
[ I won't post the first patch though. It was already posted here:
https://gcc.gnu.org/ml/gcc-patches/2015-11/msg01701.html . ]
this patches removes first_pass_instance from pass_object_sizes.
Thanks,
- Tom
Remove first_pass_instance from pass_object_sizes
2015-11-15 Tom de Vries <tom@codesourcery.com>
* passes.def: Add arg to pass_object_sizes pass instantiation.
* tree-object-size.c (pass_object_sizes::pass_object_sizes): Initialize
insert_min_max_p.
(pass_object_sizes::set_pass_param): New member function. Set
insert_min_max_p.
(pass_object_sizes::insert_min_max_p): New private member.
(pass_object_sizes::execute): Use insert_min_max_p instead of
first_pass_instance.
---
gcc/passes.def | 4 ++--
gcc/tree-object-size.c | 14 +++++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/gcc/passes.def b/gcc/passes.def
index d274a95..64883a7 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -77,7 +77,7 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_all_early_optimizations);
PUSH_INSERT_PASSES_WITHIN (pass_all_early_optimizations)
NEXT_PASS (pass_remove_cgraph_callee_edges);
- NEXT_PASS (pass_object_sizes);
+ NEXT_PASS (pass_object_sizes, true /* insert_min_max_p */);
NEXT_PASS (pass_ccp);
/* After CCP we rewrite no longer addressed locals into SSA
form if possible. */
@@ -164,7 +164,7 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_backprop);
NEXT_PASS (pass_phiprop);
NEXT_PASS (pass_forwprop);
- NEXT_PASS (pass_object_sizes);
+ NEXT_PASS (pass_object_sizes, false /* insert_min_max_p */);
/* pass_build_alias is a dummy pass that ensures that we
execute TODO_rebuild_alias at this point. */
NEXT_PASS (pass_build_alias);
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index fa3625c..459e65d 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -1217,13 +1217,21 @@ class pass_object_sizes : public gimple_opt_pass
{
public:
pass_object_sizes (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_object_sizes, ctxt)
+ : gimple_opt_pass (pass_data_object_sizes, ctxt), insert_min_max_p (false)
{}
/* opt_pass methods: */
opt_pass * clone () { return new pass_object_sizes (m_ctxt); }
+ void set_pass_param (unsigned int n, bool param)
+ {
+ gcc_assert (n == 0);
+ insert_min_max_p = param;
+ }
virtual unsigned int execute (function *);
+ private:
+ /* Determines whether the pass instance creates MIN/MAX_EXPRs. */
+ bool insert_min_max_p;
}; // class pass_object_sizes
/* Dummy valueize function. */
@@ -1250,12 +1258,12 @@ pass_object_sizes::execute (function *fun)
init_object_sizes ();
- /* In the first pass instance, only attempt to fold
+ /* If insert_min_max_p, only attempt to fold
__builtin_object_size (x, 1) and __builtin_object_size (x, 3),
and rather than folding the builtin to the constant if any,
create a MIN_EXPR or MAX_EXPR of the __builtin_object_size
call result and the computed constant. */
- if (first_pass_instance)
+ if (insert_min_max_p)
{
tree ost = gimple_call_arg (call, 1);
if (tree_fits_uhwi_p (ost))