[LLVMbugs] [Bug 7576] New: clang takes a long time to build a c file with -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 6 08:52:55 PDT 2010


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

           Summary: clang takes a long time to build a c file with -O2
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: vince at kyllikki.org
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=5171)
 --> (http://llvm.org/bugs/attachment.cgi?id=5171)
Intermediate source from clang compile

The NetSurf project (http://netsurf-browser.org/) has a single file which takes
an unusually long time to compile with -O2 optimisation turned on.

The smallest test case I can currently reproduce the issue with is building the
file (/content/urldb.c within our codebase) as part of the test suite.

Here are the tests showing the compile time for clang and gcc with and without
-O2

$ clang --version
clang version 2.0 (trunk 106560)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ gcc --version
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ time clang -std=c99 -g -O2 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I.. `pkg-config
--cflags libxml-2.0 libcurl` ../content/urldb.c ../utils/url.c ../utils/utils.c
../utils/messages.c ../utils/hashtable.c ../utils/filename.c
../test/urldbtest.c -o urldbtest `pkg-config --libs libxml-2.0 libcurl`

real    1m55.421s
user    1m49.927s
sys    0m1.228s
$ time clang -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I.. `pkg-config
--cflags libxml-2.0 libcurl` ../content/urldb.c ../utils/url.c ../utils/utils.c
../utils/messages.c ../utils/hashtable.c ../utils/filename.c
../test/urldbtest.c -o urldbtest `pkg-config --libs libxml-2.0 libcurl`

real    0m1.577s
user    0m1.200s
sys    0m0.192s
$ time gcc -std=c99 -g -O2 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I.. `pkg-config
--cflags libxml-2.0 libcurl` ../content/urldb.c ../utils/url.c ../utils/utils.c
../utils/messages.c ../utils/hashtable.c ../utils/filename.c
../test/urldbtest.c -o urldbtest `pkg-config --libs libxml-2.0 libcurl`

real    0m3.229s
user    0m2.696s
sys    0m0.308s
$ time gcc -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I.. `pkg-config
--cflags libxml-2.0 libcurl` ../content/urldb.c ../utils/url.c ../utils/utils.c
../utils/messages.c ../utils/hashtable.c ../utils/filename.c
../test/urldbtest.c -o urldbtest `pkg-config --libs libxml-2.0 libcurl`

real    0m1.242s
user    0m0.920s
sys    0m0.196s


The specific file that is taking the time is content/urldb.c

$ time clang -std=c99 -c -g -O2 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I..
`pkg-config --cflags libxml-2.0 libcurl` ../content/urldb.c 

real    1m50.883s
user    1m47.823s
sys    0m0.764s
$ time clang -std=c99 -c -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I..
`pkg-config --cflags libxml-2.0 libcurl` ../content/urldb.c 

real    0m0.649s
user    0m0.520s
sys    0m0.060s

I saved the intermediate files (-save-temps) from the previous compile
(attached) and re-tested

time clang -c -O0 urldb.i 

real    0m0.645s
user    0m0.512s
sys    0m0.028s
[16:49 vince at derik ~/netsurf/netsurf-trunk/test]$ time clang -c -O2 urldb.i 

real    1m52.981s
user    1m48.683s
sys    0m0.892s

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list