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] Fix target clones (PR gcov-profile/85370).


Hi.

Target clones have DECL_ARTIFICIAL set to 1, but we want to
provide --coverage for that. With patched GCC on can see:

        -:    0:Source:pr85370.c
        -:    0:Graph:pr85370.gcno
        -:    0:Data:pr85370.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:__attribute__((target_clones("arch=slm","default")))
        1:    2:int foo1 (int a, int b) { // executed #### wrongly
        1:    3:  return a + b;
        -:    4:}
------------------
foo1.arch_slm.0:
        0:    2:int foo1 (int a, int b) { // executed #### wrongly
        0:    3:  return a + b;
        -:    4:}
------------------
foo1.default.1:
        1:    2:int foo1 (int a, int b) { // executed #### wrongly
        1:    3:  return a + b;
        -:    4:}
------------------
        -:    5:
        1:    6:int foo2 (int a, int b) {
        1:    7:  return a + b;
        -:    8:}
        -:    9:
        1:   10:int main() {
        1:   11:  foo1(1, 1);
        1:   12:  foo2(1, 1);
        1:   13:  return 1;
        -:   14:}

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Will install in couple of days if no objection.

Martin

gcc/ChangeLog:

2018-07-25  Martin Liska  <mliska@suse.cz>

        PR gcov-profile/85370
	* coverage.c (coverage_begin_function): Do not mark target
        clones as artificial functions.
---
 gcc/coverage.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


diff --git a/gcc/coverage.c b/gcc/coverage.c
index da171c84d3c..bae6f5cafac 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -656,7 +656,8 @@ coverage_begin_function (unsigned lineno_checksum, unsigned cfg_checksum)
   gcov_write_unsigned (cfg_checksum);
   gcov_write_string (IDENTIFIER_POINTER
 		     (DECL_ASSEMBLER_NAME (current_function_decl)));
-  gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl));
+  gcov_write_unsigned (DECL_ARTIFICIAL (current_function_decl)
+		       && !DECL_FUNCTION_VERSIONED (current_function_decl));
   gcov_write_filename (xloc.file);
   gcov_write_unsigned (xloc.line);
   gcov_write_unsigned (xloc.column);


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