<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Incorrect sample profiles at O3"
   href="https://llvm.org/bugs/show_bug.cgi?id=28991">28991</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect sample profiles at O3
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dcallahan@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16963" name="attach_16963" title="Tar file of script and input files">attachment 16963</a> <a href="attachment.cgi?id=16963&action=edit" title="Tar file of script and input files">[details]</a></span>
Tar file of script and input files

<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Customize Bugzilla to have some LLVM flavah"
   href="show_bug.cgi?id=2">bug2</a>.sh generates the reproduction where we compile a training program either
-00 or -03. 

The -O0 training yield this sample

Function: _Z8clampSumPdidd: 105434939, 1, 14 sampled lines
Samples collected in the function's body {
  0: 1
  1: 1
  2.1: 949899
  2.2: 949797
  3: 949833
  4: 0
  5: 949926
  6: 949896
  7: 0
  8: 949929
  9: 949904
  11: 949889
  12: 949809
  14: 4
}

while the -O3 training yields this sample 

Function: _Z8clampSumPdidd: 76108151, 2, 9 sampled lines
Samples collected in the function's body {
  0: 2
  2.1: 1435907
  3: 1436091
  6: 1436048
  7: 1436032
  9: 2
  11: 1435984
  12: 1435974
  14: 2
}

Note the differences in values for relative statements 7 and 9.
The corresponding branch_weights are
   !74 = !{!"branch_weights", i32 1, i32 949905}
and 
   !74 = !{!"branch_weights", i32 1436033, i32 3}

The -O3 sample inverts the relative weights relative to the (correct) -O0
sample.

The attached tar file has <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Customize Bugzilla to have some LLVM flavah"
   href="show_bug.cgi?id=2">bug2</a>.sh, bug.cc and main.cc and a snapshot of <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Customize Bugzilla to have some LLVM flavah"
   href="show_bug.cgi?id=2">bug2</a>.sh
output.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>