llvm / llvm/llvm-project

[LifetimeSafety] Investigate large-compile time regressions with -fexperimental-lifetime-safety-tu-analysis

Open
#200,170 6 comments 0 reactions 1 assignee Claimed by @aeft View on GitHub
clang:temporal-safety slow-compile
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.