[gimple-classes, committed 63/92] Concretize three gimple_try_set_ accessors
David Malcolm
dmalcolm@redhat.com
Mon Oct 27 20:38:00 GMT 2014
This corresponds to:
[PATCH 65/89] Concretize three gimple_try_set_ accessors
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01167.html
from the original 89-patch kit
That earlier patch was approved by Jeff:
> OK once prerequisites have gone in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00831.html
gcc/
* gimple.c (gimple_copy): Add checked casts to gimple_try.
* gimple.h (gimple_try_set_kind): Require a gimple_try.
(gimple_try_set_eval): Likewise.
(gimple_try_set_cleanup): Likewise.
* tree-eh.c (optimize_double_finally): Require a pair of gimple_try
statements.
(refactor_eh_r): Convert code comparisons to dynamic casts.
---
gcc/ChangeLog.gimple-classes | 14 ++++++++++++++
gcc/gimple.c | 12 ++++++++----
gcc/gimple.h | 13 +++++--------
gcc/tree-eh.c | 15 +++++++--------
4 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index b874697..af8a440 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,19 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Concretize three gimple_try_set_ accessors
+
+ * gimple.c (gimple_copy): Add checked casts to gimple_try.
+
+ * gimple.h (gimple_try_set_kind): Require a gimple_try.
+ (gimple_try_set_eval): Likewise.
+ (gimple_try_set_cleanup): Likewise.
+
+ * tree-eh.c (optimize_double_finally): Require a pair of gimple_try
+ statements.
+ (refactor_eh_r): Convert code comparisons to dynamic casts.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
Concretize gimple_try_set_catch_is_cleanup
* gimple.h (gimple_try_set_catch_is_cleanup): Require a gimple_try.
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 0775477..0fac6b4 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -1709,10 +1709,14 @@ gimple_copy (gimple stmt)
break;
case GIMPLE_TRY:
- new_seq = gimple_seq_copy (gimple_try_eval (stmt));
- gimple_try_set_eval (copy, new_seq);
- new_seq = gimple_seq_copy (gimple_try_cleanup (stmt));
- gimple_try_set_cleanup (copy, new_seq);
+ {
+ gimple_try try_stmt = as_a <gimple_try> (stmt);
+ gimple_try try_copy = as_a <gimple_try> (copy);
+ new_seq = gimple_seq_copy (gimple_try_eval (try_stmt));
+ gimple_try_set_eval (try_copy, new_seq);
+ new_seq = gimple_seq_copy (gimple_try_cleanup (try_stmt));
+ gimple_try_set_cleanup (try_copy, new_seq);
+ }
break;
case GIMPLE_OMP_FOR:
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 990e90d..3c11a4a 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3711,9 +3711,8 @@ gimple_try_kind (const_gimple gs)
/* Set the kind of try block represented by GIMPLE_TRY GS. */
static inline void
-gimple_try_set_kind (gimple gs, enum gimple_try_flags kind)
+gimple_try_set_kind (gimple_try gs, enum gimple_try_flags kind)
{
- GIMPLE_CHECK (gs, GIMPLE_TRY);
gcc_gimple_checking_assert (kind == GIMPLE_TRY_CATCH
|| kind == GIMPLE_TRY_FINALLY);
if (gimple_try_kind (gs) != kind)
@@ -3786,23 +3785,21 @@ gimple_try_set_catch_is_cleanup (gimple_try g, bool catch_is_cleanup)
/* Set EVAL to be the sequence of statements to use as the body for
- GIMPLE_TRY GS. */
+ GIMPLE_TRY TRY_STMT. */
static inline void
-gimple_try_set_eval (gimple gs, gimple_seq eval)
+gimple_try_set_eval (gimple_try try_stmt, gimple_seq eval)
{
- gimple_statement_try *try_stmt = as_a <gimple_statement_try *> (gs);
try_stmt->eval = eval;
}
/* Set CLEANUP to be the sequence of statements to use as the cleanup
- body for GIMPLE_TRY GS. */
+ body for GIMPLE_TRY TRY_STMT. */
static inline void
-gimple_try_set_cleanup (gimple gs, gimple_seq cleanup)
+gimple_try_set_cleanup (gimple_try try_stmt, gimple_seq cleanup)
{
- gimple_statement_try *try_stmt = as_a <gimple_statement_try *> (gs);
try_stmt->cleanup = cleanup;
}
diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c
index b496c08..da54772 100644
--- a/gcc/tree-eh.c
+++ b/gcc/tree-eh.c
@@ -3024,7 +3024,7 @@ same_handler_p (gimple_seq oneh, gimple_seq twoh)
temporary used in the initializer for A. */
static void
-optimize_double_finally (gimple one, gimple two)
+optimize_double_finally (gimple_try one, gimple_try two)
{
gimple oneh;
gimple_stmt_iterator gsi;
@@ -3071,13 +3071,12 @@ refactor_eh_r (gimple_seq seq)
two = NULL;
else
two = gsi_stmt (gsi);
- if (one
- && two
- && gimple_code (one) == GIMPLE_TRY
- && gimple_code (two) == GIMPLE_TRY
- && gimple_try_kind (one) == GIMPLE_TRY_FINALLY
- && gimple_try_kind (two) == GIMPLE_TRY_FINALLY)
- optimize_double_finally (one, two);
+ if (one && two)
+ if (gimple_try try_one = dyn_cast <gimple_try> (one))
+ if (gimple_try try_two = dyn_cast <gimple_try> (two))
+ if (gimple_try_kind (try_one) == GIMPLE_TRY_FINALLY
+ && gimple_try_kind (try_two) == GIMPLE_TRY_FINALLY)
+ optimize_double_finally (try_one, try_two);
if (one)
switch (gimple_code (one))
{
--
1.8.5.3
More information about the Gcc-patches
mailing list