aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-05-15 23:41:35 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-05-15 23:41:35 +0200
commitc42b72a7ddc52c65a0a6b3f9127224c8770ac6da (patch)
tree8484d48e0ab4506ce0c9e9dfbf430cf6a477a38b /gcc
parente5d7010bb30b136e06f31edd197b6dca9f04f7cb (diff)
downloadgcc-c42b72a7ddc52c65a0a6b3f9127224c8770ac6da.zip
gcc-c42b72a7ddc52c65a0a6b3f9127224c8770ac6da.tar.gz
gcc-c42b72a7ddc52c65a0a6b3f9127224c8770ac6da.tar.bz2
re PR debug/90197 (Cannot step through simple loop at -O -g)
PR debug/90197 * cp-gimplify.c (genericize_cp_loop): Emit a DEBUG_BEGIN_STMT before the condition (or if missing or constant non-zero at the end of the loop. Emit a DEBUG_BEGIN_STMT before the increment expression if any. Don't call protected_set_expr_location on incr if it already has a location. From-SVN: r271269
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-gimplify.c29
2 files changed, 35 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3119c03..058773f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2019-05-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/90197
+ * cp-gimplify.c (genericize_cp_loop): Emit a DEBUG_BEGIN_STMT
+ before the condition (or if missing or constant non-zero at the end
+ of the loop. Emit a DEBUG_BEGIN_STMT before the increment expression
+ if any. Don't call protected_set_expr_location on incr if it already
+ has a location.
+
2019-05-15 Marek Polacek <polacek@redhat.com>
CWG 2096 - constraints on literal unions.
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 4e63a4a..72d8581 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -241,8 +241,10 @@ genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
tree blab, clab;
tree exit = NULL;
tree stmt_list = NULL;
+ tree debug_begin = NULL;
- protected_set_expr_location (incr, start_locus);
+ if (EXPR_LOCATION (incr) == UNKNOWN_LOCATION)
+ protected_set_expr_location (incr, start_locus);
cp_walk_tree (&cond, cp_genericize_r, data, NULL);
cp_walk_tree (&incr, cp_genericize_r, data, NULL);
@@ -253,6 +255,13 @@ genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
cp_walk_tree (&body, cp_genericize_r, data, NULL);
*walk_subtrees = 0;
+ if (MAY_HAVE_DEBUG_MARKER_STMTS
+ && (!cond || !integer_zerop (cond)))
+ {
+ debug_begin = build0 (DEBUG_BEGIN_STMT, void_type_node);
+ SET_EXPR_LOCATION (debug_begin, cp_expr_loc_or_loc (cond, start_locus));
+ }
+
if (cond && TREE_CODE (cond) != INTEGER_CST)
{
/* If COND is constant, don't bother building an exit. If it's false,
@@ -265,10 +274,24 @@ genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
}
if (exit && cond_is_first)
- append_to_statement_list (exit, &stmt_list);
+ {
+ append_to_statement_list (debug_begin, &stmt_list);
+ debug_begin = NULL_TREE;
+ append_to_statement_list (exit, &stmt_list);
+ }
append_to_statement_list (body, &stmt_list);
finish_bc_block (&stmt_list, bc_continue, clab);
- append_to_statement_list (incr, &stmt_list);
+ if (incr)
+ {
+ if (MAY_HAVE_DEBUG_MARKER_STMTS)
+ {
+ tree d = build0 (DEBUG_BEGIN_STMT, void_type_node);
+ SET_EXPR_LOCATION (d, cp_expr_loc_or_loc (incr, start_locus));
+ append_to_statement_list (d, &stmt_list);
+ }
+ append_to_statement_list (incr, &stmt_list);
+ }
+ append_to_statement_list (debug_begin, &stmt_list);
if (exit && !cond_is_first)
append_to_statement_list (exit, &stmt_list);