Merge pull request #80577 from atrick/addressable-escape

Fix GenericSpecializer for addressable parameters.
This commit is contained in:
Andrew Trick
2025-04-08 12:44:28 -07:00
committed by GitHub
12 changed files with 221 additions and 83 deletions

View File

@@ -289,11 +289,6 @@ public:
&& scopeLifetimeParamIndices->contains(index);
}
bool checkAddressable(int index) const {
return hasAddressableParamIndices()
&& getAddressableIndices()->contains(index);
}
std::string getString() const;
void Profile(llvm::FoldingSetNodeID &ID) const;
void getConcatenatedData(SmallVectorImpl<bool> &concatenatedData) const;

View File

@@ -5649,6 +5649,13 @@ public:
return getLifetimeDependenceFor(getNumParameters());
}
/// Return true of the specified parameter is addressable based on its type
/// lowering in 'caller's context. This includes @_addressableForDependencies
/// parameter types.
///
/// Defined in SILType.cpp.
bool isAddressable(unsigned paramIdx, SILFunction *caller);
/// Returns true if the function type stores a Clang type that cannot
/// be derived from its Swift type. Returns false otherwise, including if
/// the function type is not @convention(c) or @convention(block).

View File

@@ -641,6 +641,10 @@ public:
return getArgumentParameterInfo(oper).hasOption(SILParameterInfo::Sending);
}
/// Return true if 'operand' is addressable after type substitution in the
/// caller's context.
bool isAddressable(const Operand &operand) const;
static ApplySite getFromOpaqueValue(void *p) { return ApplySite(p); }
friend bool operator==(ApplySite lhs, ApplySite rhs) {

View File

@@ -84,7 +84,8 @@ class ReabstractionInfo {
/// specializer.
bool ConvertIndirectToDirect = true;
/// If true, drop unused arguments.
/// If true, drop unused arguments. Dropping unused arguments is a
/// prerequisite before promoting an indirect argument to a direct argument.
/// See `droppedArguments`.
bool dropUnusedArguments = false;
@@ -204,7 +205,7 @@ public:
ReabstractionInfo(ModuleDecl *targetModule, bool isModuleWholeModule,
ApplySite Apply, SILFunction *Callee,
SubstitutionMap ParamSubs, SerializedKind_t Serialized,
bool ConvertIndirectToDirect, bool dropMetatypeArgs,
bool ConvertIndirectToDirect, bool dropUnusedArguments,
OptRemark::Emitter *ORE = nullptr);
/// Constructs the ReabstractionInfo for generic function \p Callee with