I did some benchmarking of clang on Windows this morning, just for fun.
I used LLVM_TARGETS_TO_BUILD:STRING=all on cmake to include all the
targets (to be able to compare with what Rafael Espindola posted on
LLVM-Dev.)
I compiled 4 versions of clang:
win32 and /O1
win32 and /O2
win64 and /O1
win64 and /O2
/O1 is Minimize Size (configuration MinSizeRel)
/O2 is Maximize Speed (configuration Release)
Everything was compiled using Visual Studio 2008, Windows 7 x64.
I am talking about the LTO (Microsoft calls it Whole Program
Optimization) provided by VS. Being able to compile clang using VS
with Whole Program Optimization on.
Now we need a way to create a new configuration using CMake to enable
LTO compilation with MSVC.
If you describe the process involved on using LTO I could help a bit.
(Is that the same LTO based on LLVM? Does it work on Windows at all? Or
is it the LTO provided by VS?)
I am talking about the LTO (Microsoft calls it Whole Program
Optimization) provided by VS. Being able to compile clang using VS
with Whole Program Optimization on.
ok but if you give /GL to the compiler you need to give /LTCG to the
linker.. how do u do that?
From the second web page you linked:
"The linker invokes link-time code generation if it is passed a module
that was compiled with /GL or an MSIL module (see .netmodule Files as
Linker Input for more information). If you do not explicitly specify
/LTCG when passing /GL or MSIL modules to the linker, the linker will
eventually detect this and restart the link with /LTCG."
Now we need a way to create a new configuration using CMake to enable
LTO compilation with MSVC.
Thank you.
I tested and I was disappointed.. I don't think it is worth adding a
new configuration for LTO using MSVC:
My experience with my projects is similar to yours, that's why I asked
for a test before adding the build option. Unless you do something
really stupid (like not inlining your class accessors) the only effect
of /GL is increasing build time.
clang is slightly faster than MSVC at parsing the non templated Visual
Studio header files.
I ran the test many times on both clang and cl to make sure all header
files were in the cache somewhere because the first time you run it,
your get slower result.
clang is slightly faster than MSVC at parsing the non templated Visual
Studio header files.
I ran the test many times on both clang and cl to make sure all header
files were in the cache somewhere because the first time you run it,
your get slower result.
FYI, 18 months later.. clang is no longer faster than cl.exe, it's a draw!!
I am using a file test.cpp that just include all the Windows/MSVC SDK headers.
I ran the test many many times and I always get 7.2 secs. Strangely
clang.exe and cl.exe (MSVC) take almost exactly the same time to parse
the test file.
(The reason the test went from 5.x sec to 7.2 sec is because it now
includes a lot more .h files).