This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: reapply code to profile.c to fix gcov test failure
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH]: reapply code to profile.c to fix gcov test failure
- From: Janis Johnson <janis187 at us dot ibm dot com>
- Date: Tue, 21 Aug 2001 15:06:17 -0700
- Cc: jh at suse dot cz
The test gcc.misc-tests/gcov-3.c was added on July 11 and passed until
August 4. The test is meant to make sure that gcov doesn't die when
processing data from a program that uses non-local gotos, but the
failure is unrelated to that and happens because code following a call
in main() isn't counted.
On August 4 Honza deleted a chunk of code in branch_prob() in profile.c
that added an exit edge for a call or for some kinds of asm code. If
that code is reapplied, as in this patch, then gcov-3.c passes again.
The new test doesn't cover more than gcov-3.c already does, but if it
fails then it should be more clear what has broken.
Bootstrapped and tested on i686-pc-linux-gnu.
Honza and rth have both made lots of changes to profile.c lately and
might have better ideas of how to fix this.
2001-08-21 Janis Johnson <janis187@us.ibm.com>
* profile.c (branch_prob): Reinsert code to add exit edge
after call or asm code.
* gcc.misc-tests/gcov-6.c: New test.
Index: profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/profile.c,v
retrieving revision 1.68
diff -u -r1.68 profile.c
--- profile.c 2001/08/21 05:06:52 1.68
+++ profile.c 2001/08/21 20:16:58
@@ -593,6 +593,28 @@
have_entry_edge = 1;
}
+ /* ??? Not strictly needed unless flag_test_coverage, but adding
+ them anyway keeps the .da file consistent. */
+ /* ??? Currently inexact for basic blocks with multiple calls.
+ We need to split blocks here. */
+ for (insn = bb->head;
+ insn != NEXT_INSN (bb->end);
+ insn = NEXT_INSN (insn))
+ {
+ rtx set;
+ if (GET_CODE (insn) == CALL_INSN)
+ need_exit_edge = 1;
+ else if (GET_CODE (insn) == INSN)
+ {
+ set = PATTERN (insn);
+ if (GET_CODE (set) == PARALLEL)
+ set = XVECEXP (set, 0, 0);
+ if ((GET_CODE (set) == ASM_OPERANDS && MEM_VOLATILE_P (set))
+ || GET_CODE (set) == ASM_INPUT)
+ need_exit_edge = 1;
+ }
+ }
+
if (need_exit_edge && !have_exit_edge)
{
if (rtl_dump_file)
--- gcc/testsuite/gcc.misc-tests/gcov-6.c.orig Tue Aug 21 13:20:15 2001
+++ gcc/testsuite/gcc.misc-tests/gcov-6.c Tue Aug 21 13:03:56 2001
@@ -0,0 +1,29 @@
+/* Check that statements following a call are counted. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int retval = 1;
+
+void doit2 (int i)
+{
+ if (i == 2) /* count(1) */
+ abort ();
+}
+
+void doit (int i)
+{
+ doit2 (i); /* count(1) */
+ retval = 2; /* count(1) */
+ if (i == 0) /* count(1) */
+ abort ();
+}
+
+int main ()
+{
+ doit (1); /* count(1) */
+ retval = 0; /* count(1) */
+ exit (retval); /* count(1) */
+}
+
+/* { dg-final { run-gcov gcov-6.c } } */