DFAJumpThreading enabled by default causes huge compile-time regression at -O2 (under 1 s -> over 90 min)
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
While upgrading openembedded-core to clang 23.1.0 I noticed that dovecot 2.4.4's src/lib-json/test-json-generator.c no longer finishes compiling at -O2. clang 22.1.8 compiles the file in 0.8 seconds.
With 23.1.0 I killed the compile after 90 minutes. The compiler sits at 100% CPU with flat memory (~62 MB) the whole time. Current main (faf31b04449c, assertions enabled, none fire) behaves the same. -O1 is not affected.
I bisected llvmorg-22.1.8..llvmorg-23.1.0 and it points at ebb9d0eecb19 (Reapply "[DFAJumpThreading] Enable DFAJumpThread by
default.", #169183). Adding `-mllvm -enable-dfa-jump-thread=false` brings the compile back to about 1 second. The source file is mostly switch based state machine loops, which I understand is what this pass transforms.
Reproduce with the attached preprocessed source:
```
clang --target=x86_64-linux-gnu -O2 -std=gnu11 -w -c test-json-generator.i
```
or with the IR extracted from it (generated with clang 23.1.0
-O2 -emit-llvm, llc alone reproduces the slow part):
```
llc -O2 fn-test_json_generate_buffer.ll -o /dev/null # ~8 min
llc -O2 reduced-strict.ll -o /dev/null # 236 lines, ~2 min
```
Stack samples taken while it was stuck are attached (clang-hang-samples.txt), most of the time is inside ScalarEvolution
functions called from the loop passes.
[dovecot-clang23-compile-time-repro.zip](https://github.com/user-attachments/files/31858317/dovecot-clang23-compile-time-repro.zip)
Please let me know if you need more details.
Contributor guide
Research direction
Start by running the provided clang command on test-json-generator.i, then compare it with the -mllvm -enable-dfa-jump-thread=false case and the reduced llc reproducer reduced-strict.ll. Trace the DFAJumpThreading and ScalarEvolution activity shown by the stack samples. Done means the reproducer no longer causes the severe -O2 compile-time regression while preserving the intended pass behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100