<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 --- - Incredibly slow compilation on complex CFG"
   href="http://llvm.org/bugs/show_bug.cgi?id=22609">22609</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incredibly slow compilation on complex CFG
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bernd@net2o.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've made Gforth compile with clang (works fine, resulting speed almost as good
as GCC), but compiling the engine is extremely slow.  The engine contains a big
function generated by vmgen, which uses computed gotos to jump from one
primitive to the other, so all the vm code ends up in one function.  We won't
fix that, that's the right way to go; that way, the compiler can allocate
registers for all important pointers.

Apparently, LLVM tries to optimize over these computed gotos, which is
completely futile - it can't improve the code that way, and it is of course
O(n²) to do so. With a few hundred primitives, Gforth's engine certainly is a
relatively big function using many computed gotos (one per primitive).

In the end, it takes about 10 minutes for one engine compilation run on a 3GHz
Core i7, instead of seconds on GCC. Of course, not optimizing at all "solves"
that problem.

We have a similar problem with GCC and -fgcse, and the GCC manual suggests to
use -fno-gcse, which we do (in this case, it *also* affects run-time, not only
compile-time):

           Note: When compiling a program using computed gotos, a GCC
           extension, you may get better run-time performance if you disable
           the global common subexpression elimination pass by adding
           -fno-gcse to the command line.

Suggestion: Avoid global optimizations over computed gotos if the function has
more than a few labels as targets for these gotos.

You can try compiling Gforth git on clang (./configure CC=clang) with the
current Gforth git:

git clone git://git.savannah.gnu.org/gforth.git

Note that you need a running gforth to compile from git sources (vmgen is
written in Gforth), but that one doesn't have to be the latest development
version.</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>