<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Cambria;
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
h1
        {mso-style-priority:9;
        mso-style-link:"Heading 1 Char";
        margin-top:24.0pt;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:0in;
        margin-bottom:.0001pt;
        page-break-after:avoid;
        font-size:14.0pt;
        font-family:"Cambria","serif";
        color:#365F91;
        font-weight:bold;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
span.Heading1Char
        {mso-style-name:"Heading 1 Char";
        mso-style-priority:9;
        mso-style-link:"Heading 1";
        font-family:"Cambria","serif";
        color:#365F91;
        font-weight:bold;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Sounds good. Thanks for looking at this!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Matthew
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> Marco Castelluccio [mailto:mcastelluccio@mozilla.com]
<br>
<b>Sent:</b> Tuesday, July 10, 2018 4:37 PM<br>
<b>To:</b> Voss, Matthew; eugeni.stepanov@gmail.com<br>
<b>Cc:</b> llvm-commits@lists.llvm.org; uweigand@de.ibm.com<br>
<b>Subject:</b> Re: [compiler-rt] r336678 - Reapply "Make __gcov_flush flush counters for all shared libraries"<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Actually, I think r336693 is what caused the failure, it's not a spurious failure.<br>
<a href="https://reviews.llvm.org/D49161">https://reviews.llvm.org/D49161</a> should fix it.<br>
<br>
Thanks,<br>
Marco.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Il 10/07/2018 23:30, <a href="mailto:Matthew.Voss@sony.com">
Matthew.Voss@sony.com</a> ha scritto:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hmm… We build the PS4 target on Windows. I’m assuming that’s sanitizer-x86_64-windows?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Matthew</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> Marco Castelluccio [<a href="mailto:mcastelluccio@mozilla.com">mailto:mcastelluccio@mozilla.com</a>]
<br>
<b>Sent:</b> Tuesday, July 10, 2018 2:20 PM<br>
<b>To:</b> Voss, Matthew; <a href="mailto:eugeni.stepanov@gmail.com">eugeni.stepanov@gmail.com</a><br>
<b>Cc:</b> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<b>Subject:</b> Re: [compiler-rt] r336678 - Reapply "Make __gcov_flush flush counters for all shared libraries"</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">I'm going to mark the test as failing on sanitizer-x86_64-linux for now.<br>
Matthew, is it the same target failing for you?<br>
<br>
Thanks,<br>
Marco.<o:p></o:p></p>
<div>
<p class="MsoNormal">Il 10/07/2018 23:10, <a href="mailto:Matthew.Voss@sony.com">
Matthew.Voss@sony.com</a> ha scritto:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Marco,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">This change is also breaking our internal bots. Could you take a look at this?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Matthew</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvm-commits [<a href="mailto:llvm-commits-bounces@lists.llvm.org">mailto:llvm-commits-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Evgenii Stepanov via llvm-commits<br>
<b>Sent:</b> Tuesday, July 10, 2018 11:23 AM<br>
<b>To:</b> Marco Castelluccio<br>
<b>Cc:</b> LLVM Commits<br>
<b>Subject:</b> Re: [compiler-rt] r336678 - Reapply "Make __gcov_flush flush counters for all shared libraries"</span><o:p></o:p></p>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal">Hi,<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">it looks like instrprof-shared-gcov-flush.test needs more XFAILs. See this x86/x86_64 failure:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/13413/steps/test%20standalone%20compiler-rt/logs/stdio">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/13413/steps/test%20standalone%20compiler-rt/logs/stdio</a><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal">On Tue, Jul 10, 2018 at 7:12 AM, Marco Castelluccio via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">Author: marco<br>
Date: Tue Jul 10 07:12:03 2018<br>
New Revision: 336678<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=336678&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=336678&view=rev</a><br>
Log:<br>
Reapply "Make __gcov_flush flush counters for all shared libraries"<br>
<br>
This reapplies r336365, after marking tests as failing on various<br>
configurations.<br>
<br>
Added:<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func2.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func2.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func3.c<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func3.c<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func3.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-func3.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-lib.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-lib.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-lib_called-twice.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-lib_called-twice.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-lib_in-loop.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-lib_in-loop.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush.c<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush.c<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main.c.gcov<br>
      - copied unchanged from r336473, compiler-rt/trunk/test/profile/Inputs/instrprof-shared-main.c.gcov<br>
    compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test<br>
      - copied, changed from r336473, compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test<br>
    compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test<br>
      - copied, changed from r336473, compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test<br>
Modified:<br>
    compiler-rt/trunk/lib/profile/GCDAProfiling.c<br>
    compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c<br>
    compiler-rt/trunk/test/profile/instrprof-dlopen-dlclose-gcov.test<br>
<br>
Modified: compiler-rt/trunk/lib/profile/GCDAProfiling.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/GCDAProfiling.c?rev=336678&r1=336677&r2=336678&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/GCDAProfiling.c?rev=336678&r1=336677&r2=336678&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/profile/GCDAProfiling.c (original)<br>
+++ compiler-rt/trunk/lib/profile/GCDAProfiling.c Tue Jul 10 07:12:03 2018<br>
@@ -86,31 +86,76 @@ static uint64_t file_size = 0;<br>
 static int new_file = 0;<br>
 static int fd = -1;<br>
<br>
-/*<br>
- * A list of functions to write out the data.<br>
- */<br>
-typedef void (*writeout_fn)();<br>
+typedef void (*fn_ptr)();<br>
<br>
-struct writeout_fn_node {<br>
-  writeout_fn fn;<br>
-  struct writeout_fn_node *next;<br>
+typedef void* dynamic_object_id;<br>
+// The address of this variable identifies a given dynamic object.<br>
+static dynamic_object_id current_id;<br>
+#define CURRENT_ID (&current_id)<br>
+<br>
+struct fn_node {<br>
+  dynamic_object_id id;<br>
+  fn_ptr fn;<br>
+  struct fn_node* next;<br>
 };<br>
<br>
-static struct writeout_fn_node *writeout_fn_head = NULL;<br>
-static struct writeout_fn_node *writeout_fn_tail = NULL;<br>
+struct fn_list {<br>
+  struct fn_node *head, *tail;<br>
+};<br>
<br>
 /*<br>
- *  A list of flush functions that our __gcov_flush() function should call.<br>
+ * A list of functions to write out the data, shared between all dynamic objects.<br>
  */<br>
-typedef void (*flush_fn)();<br>
+struct fn_list writeout_fn_list;<br>
<br>
-struct flush_fn_node {<br>
-  flush_fn fn;<br>
-  struct flush_fn_node *next;<br>
-};<br>
+/*<br>
+ *  A list of flush functions that our __gcov_flush() function should call, shared between all dynamic objects.<br>
+ */<br>
+struct fn_list flush_fn_list;<br>
+<br>
+static void fn_list_insert(struct fn_list* list, fn_ptr fn) {<br>
+  struct fn_node* new_node = malloc(sizeof(struct fn_node));<br>
+  new_node->fn = fn;<br>
+  new_node->next = NULL;<br>
+  new_node->id = CURRENT_ID;<br>
+<br>
+  if (!list->head) {<br>
+    list->head = list->tail = new_node;<br>
+  } else {<br>
+    list->tail->next = new_node;<br>
+    list->tail = new_node;<br>
+  }<br>
+}<br>
+<br>
+static void fn_list_remove(struct fn_list* list) {<br>
+  struct fn_node* curr = list->head;<br>
+  struct fn_node* prev = NULL;<br>
+  struct fn_node* next = NULL;<br>
+<br>
+  while (curr) {<br>
+    next = curr->next;<br>
+<br>
+    if (curr->id == CURRENT_ID) {<br>
+      if (curr == list->head) {<br>
+        list->head = next;<br>
+      }<br>
+<br>
+      if (curr == list->tail) {<br>
+        list->tail = prev;<br>
+      }<br>
+<br>
+      if (prev) {<br>
+        prev->next = next;<br>
+      }<br>
+<br>
+      free(curr);<br>
+    } else {<br>
+      prev = curr;<br>
+    }<br>
<br>
-static struct flush_fn_node *flush_fn_head = NULL;<br>
-static struct flush_fn_node *flush_fn_tail = NULL;<br>
+    curr = next;<br>
+  }<br>
+}<br>
<br>
 static void resize_write_buffer(uint64_t size) {<br>
   if (!new_file) return;<br>
@@ -403,6 +448,7 @@ void llvm_gcda_summary_info() {<br>
   const uint32_t obj_summary_len = 9; /* Length for gcov compatibility. */<br>
   uint32_t i;<br>
   uint32_t runs = 1;<br>
+  static uint32_t run_counted = 0; // We only want to increase the run count once.<br>
   uint32_t val = 0;<br>
   uint64_t save_cur_pos = cur_pos;<br>
<br>
@@ -429,7 +475,9 @@ void llvm_gcda_summary_info() {<br>
<br>
     read_32bit_value(); /* checksum, unused */<br>
     read_32bit_value(); /* num, unused */<br>
-    runs += read_32bit_value(); /* Add previous run count to new counter. */<br>
+    uint32_t prev_runs = read_32bit_value();<br>
+    /* Add previous run count to new counter, if not already counted before. */<br>
+    runs = run_counted ? prev_runs : prev_runs + 1;<br>
   }<br>
<br>
   cur_pos = save_cur_pos;<br>
@@ -447,6 +495,8 @@ void llvm_gcda_summary_info() {<br>
   write_bytes("\0\0\0\xa3", 4); /* tag indicates 1 program */<br>
   write_32bit_value(0); /* 0 length */<br>
<br>
+  run_counted = 1;<br>
+<br>
 #ifdef DEBUG_GCDAPROFILING<br>
   fprintf(stderr, "llvmgcda:   %u runs\n", runs);<br>
 #endif<br>
@@ -479,61 +529,34 @@ void llvm_gcda_end_file() {<br>
 }<br>
<br>
 COMPILER_RT_VISIBILITY<br>
-void llvm_register_writeout_function(writeout_fn fn) {<br>
-  struct writeout_fn_node *new_node = malloc(sizeof(struct writeout_fn_node));<br>
-  new_node->fn = fn;<br>
-  new_node->next = NULL;<br>
-<br>
-  if (!writeout_fn_head) {<br>
-    writeout_fn_head = writeout_fn_tail = new_node;<br>
-  } else {<br>
-    writeout_fn_tail->next = new_node;<br>
-    writeout_fn_tail = new_node;<br>
-  }<br>
+void llvm_register_writeout_function(fn_ptr fn) {<br>
+  fn_list_insert(&writeout_fn_list, fn);<br>
 }<br>
<br>
 COMPILER_RT_VISIBILITY<br>
 void llvm_writeout_files(void) {<br>
-  struct writeout_fn_node *curr = writeout_fn_head;<br>
+  struct fn_node *curr = writeout_fn_list.head;<br>
<br>
   while (curr) {<br>
-    curr->fn();<br>
+    if (curr->id == CURRENT_ID) {<br>
+      curr->fn();<br>
+    }<br>
     curr = curr->next;<br>
   }<br>
 }<br>
<br>
 COMPILER_RT_VISIBILITY<br>
 void llvm_delete_writeout_function_list(void) {<br>
-  while (writeout_fn_head) {<br>
-    struct writeout_fn_node *node = writeout_fn_head;<br>
-    writeout_fn_head = writeout_fn_head->next;<br>
-    free(node);<br>
-  }<br>
-  <br>
-  writeout_fn_head = writeout_fn_tail = NULL;<br>
+  fn_list_remove(&writeout_fn_list);<br>
 }<br>
<br>
 COMPILER_RT_VISIBILITY<br>
-void llvm_register_flush_function(flush_fn fn) {<br>
-  struct flush_fn_node *new_node = malloc(sizeof(struct flush_fn_node));<br>
-  new_node->fn = fn;<br>
-  new_node->next = NULL;<br>
-<br>
-  if (!flush_fn_head) {<br>
-    flush_fn_head = flush_fn_tail = new_node;<br>
-  } else {<br>
-    flush_fn_tail->next = new_node;<br>
-    flush_fn_tail = new_node;<br>
-  }<br>
+void llvm_register_flush_function(fn_ptr fn) {<br>
+  fn_list_insert(&flush_fn_list, fn);<br>
 }<br>
<br>
-// __gcov_flush is hidden. When called in a .so file,<br>
-// it dumps profile data of the calling .so file.<br>
-// If a main program needs to dump profile data of each linked<br>
-// .so files, it should use dlsym to find and call llvm_gcov_flush.<br>
-COMPILER_RT_VISIBILITY<br>
 void __gcov_flush() {<br>
-  struct flush_fn_node *curr = flush_fn_head;<br>
+  struct fn_node* curr = flush_fn_list.head;<br>
<br>
   while (curr) {<br>
     curr->fn();<br>
@@ -541,25 +564,13 @@ void __gcov_flush() {<br>
   }<br>
 }<br>
<br>
-// llvm_gcov_flush is not hidden for a program to use dlsym to<br>
-// find and call for any linked .so file.<br>
-void llvm_gcov_flush() {<br>
-  __gcov_flush();<br>
-}<br>
-<br>
 COMPILER_RT_VISIBILITY<br>
 void llvm_delete_flush_function_list(void) {<br>
-  while (flush_fn_head) {<br>
-    struct flush_fn_node *node = flush_fn_head;<br>
-    flush_fn_head = flush_fn_head->next;<br>
-    free(node);<br>
-  }<br>
-<br>
-  flush_fn_head = flush_fn_tail = NULL;<br>
+  fn_list_remove(&flush_fn_list);<br>
 }<br>
<br>
 COMPILER_RT_VISIBILITY<br>
-void llvm_gcov_init(writeout_fn wfn, flush_fn ffn) {<br>
+void llvm_gcov_init(fn_ptr wfn, fn_ptr ffn) {<br>
   static int atexit_ran = 0;<br>
<br>
   if (wfn)<br>
<br>
Modified: compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c?rev=336678&r1=336677&r2=336678&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c?rev=336678&r1=336677&r2=336678&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c (original)<br>
+++ compiler-rt/trunk/test/profile/Inputs/instrprof-dlopen-dlclose-main.c Tue Jul 10 07:12:03 2018<br>
@@ -10,6 +10,12 @@ int main(int argc, char *argv[]) {<br>
     return EXIT_FAILURE;<br>
   }<br>
<br>
+  void (*func)(void) = (void (*)(void))dlsym(f1_handle, "func");<br>
+  if (func == NULL) {<br>
+    fprintf(stderr, "unable to lookup symbol 'func': %s\n", dlerror());<br>
+    return EXIT_FAILURE;<br>
+  }<br>
+<br>
   dlerror();<br>
   void *f2_handle = dlopen("func2.shared", RTLD_LAZY | RTLD_GLOBAL);<br>
   if (f2_handle == NULL) {<br>
@@ -17,31 +23,44 @@ int main(int argc, char *argv[]) {<br>
     return EXIT_FAILURE;<br>
   }<br>
<br>
-  dlerror();<br>
-  void (*gcov_flush)() = (void (*)())dlsym(f1_handle, "__gcov_flush");<br>
-  if (gcov_flush != NULL || dlerror() == NULL) {<br>
-    fprintf(stderr, "__gcov_flush should not be visible in func.shared'\n");<br>
+  void (*func2)(void) = (void (*)(void))dlsym(f2_handle, "func2");<br>
+  if (func2 == NULL) {<br>
+    fprintf(stderr, "unable to lookup symbol 'func2': %s\n", dlerror());<br>
+    return EXIT_FAILURE;<br>
+  }<br>
+  func2();<br>
+<br>
+#ifdef USE_LIB3<br>
+  void *f3_handle = dlopen("func3.shared", RTLD_LAZY | RTLD_GLOBAL);<br>
+  if (f3_handle == NULL) {<br>
+    fprintf(stderr, "unable to open 'func3.shared': %s\n", dlerror());<br>
+    return EXIT_FAILURE;<br>
+  }<br>
+<br>
+  void (*func3)(void) = (void (*)(void))dlsym(f3_handle, "func3");<br>
+  if (func3 == NULL) {<br>
+    fprintf(stderr, "unable to lookup symbol 'func3': %s\n", dlerror());<br>
     return EXIT_FAILURE;<br>
   }<br>
+  func3();<br>
+#endif<br>
<br>
   dlerror();<br>
-  void (*f1_flush)() = (void (*)())dlsym(f1_handle, "llvm_gcov_flush");<br>
-  if (f1_flush == NULL) {<br>
-    fprintf(stderr, "unable to find llvm_gcov_flush in func.shared': %s\n", dlerror());<br>
+  void (*gcov_flush1)() = (void (*)())dlsym(f1_handle, "__gcov_flush");<br>
+  if (gcov_flush1 == NULL) {<br>
+    fprintf(stderr, "unable to find __gcov_flush in func.shared': %s\n", dlerror());<br>
     return EXIT_FAILURE;<br>
   }<br>
-  f1_flush();<br>
<br>
   dlerror();<br>
-  void (*f2_flush)() = (void (*)())dlsym(f2_handle, "llvm_gcov_flush");<br>
-  if (f2_flush == NULL) {<br>
-    fprintf(stderr, "unable to find llvm_gcov_flush in func2.shared': %s\n", dlerror());<br>
+  void (*gcov_flush2)() = (void (*)())dlsym(f2_handle, "__gcov_flush");<br>
+  if (gcov_flush2 == NULL) {<br>
+    fprintf(stderr, "unable to find __gcov_flush in func2.shared': %s\n", dlerror());<br>
     return EXIT_FAILURE;<br>
   }<br>
-  f2_flush();<br>
<br>
-  if (f1_flush == f2_flush) {<br>
-    fprintf(stderr, "Same llvm_gcov_flush found in func.shared and func2.shared\n");<br>
+  if (gcov_flush1 == gcov_flush2) {<br>
+    fprintf(stderr, "Same __gcov_flush found in func.shared and func2.shared\n");<br>
     return EXIT_FAILURE;<br>
   }<br>
<br>
@@ -51,6 +70,17 @@ int main(int argc, char *argv[]) {<br>
     return EXIT_FAILURE;<br>
   }<br>
<br>
+  func();<br>
+<br>
+  int g1 = 0;<br>
+  int g2 = 0;<br>
+  int n = 10;<br>
+<br>
+  if (n % 5 == 0)<br>
+    g1++;<br>
+  else<br>
+    g2++;<br>
+<br>
   return EXIT_SUCCESS;<br>
 }<br>
<br>
<br>
Modified: compiler-rt/trunk/test/profile/instrprof-dlopen-dlclose-gcov.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-dlopen-dlclose-gcov.test?rev=336678&r1=336677&r2=336678&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-dlopen-dlclose-gcov.test?rev=336678&r1=336677&r2=336678&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/profile/instrprof-dlopen-dlclose-gcov.test (original)<br>
+++ compiler-rt/trunk/test/profile/instrprof-dlopen-dlclose-gcov.test Tue Jul 10 07:12:03 2018<br>
@@ -1,6 +1,33 @@<br>
+# This test fails on powerpc64 BE and s390x (<a href="https://bugs.llvm.org/show_bug.cgi?id=38121" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=38121</a>).<br>
+XFAIL: s390x || powerpc64-unknown-linux-gnu<br>
+<br>
 RUN: mkdir -p %t.d<br>
-RUN: %clang --coverage -o %t.d/func.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func.c<br>
-RUN: %clang --coverage -o %t.d/func2.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func2.c<br>
+RUN: cd %t.d<br>
+<br>
+RUN: %clang --coverage -o func.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func.c<br>
+RUN: %clang --coverage -o func2.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func2.c<br>
+RUN: %clang --coverage -o func3.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func3.c<br>
 RUN: %clang --coverage -o %t -fPIC -rpath %t.d %S/Inputs/instrprof-dlopen-dlclose-main.c<br>
<br>
+# Test with two dlopened libraries.<br>
+RUN: %run %t<br>
+RUN: llvm-cov gcov instrprof-dlopen-dlclose-main.gcda<br>
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-dlclose-main.c.gcov %S/Inputs/instrprof-dlopen-dlclose-main.c.gcov<br>
+RUN: llvm-cov gcov instrprof-dlopen-func.gcda<br>
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func.c.gcov %S/Inputs/instrprof-dlopen-func.c.gcov<br>
+RUN: llvm-cov gcov instrprof-dlopen-func2.gcda<br>
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/Inputs/instrprof-dlopen-func2.c.gcov<br>
+RUN: rm instrprof-dlopen-dlclose-main.gcda instrprof-dlopen-func.gcda instrprof-dlopen-func2.gcda<br>
+<br>
+# Test with three dlopened libraries.<br>
+RUN: %clang -DUSE_LIB3 --coverage -o %t -fPIC -rpath %t.d %S/Inputs/instrprof-dlopen-dlclose-main.c<br>
 RUN: %run %t<br>
+RUN: llvm-cov gcov instrprof-dlopen-dlclose-main.gcda<br>
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-dlclose-main.c.gcov %S/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov<br>
+RUN: llvm-cov gcov instrprof-dlopen-func.gcda<br>
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func.c.gcov %S/Inputs/instrprof-dlopen-func.c.gcov<br>
+RUN: llvm-cov gcov instrprof-dlopen-func2.gcda<br>
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/Inputs/instrprof-dlopen-func2.c.gcov<br>
+RUN: llvm-cov gcov instrprof-dlopen-func3.gcda<br>
+RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/Inputs/instrprof-dlopen-func3.c.gcov<br>
+RUN: rm instrprof-dlopen-dlclose-main.gcda instrprof-dlopen-func.gcda instrprof-dlopen-func2.gcda instrprof-dlopen-func3.gcda<br>
<br>
Copied: compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test (from r336473, compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test?p2=compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test&p1=compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test&r1=336473&r2=336678&rev=336678&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test?p2=compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test&p1=compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test&r1=336473&r2=336678&rev=336678&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test (original)<br>
+++ compiler-rt/trunk/test/profile/instrprof-gcov-two-objects.test Tue Jul 10 07:12:03 2018<br>
@@ -1,3 +1,6 @@<br>
+# This test fails on powerpc64 BE and s390x (<a href="https://bugs.llvm.org/show_bug.cgi?id=38121" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=38121</a>).<br>
+XFAIL: s390x || powerpc64-unknown-linux-gnu<br>
+<br>
 RUN: mkdir -p %t.d<br>
 RUN: cd %t.d<br>
<br>
<br>
Copied: compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test (from r336473, compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test?p2=compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test&p1=compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test&r1=336473&r2=336678&rev=336678&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test?p2=compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test&p1=compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test&r1=336473&r2=336678&rev=336678&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test (original)<br>
+++ compiler-rt/trunk/test/profile/instrprof-shared-gcov-flush.test Tue Jul 10 07:12:03 2018<br>
@@ -1,3 +1,6 @@<br>
+# This test fails on Mac, powerpc64 BE and s390x (<a href="https://bugs.llvm.org/show_bug.cgi?id=38121" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=38121</a>).<br>
+XFAIL: darwin || s390x || powerpc64-unknown-linux-gnu<br>
+<br>
 RUN: mkdir -p %t.d<br>
 RUN: cd %t.d<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</blockquote>
<p class="MsoNormal"> <o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>