[LLVMbugs] [Bug 22609] New: Incredibly slow compilation on complex CFG

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 16 14:46:50 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22609

            Bug ID: 22609
           Summary: Incredibly slow compilation on complex CFG
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bernd at net2o.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150216/de6ab2db/attachment.html>


More information about the llvm-bugs mailing list