diff mbox

[PR68603] Associate conditional C++ loop's back-jump with start, not body

Message ID m3bnabxwql.fsf@oc1027705133.ibm.com
State New
Headers show

Commit Message

Andreas Arnez Nov. 30, 2015, 4:44 p.m. UTC
SVN commit r230979 always associates a loop's back-jump with the start
of the loop body.  This caused a regression for gcov with conditional
loops, because then the loop body appears to be covered twice per
iteration.

gcc/cp/ChangeLog:

	PR gcov-profile/68603
	* cp-gimplify.c (genericize_cp_loop): For the back-jump's location
	use the start of the loop body only if the loop is unconditional.
---
 gcc/cp/cp-gimplify.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jason Merrill Nov. 30, 2015, 5:01 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index a9a34cd..3c89f1b 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -264,7 +264,9 @@  genericize_cp_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
     }
   else
     {
-      location_t loc = EXPR_LOCATION (expr_first (body));
+      location_t loc = start_locus;
+      if (!cond || integer_nonzerop (cond))
+	loc = EXPR_LOCATION (expr_first (body));
       if (loc == UNKNOWN_LOCATION)
 	loc = start_locus;
       loop = build1_loc (loc, LOOP_EXPR, void_type_node, stmt_list);