[cfe-users] UBSan: very long compile times for clang++ with -fsanitize=undefined, unsigned-integer-overflow
Schlottke-Lakemper, Michael via cfe-users
cfe-users at lists.llvm.org
Mon Nov 23 08:02:07 PST 2015
When compiling our simulation tool with the undefined behavior sanitizer, I noticed that some files take much longer to compile - I am talking about a 5x-250x increase:
file1 (zfsdgblock_inst_3d_acousticperturb.cpp): 8.5s vs 41.3s (4.8x)
file2 (zfsfvparticle.cpp): 9.5s vs 114.8s (12.1x)
file3 (zfscartesiangrid_inst_fv.cpp): 18.4s vs 100.8s (5.4x)
file4 (zfsfvbndrycnd3d.cpp): 19.6s vs [stopped after 1.5 hours of compilation]
For reference, I’ve added the full compilation command I used below. In the UBSan invocation, the only change is the addition of “-fsanitize=undefined,unsigned-integer-overflow”.
Even though the files in question are relatively large (5k-20k lines), I am wondering if this is expected. Is there anything I can do to significantly speed up compilation while still getting reasonable runtime performance? I found out that e.g. using -O0 instead of -O3 significantly reduces the compile time for file4 with ubsan to 17.1s, while -O1 already takes > 15 mins.
Here is the compilation command I used for file2 (the other files were compiled using the exact same flags):
/pds/opt/llvm/bin/clang++ -O3 -DNDEBUG -fvectorize -fslp-vectorize -DCOMPILER_ATTRIBUTES -DUSE_RESTRICT -march=native -mtune=native -std=c++11 -stdlib=libc++ -Wall -Wextra -pedantic -Wshadow -Wfloat-equal -Wcast-align -Wfloat-equal -Wdisabled-optimization -Wformat=2 -Winvalid-pch -Winit-self -Wmissing-include-dirs -Wredundant-decls -Wpacked -Wpointer-arith -Wstack-protector -Wswitch-default -Wwrite-strings -Wno-type-safety -Werror -Wunused -Wno-infinite-recursion -Isrc -isystem /pds/opt/fftw/include -isystem /pds/opt/parallel-netcdf/include -isystem /pds/opt/openmpi/include -MMD -MT src/CMakeFiles/zfs.dir/zfsfvparticle.cpp.o -MF src/CMakeFiles/zfs.dir/zfsfvparticle.cpp.o.d -o src/CMakeFiles/zfs.dir/zfsfvparticle.cpp.o -c src/zfsfvparticle.cpp
"-DCOMPILER_ATTRIBUTES -DUSE_RESTRICT” just enables compiler attributes and the use of __restrict in the preprocessor stage.
More information about the cfe-users