diff options
| author | Utkarsh Saxena <usx@google.com> | 2025-11-06 22:02:39 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-06 22:02:39 -0500 |
| commit | 8fca65c65e3aab9bfdb1a3252335a880689a3f61 (patch) | |
| tree | 66330394cbe233e9c888e3bc0dc8b345e50bfb10 /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | |
| parent | f2857c2aded10a7ce9e358f0f55d5eb1a344b9a5 (diff) | |
| download | llvm-8fca65c65e3aab9bfdb1a3252335a880689a3f61.zip llvm-8fca65c65e3aab9bfdb1a3252335a880689a3f61.tar.gz llvm-8fca65c65e3aab9bfdb1a3252335a880689a3f61.tar.bz2 | |
[LifetimeSafety] Optimize loan propagation by separating persistent and block-local origins (#165789)
## Summary
Optimizes the lifetime analysis loan propagation by preventing block-local origins from participating in expensive join operations at block boundaries.
## Problem
The lifetime analysis currently performs join operations on all origins at every block boundary. However, many origins are block-local: they exist only to propagate loans between persistent origins across temporary declarations and expressions within a single block. Including them in joins is unnecessary and expensive.
## Solution
This PR classifies origins into two categories:
- **Persistent origins**: referenced in multiple basic blocks, must participate in joins
- **Block-local origins**: confined to a single block, can be discarded at block boundaries
### Implementation
1. **Pre-pass** (`computePersistentOrigins`): Analyzes all facts in the CFG to identify which origins appear in multiple blocks
2. **Split lattice**: Maintains two separate `OriginLoanMap`s:
- `PersistentOrigins`: participates in join operations
- `BlockLocalOrigins`: used during block execution, discarded at boundaries
3. **Optimized join**: Only merges persistent origins; block-local map is reset to empty
### Benefits
- Significantly reduces join complexity, especially in functions with many temporary locals
- Performance scales with the ratio of temporary to persistent origins
- Correctness preserved: block-local loan propagation still works within blocks
Fixes: https://github.com/llvm/llvm-project/issues/165780
Fixes: https://github.com/llvm/llvm-project/issues/164625. It brings down regression from **150% to 2%**.
---
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp')
0 files changed, 0 insertions, 0 deletions
