[LLVMbugs] [Bug 12850] New: Severe constexpr compile-time performance issue
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed May 16 07:53:03 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12850
Bug #: 12850
Summary: Severe constexpr compile-time performance issue
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: andyg1001 at hotmail.co.uk
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
The following is some simple test code that causes clang to slow to a crawl:
#include <stdio.h>
constexpr int fn(int i) {
return i < 0 ? 0 : (i + fn(i-1) + fn(i-2));
}
constexpr int e = fn(NUM);
int main() {
printf("%i\n", e);
return 0;
}
With gcc 4.6.3 or 4.7.0, compiling using "gcc -std=c++0x test.cpp -DNUM=???"
(where NUM is given in the table below), takes the following compile times:
NUM | compile time | output
================================
5 | 0.03 | 26
10 | 0.03 | 364
15 | 0.03 | 4163
20 | 0.03 | 46345
25 | 0.03 | 514201
30 | 0.03 | 5702854
35 | 0.03 | 63245948
40 | 0.03 | 701408690
On clang 3.1 rc-1, the corresponding compile times become:
NUM | compile time | output
================================
5 | 0.03 | 26
10 | 0.04 | 364
15 | 0.04 | 4163
20 | 0.12 | 46345
25 | 1.03 | 514201
30 | 11.16 | 5702854
35 | 123.93 | 63245948
40 | 1377.85 | 701408690
In both cases, compile times are in seconds. I can only assume gcc must be
somehow caching previously evaluated function calls...
--
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