Open mikulas-patocka opened 2 months ago
We are spending the vast majority of our time in AnalysisBasedWarnings
(runUninitializedVariablesAnalysis()
specifically). Those are enabled by default with -Wmost
which is included in -Wall
; however, that behavior hasn't changed in a long time, so I'm not certain why it's slowed down so much recently (this is why -Wall
made it twice as bad in earlier versions of Clang though).
Here are some timing tests I did on Windows:
PS F:\source\llvm-project> Measure-Command{.\llvm\out\build\x64-Debug\bin\clang.exe --target=x86_64-pc-linux -c -x c "c:\Users\aballman\OneDrive - Intel Corporation\Desktop\ipret.e"}
Days : 0
Hours : 0
Minutes : 1
Seconds : 6
Milliseconds : 766
Ticks : 667660246
TotalDays : 0.000772754914351852
TotalHours : 0.0185461179444444
TotalMinutes : 1.11276707666667
TotalSeconds : 66.7660246
TotalMilliseconds : 66766.0246
PS F:\source\llvm-project> Measure-Command{.\llvm\out\build\x64-Debug\bin\clang.exe --target=x86_64-pc-linux -Wall -Wno-uninitialized -c -x c "c:\Users\aballman\OneDrive - Intel Corporation\Desktop\ipret.e"}
Days : 0
Hours : 0
Minutes : 1
Seconds : 9
Milliseconds : 712
Ticks : 697128500
TotalDays : 0.000806861689814815
TotalHours : 0.0193646805555556
TotalMinutes : 1.16188083333333
TotalSeconds : 69.71285
TotalMilliseconds : 69712.85
(I did not let the non--Wall
execution run to completion, I gave up after five minutes.)
So -Wuninitialized
definitely seems like it contributes the most to the issue.
I explained it badly - it is not a regression between version 18 and 20. If I try to compile the file ipret.e with clang-18 on the same machine, I get 17 minutes without -Wall and 49 minutes with -Wall. So it seems that the -Wall slowdown was always there.
Ah, thank you for the update, that makes so much more sense to me!
Despite not being a new issue, this is still worth investigating how we can improve; that much of a compile time performance hit is hard to swallow (it would normally be enough to remove this from -Wall
which I would really like to avoid as an outcome given the security benefits of that particular diagnostic being enabled by default).
CC @gribozavr @ymand @sgatev as CFG code owners
BTW. when I compare performance of the binary generated by clang-18, clang-20 and gcc-14, I get: clang-18: 17.9s clang-20: 20.1s gcc-14: 18.8s
So, clang-20 compiles faster than clang-18, but it produces slower code. Should I create another bug report for this regression?
Should I create another bug report for this regression?
Yeah, it's worth filing an issue over. FWIW, it would be helpful if you were able to give a small reproducer instead of a whole program, if possible!
OK. I made a simple reproducer and submitted it here: https://github.com/llvm/llvm-project/issues/106846
My c++ config is "cpp": "cd $dir && g++ -std=c++17 -g-Wall -lm -o $fileNameWithoutExt && $dir$fileNameWithoutExt" when i try to run using the keyboard shortcut/ run code my terminal says unrecognized debug output level '-Wall' mean when i run c++
Download an example file from: http://www.jikos.cz/~mikulas/testcases/clang/ipret.e (the file comes from Ajla, https://www.ajla-lang.cz/ )
If you compile it with $ time clang-20 -c -x c ipret.e -O2 it takes 23 seconds
If you compile it with $ time clang-20 -c -x c ipret.e -O2 -Wall it takes 31 minutes
I tested it with clang-20 from Debian Sid. On clang-18 and older, it takes a long time to compile the file even without -Wall, but the -Wall switch makes it twice worse.
Also, note that while clang-19 and clang-20 compile faster than clang-18, the code generated by clang-19 and clang-20 for this file is inferior to the code generated by clang-18 and older.