<html>
    <head>
      <base href="http://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 --- - Improvements in raw branch profile data representation"
   href="http://llvm.org/bugs/show_bug.cgi?id=22719">22719</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improvements in raw branch profile data representation
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>Global Analyses
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dnovillo@google.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dnovillo@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>davidxl@google.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Raw branch profile data from instrumentation or sample based profiler is
represented using MD_prof meta data attached to branch/switch instructions.

The raw profile data serves two purposes:
1) to represent branch probabilities
2) to represent the raw branch execution count (named weight).

However the current profile annotation in clang has some limitations that lead
to information loss due to weight scaling:

(in tools/clang/lib/CodeGen/CodeGenPGO.cpp)

- scaleBranchWeight: when computing branch weight, the profile count is capped
to UINT32_MAX. For applications with long training runs (especially for cases
with hot loops executed by many threads), the capping can occur often.  Due to
the capping, currently the branch weight can not be used to preserve edge
execution count information. When the actual weight is larger but close to
UINT32_MAX, the scale factor will be two. As a result, the scaled weight will
only be half of the actual weight.

- When there is no scaling (scaling factor == 1), the computed weight will be
the actual weight + 1 (see calculateWeightScale).  This leads to distortion to
branch probability. Also for a loop that executes only once, the exit edge will
have a calculated weight of 2. This leads to wrong estimated trip count which
is only half of the actual value.</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>