[LifetimeSafety] Investigate large-compile time regressions with -fexperimental-lifetime-safety-tu-analysis
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Recent profiling shows that the experimental translation unit analysis for Lifetime Safety causes a **10-50%** compile-time regression.
To begin with we should be profiling this analysis in TU-analysis mode in llvm-compile-time-tracker.com
This will build LLVM without modules. If we have significant regressions, we should already have good starting point to optimise.
### Idea 1: Avoid building CallGraph for functions from .pcm files to reduce TU analysis overhead
We suspect that this bottleneck is primarily due to the CallGraph construction triggering the expensive deserialization of function bodies from Clang modules (.pcm files).
To resolve this, the CallGraph construction must be optimized to skip building nodes for functions defined within .pcm files. This can be achieved by modifying the `RecursiveASTVisitor` in `clang/Analysis/CallGraph.h` to identify and ignore declarations that originate from imported modules, ensuring the analysis remains focused on the local translation unit without incurring global deserialization costs.
Contributor guide
Assessment
This issue has not been assessed yet.