This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] profile feedback: -fprofile-use= and -fprofile-correction, correctness fixes and option semantic changes.
- From: "Seongbae Park (박성배, 朴成培)" <seongbae dot park at gmail dot com>
- To: "Jan Hubicka" <jh at suse dot cz>
- Cc: "Jan Hubicka" <hubicka at ucw dot cz>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 28 May 2008 13:15:25 -0700
- Subject: Re: [PATCH] profile feedback: -fprofile-use= and -fprofile-correction, correctness fixes and option semantic changes.
- References: <ab3a61990803201358l2da959c0t166e9bdfba53dd09@mail.gmail.com> <ab3a61990803292123g13d2f734teb7a126dcba226a0@mail.gmail.com> <20080330131315.GB28471@atrey.karlin.mff.cuni.cz> <ab3a61990803301353n7f6d6a86u194bc39a78b32215@mail.gmail.com> <ab3a61990804021517v1f50537bj7ef7a27db9108d0b@mail.gmail.com> <20080403063951.GE16935@kam.mff.cuni.cz> <ab3a61990804030958h2e6b35d8oca0aa854c9a833b9@mail.gmail.com> <ab3a61990804031630xf235ee6me363b2ca008d13d3@mail.gmail.com> <ab3a61990805271356s2246a5c1nb31104cc6ab8a796@mail.gmail.com> <20080528125714.GE16497@kam.mff.cuni.cz>
On Wed, May 28, 2008 at 5:57 AM, Jan Hubicka <jh@suse.cz> wrote:
>>
>> ping^3 (or ^4 counting ping on irc :)) for the above patch and:
>>
>> http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00112.html
>
> This is OK^4. Thanks for the patience and reminding me!
>
> Honza
Also applied the following patch as revision 136124.
Thanks!
Seongbae
2008-05-28 Seongbae Park <seongbae.park@gmail.com>
* tree-ssa-propagate.c (set_rhs): Preserve the histogram
and the eh region information.
* value-prof.c (gimple_move_stmt_histograms): New function.
* value-prof.h (gimple_move_stmt_histograms): New function declaration.
Index: value-prof.c
===================================================================
--- value-prof.c (revision 136118)
+++ value-prof.c (working copy)
@@ -336,6 +336,25 @@ gimple_duplicate_stmt_histograms (struct
}
}
+
+/* Move all histograms associated with OSTMT to STMT. */
+
+void
+gimple_move_stmt_histograms (struct function *fun, tree stmt, tree ostmt)
+{
+ histogram_value val = gimple_histogram_value (fun, ostmt);
+ if (val)
+ {
+ /* The following three statements can't be reordered,
+ because histogram hashtab relies on stmt field value
+ for finding the exact slot. */
+ set_histogram_value (fun, ostmt, NULL);
+ for (; val != NULL; val = val->hvalue.next)
+ val->hvalue.stmt = stmt;
+ set_histogram_value (fun, stmt, val);
+ }
+}
+
static bool error_found = false;
/* Helper function for verify_histograms. For each histogram reachable via htab
Index: value-prof.h
===================================================================
--- value-prof.h (revision 136117)
+++ value-prof.h (working copy)
@@ -116,6 +116,7 @@ void dump_histograms_for_stmt (struct fu
void gimple_remove_histogram_value (struct function *, tree, histogram_value);
void gimple_remove_stmt_histograms (struct function *, tree);
void gimple_duplicate_stmt_histograms (struct function *, tree, struct function *, tree);
+void gimple_move_stmt_histograms (struct function *, tree, tree);
void verify_histograms (void);
void free_histograms (void);
void stringop_block_profile (tree, unsigned int *, HOST_WIDE_INT *);
Index: tree-ssa-propagate.c
===================================================================
--- tree-ssa-propagate.c (revision 136117)
+++ tree-ssa-propagate.c (working copy)
@@ -40,6 +40,7 @@
#include "langhooks.h"
#include "varray.h"
#include "vec.h"
+#include "value-prof.h"
/* This file implements a generic value propagation engine based on
the same propagation used by the SSA-CCP algorithm [1].
@@ -680,9 +681,10 @@ bool
set_rhs (tree *stmt_p, tree expr)
{
tree stmt = *stmt_p, op;
- stmt_ann_t ann;
+ tree new_stmt;
tree var;
ssa_op_iter iter;
+ int eh_region;
if (!valid_gimple_expression_p (expr))
return false;
@@ -733,9 +735,22 @@ set_rhs (tree *stmt_p, tree expr)
default:
/* Replace the whole statement with EXPR. If EXPR has no side
effects, then replace *STMT_P with an empty statement. */
- ann = stmt_ann (stmt);
- *stmt_p = TREE_SIDE_EFFECTS (expr) ? expr : build_empty_stmt ();
- (*stmt_p)->base.ann = (tree_ann_t) ann;
+ new_stmt = TREE_SIDE_EFFECTS (expr) ? expr : build_empty_stmt ();
+ *stmt_p = new_stmt;
+
+ /* Preserve the annotation, the histograms and the EH region information
+ associated with the original statement. The EH information
+ needs to be preserved only if the new statement still can throw. */
+ new_stmt->base.ann = (tree_ann_t) stmt_ann (stmt);
+ gimple_move_stmt_histograms (cfun, new_stmt, stmt);
+ if (tree_could_throw_p (new_stmt))
+ {
+ eh_region = lookup_stmt_eh_region (stmt);
+ /* We couldn't possibly turn a nothrow into a throw statement. */
+ gcc_assert (eh_region >= 0);
+ remove_stmt_from_eh_region (stmt);
+ add_stmt_to_eh_region (new_stmt, eh_region);
+ }
if (gimple_in_ssa_p (cfun)
&& TREE_SIDE_EFFECTS (expr))