<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 --- - Infinite loop in SampleProfileLoader (inlineHotFunctions)"
   href="https://llvm.org/bugs/show_bug.cgi?id=31119">31119</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Infinite loop in SampleProfileLoader (inlineHotFunctions)
          </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>Windows NT
          </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>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>greg_bedwell@sn.scee.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>danielcdh@gmail.com, dnovillo@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We've had a report from a user out in the field of a hang in the compiler that
occurs when -fprofile-sample-use is used.  I can see that it's getting stuck in
SampleProfileLoader::inlineHotFunctions due to never breaking out of the
while(true).  I've reduced the (large) user-provided testcase and constructed
the following simple one that demonstrates the behaviour:

$ type pgo.txt
#
==============================================================================
_Z5alphav:102608:432
 0.1: _Z4sort14GenericFunctor:105
#
==============================================================================

$ type test.cpp
//
=============================================================================
__attribute__((__nodebug__)) inline void _Sort(unsigned aa) {
  if (aa)
    _Sort(--aa);
}
struct GenericFunctor {
  GenericFunctor() {}
};
unsigned depth;
__attribute__((__nodebug__)) inline void sort(GenericFunctor) { _Sort(depth); }
void alpha() { sort(GenericFunctor()); }
//
=============================================================================

$ clang -target x86_64-unknown-unknown -v
clang version 4.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
76fd46ed36e54c6418eb2d9254d9b99d1528311b) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
fcc1f76b4d065552630b28ec1d7959b692680c18)
Target: x86_64-unknown-unknown
Thread model: posix
InstalledDir:
C:\work\public-git\upstream-llvm\build-vs2015-ps4-master\Release\bin

$ clang -target x86_64-unknown-unknown -Rpass=sample -c test.cpp -O3 -g

$ clang -target x86_64-unknown-unknown -Rpass=sample -c test.cpp -O3 -g
-fprofile-sample-use=pgo.txt
test.cpp:11:16: remark: inlined hot callee '_Z4sort14GenericFunctor' with 105
samples into '_Z5alphav' [-Rpass=sample-profile]
void alpha() { sort(GenericFunctor()); }
               ^
test.cpp:11:16: remark: inlined hot callee '_Z5_Sortj' with 105 samples into
'_Z5alphav' [-Rpass=sample-profile]
test.cpp:11:16: remark: inlined hot callee '_Z5_Sortj' with 105 samples into
'_Z5alphav' [-Rpass=sample-profile]
test.cpp:11:16: remark: inlined hot callee '_Z5_Sortj' with 105 samples into
'_Z5alphav' [-Rpass=sample-profile]
test.cpp:11:16: remark: inlined hot callee '_Z5_Sortj' with 105 samples into
'_Z5alphav' [-Rpass=sample-profile]
test.cpp:11:16: remark: inlined hot callee '_Z5_Sortj' with 105 samples into
'_Z5alphav' [-Rpass=sample-profile]
test.cpp:11:16: remark: inlined hot callee '_Z5_Sortj' with 105 samples into
'_Z5alphav' [-Rpass=sample-profile]
test.cpp:11:16: remark: inlined hot callee '_Z5_Sortj' with 105 samples into
'_Z5alphav' [-Rpass=sample-profile]
^C
$</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>