This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Make gcc.dg/profile-dir-*.c more robust


I don't think that checking for the correct gcda filename in the assembly
output is sufficiently target-independent.  The filename is output by
ASM_OUTPUT_ASCII.  How that is actually encoded and split up into several
lines depends on the requirements of the assembler.

For example profile-dir-1.c and profile-dir-3.c fail on MIPS because the
trailing zero is explicitely encoded like profile-dir-1.gcda\000".
profile-dir-2 fails depending how long the path is and whether where it was
split up prevents the match.

Instead of just complaining I decided to fix this because I can easily test
MIPS.  The patch below adds the filename to the dump file and then changes the
tests to check the dump file instead of the assembly.

Tested on mipsisa64-elf and x86_64-linux.

OK?

Adam

	* coverage.c: Include tree-pass.h.
	(coverage_counter_alloc): Print da_file_name to the dump file.

testsuite/

	* gcc.dg/profile-dir-1.c, gcc.dg/profile-dir-2.c,
	gcc.dg/profile-dir-3.c: Generate tree_profile dump.  Check gcda
	file name there instead of the assembly.  Cleanup the dump file.

Index: coverage.c
===================================================================
--- coverage.c	(revision 134355)
+++ coverage.c	(working copy)
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3.  
 #include "hashtab.h"
 #include "tree-iterator.h"
 #include "cgraph.h"
+#include "tree-pass.h"
 
 #include "gcov-io.c"
 
@@ -421,6 +422,9 @@ coverage_counter_alloc (unsigned counter
       ASM_GENERATE_INTERNAL_LABEL (buf, "LPBX", counter + 1);
       DECL_NAME (tree_ctr_tables[counter]) = get_identifier (buf);
       DECL_ALIGN (tree_ctr_tables[counter]) = TYPE_ALIGN (gcov_type_node);
+
+      if (dump_file)
+	fprintf (dump_file, "Using data file %s\n", da_file_name);
     }
   fn_b_ctrs[counter] = fn_n_ctrs[counter];
   fn_n_ctrs[counter] += num;
Index: testsuite/gcc.dg/profile-dir-1.c
===================================================================
--- testsuite/gcc.dg/profile-dir-1.c	(revision 134355)
+++ testsuite/gcc.dg/profile-dir-1.c	(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fprofile-generate=." } */
-/* { dg-final { scan-assembler "\"./profile-dir-1.gcda\"" } } */
+/* { dg-options "-O -fprofile-generate=. -fdump-tree-tree_profile" } */
+/* { dg-final { scan-tree-dump " ./profile-dir-1.gcda" "tree_profile" } } */
 
 int
 main(void)
@@ -9,3 +9,4 @@ main(void)
 }
 
 /* { dg-final { cleanup-coverage-files } } */
+/* { dg-final { cleanup-tree-dump "tree_profile" } } */
Index: testsuite/gcc.dg/profile-dir-2.c
===================================================================
--- testsuite/gcc.dg/profile-dir-2.c	(revision 134355)
+++ testsuite/gcc.dg/profile-dir-2.c	(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fprofile-generate" } */
-/* { dg-final { scan-assembler "/profile-dir-2.gcda" } } */
+/* { dg-options "-O -fprofile-generate -fdump-tree-tree_profile" } */
+/* { dg-final { scan-tree-dump "/profile-dir-2.gcda" "tree_profile" } } */
 
 int
 main(void)
@@ -9,3 +9,4 @@ main(void)
 }
 
 /* { dg-final { cleanup-coverage-files } } */
+/* { dg-final { cleanup-tree-dump "tree_profile" } } */
Index: testsuite/gcc.dg/profile-dir-3.c
===================================================================
--- testsuite/gcc.dg/profile-dir-3.c	(revision 134355)
+++ testsuite/gcc.dg/profile-dir-3.c	(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fprofile-generate -fprofile-dir=." } */
-/* { dg-final { scan-assembler "\"./profile-dir-3.gcda\"" } } */
+/* { dg-options "-O -fprofile-generate -fprofile-dir=. -fdump-tree-tree_profile" } */
+/* { dg-final { scan-tree-dump " ./profile-dir-3.gcda" "tree_profile" } } */
 
 int
 main(void)
@@ -9,3 +9,4 @@ main(void)
 }
 
 /* { dg-final { cleanup-coverage-files } } */
+/* { dg-final { cleanup-tree-dump "tree_profile" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]