aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2014-02-12 15:46:30 +0100
committerThomas Schwinge <tschwinge@gcc.gnu.org>2014-02-12 15:46:30 +0100
commit88ac13da93a2c1acf2e11a8ad5f33377d8014c01 (patch)
treec3cd305fe391b2bab585d10fda9bcd8a019a2a9f /gcc
parentbae729a29f4d0a06380db341b7cf6146316aff67 (diff)
downloadgcc-88ac13da93a2c1acf2e11a8ad5f33377d8014c01.zip
gcc-88ac13da93a2c1acf2e11a8ad5f33377d8014c01.tar.gz
gcc-88ac13da93a2c1acf2e11a8ad5f33377d8014c01.tar.bz2
Refactor common code into new maybe_fold_stmt function.
gcc/ * gimplify.c (gimplify_call_expr, gimplify_modify_expr): Move common code... (maybe_fold_stmt): ... into this new function. * omp-low.c (lower_omp): Update comment. From-SVN: r207724
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gimplify.c32
-rw-r--r--gcc/omp-low.c5
3 files changed, 23 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 25f1bf4..caf93a9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2014-02-12 Thomas Schwinge <thomas@codesourcery.com>
+ * gimplify.c (gimplify_call_expr, gimplify_modify_expr): Move
+ common code...
+ (maybe_fold_stmt): ... into this new function.
+ * omp-low.c (lower_omp): Update comment.
+
* omp-low.c (lower_omp_target): Add clobber for sizes array, after
last use.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 957a82f..ff341d4 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2191,6 +2191,20 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location)
return gimplify_expr (arg_p, pre_p, NULL, test, fb);
}
+/* Don't fold STMT inside ORT_TARGET, because it can break code by adding decl
+ references that weren't in the source. We'll do it during omplower pass
+ instead. */
+
+static bool
+maybe_fold_stmt (gimple_stmt_iterator *gsi)
+{
+ struct gimplify_omp_ctx *ctx;
+ for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context)
+ if (ctx->region_type == ORT_TARGET)
+ return false;
+ return fold_stmt (gsi);
+}
+
/* Gimplify the CALL_EXPR node *EXPR_P into the GIMPLE sequence PRE_P.
WANT_VALUE is true if the result of the call is desired. */
@@ -2424,14 +2438,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
notice_special_calls (call);
gimplify_seq_add_stmt (pre_p, call);
gsi = gsi_last (*pre_p);
- /* Don't fold stmts inside of target construct. We'll do it
- during omplower pass instead. */
- struct gimplify_omp_ctx *ctx;
- for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context)
- if (ctx->region_type == ORT_TARGET)
- break;
- if (ctx == NULL)
- fold_stmt (&gsi);
+ maybe_fold_stmt (&gsi);
*expr_p = NULL_TREE;
}
else
@@ -4579,14 +4586,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
gimplify_seq_add_stmt (pre_p, assign);
gsi = gsi_last (*pre_p);
- /* Don't fold stmts inside of target construct. We'll do it
- during omplower pass instead. */
- struct gimplify_omp_ctx *ctx;
- for (ctx = gimplify_omp_ctxp; ctx; ctx = ctx->outer_context)
- if (ctx->region_type == ORT_TARGET)
- break;
- if (ctx == NULL)
- fold_stmt (&gsi);
+ maybe_fold_stmt (&gsi);
if (want_value)
{
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index e7fc730..91c8656 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -10134,9 +10134,8 @@ lower_omp (gimple_seq *body, omp_context *ctx)
gimple_stmt_iterator gsi;
for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi))
lower_omp_1 (&gsi, ctx);
- /* Inside target region we haven't called fold_stmt during gimplification,
- because it can break code by adding decl references that weren't in the
- source. Call fold_stmt now. */
+ /* During gimplification, we have not always invoked fold_stmt
+ (gimplify.c:maybe_fold_stmt); call it now. */
if (target_nesting_level)
for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi))
fold_stmt (&gsi);