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

            Bug ID: 27012
           Summary: Preprocessing and compiling C++ code in separate steps
                    may be noticeably faster than normal compilation.
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: officesamu...@gmail.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Created attachment 16063
  --> https://llvm.org/bugs/attachment.cgi?id=16063&action=edit
test code

For certain source files preprocessing and compiling them separately is faster
than normal compilation. The attached "clang_speed_test2.cpp" is one of such
files (needs boost to compile).

To reproduce the issue run the following script (assumes that boost 1.60 was
unpacked to ~/Downloads):
#!/bin/bash

COMP=clang++-3.8
OPT=-std=c++14\ -stdlib=libc++\ -isystem\ $HOME/Downloads/boost_1_60_0
FILE_NAME=clang_speed_test2.cpp

time $COMP $OPT -c $FILE_NAME -o out.cpp.1.o
time $COMP $OPT -E $FILE_NAME -o out.cpp.i
time $COMP $OPT -x c++ -c out.cpp.i -o out.cpp.2.o

Sample output on my Linux laptop:
real 0m59.743s
user 0m58.788s
sys  0m0.874s

real 0m0.204s
user 0m0.176s
sys  0m0.027s

real 0m46.988s
user 0m46.124s
sys  0m0.803s

So, it looks like there is an optimization opportunity hiding inside clang. It
would be nice to have the smaller compilation time without the need of
additional workarounds.

Some notes:
1) similar results may be obtained with clang 3.6 and 3.7; as of boost - the
issue is still reproducible with 1.58, but not with 1.57 (at least for the
attached code)
2) the difference on (some of) real production code was even bigger - the
separate steps were roughly 2x faster.
3) using the "-save-temps" option eliminates the difference (but it's not an
ideal workaround since sometimes it just increases compilation time)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to