[llvm-bugs] [Bug 27308] New: r210828 (GVN: Enable value forwarding for calloc) can cause absurdly long compile times

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 9 17:48:36 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27308

            Bug ID: 27308
           Summary: r210828 (GVN: Enable value forwarding for calloc) can
                    cause absurdly long compile times
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dimitry at andric.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16199
  --> https://llvm.org/bugs/attachment.cgi?id=16199&action=edit
Test case for r210828 regression in compile time

A recent Mesa update in FreeBSD caused a seemingly hanging instance of clang
for me, when it was compiling a rather large generated .c file (generated by
https://cgit.freedesktop.org/mesa/mesa/tree/src/mapi/glapi/gen/gl_gentable.py).
 After waiting long enough, the hang turned out to be just an extremely slow
compilation.

This extreme slowdown turned out to be introduced somewhere between clang 3.4
and 3.5, and after bisecting I ended up at http://reviews.llvm.org/rL210828
("GVN: Enable value forwarding for calloc").  Timings of the test case on a
Xeon E5-2630 v3 @ 2.40GHz, with clang r210827:

        7.98 real         7.86 user         0.12 sys

Same test case, with clang r210828:

      215.30 real       207.70 user         7.59 sys

E.g., roughly a factor 27 slowdown!

It appears both targeting i386, -mdisable-fp-elim and -O2 are essential in the
command line for the test case:

clang -cc1 -triple i386 -mdisable-fp-elim -O2 -w glapi-long-compile.c

With regards to the test case itself, the 'meat' is a large generated function
_glapi_create_table_from_handle(), which basically consists of a very large
number of blocks like:

    if(!disp->CallList) {
        void ** procp = (void **) &disp->CallList;
        snprintf(symboln, sizeof(symboln), "%sCallList", symbol_prefix);
        *procp = dlsym(handle, symboln);
    }

Strangely, though r210828 is apparently about calloc, the only calloc is at the
start of that function:

struct _glapi_table *
_glapi_create_table_from_handle(void *handle, const char *symbol_prefix) {
    struct _glapi_table *disp = calloc(_glapi_get_dispatch_table_size(),
sizeof(_glapi_proc));
    char symboln[512];
    if(!disp)
        return ((void *)0);
[...]

-- 
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/20160410/2d338d60/attachment.html>


More information about the llvm-bugs mailing list