SIL: Lower lifetime dependencies when lowering function types.

Map the lifetime dependencies described in terms of the formal AST-level parameters
to the correct parameter(s) in the lowered SIL function type. There can be 0, 1,
or many SIL parameters per formal parameter because of tuple exploding. Also,
record which dependencies are on addressable parameters (meaning that the dependency
includes not only the value of the parameter, but its specific memory location).
This commit is contained in:
Joe Groff
2025-02-12 20:25:32 -08:00
parent 3ce2449b8d
commit c65475628f
10 changed files with 381 additions and 57 deletions

View File

@@ -9106,13 +9106,16 @@ ModuleFile::maybeReadLifetimeDependence(unsigned numParams) {
bool isImmortal;
bool hasInheritLifetimeParamIndices;
bool hasScopeLifetimeParamIndices;
bool hasAddressableParamIndices;
ArrayRef<uint64_t> lifetimeDependenceData;
LifetimeDependenceLayout::readRecord(
scratch, targetIndex, isImmortal, hasInheritLifetimeParamIndices,
hasScopeLifetimeParamIndices, lifetimeDependenceData);
hasScopeLifetimeParamIndices, hasAddressableParamIndices,
lifetimeDependenceData);
SmallBitVector inheritLifetimeParamIndices(numParams, false);
SmallBitVector scopeLifetimeParamIndices(numParams, false);
SmallBitVector addressableParamIndices(numParams, false);
unsigned startIndex = 0;
auto pushData = [&](SmallBitVector &bits) {
@@ -9130,6 +9133,9 @@ ModuleFile::maybeReadLifetimeDependence(unsigned numParams) {
if (hasScopeLifetimeParamIndices) {
pushData(scopeLifetimeParamIndices);
}
if (hasAddressableParamIndices) {
pushData(addressableParamIndices);
}
ASTContext &ctx = getContext();
return LifetimeDependenceInfo(
@@ -9139,5 +9145,8 @@ ModuleFile::maybeReadLifetimeDependence(unsigned numParams) {
hasScopeLifetimeParamIndices
? IndexSubset::get(ctx, scopeLifetimeParamIndices)
: nullptr,
targetIndex, isImmortal);
targetIndex, isImmortal,
hasAddressableParamIndices
? IndexSubset::get(ctx, addressableParamIndices)
: nullptr);
}