mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #79758 from atrick/addressable-deps
Support enforcement of '@'_addressable under -enable-address-dependencies
This commit is contained in:
@@ -300,6 +300,11 @@ 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;
|
||||
|
||||
@@ -331,6 +331,10 @@ public:
|
||||
/// optimizer.
|
||||
bool UseAggressiveReg2MemForCodeSize = true;
|
||||
|
||||
/// Enable enforcement of lifetime dependencies on addressable arguments.
|
||||
/// Temporarily used to bootstrap the AddressableParameters feature.
|
||||
bool EnableAddressDependencies = false;
|
||||
|
||||
SILOptions() {}
|
||||
|
||||
/// Return a hash code of any components from these options that should
|
||||
|
||||
@@ -1489,6 +1489,9 @@ def platform_availability_inheritance_map_path
|
||||
: Separate<["-"], "platform-availability-inheritance-map-path">, MetaVarName<"<path>">,
|
||||
HelpText<"Path of the platform inheritance platform map">;
|
||||
|
||||
def enable_address_dependencies : Flag<["-"], "enable-address-dependencies">,
|
||||
HelpText<"Enable enforcement of lifetime dependencies on addressable values.">;
|
||||
|
||||
} // end let Flags = [FrontendOption, NoDriverOption, HelpHidden]
|
||||
|
||||
def disable_experimental_parser_round_trip : Flag<["-"],
|
||||
|
||||
@@ -156,6 +156,7 @@ struct BridgedYieldInfoArray {
|
||||
struct BridgedLifetimeDependenceInfo {
|
||||
swift::IndexSubset *_Nullable inheritLifetimeParamIndices;
|
||||
swift::IndexSubset *_Nullable scopeLifetimeParamIndices;
|
||||
swift::IndexSubset *_Nullable addressableParamIndices;
|
||||
SwiftUInt targetIndex;
|
||||
bool immortal;
|
||||
|
||||
@@ -164,6 +165,7 @@ struct BridgedLifetimeDependenceInfo {
|
||||
BRIDGED_INLINE bool empty() const;
|
||||
BRIDGED_INLINE bool checkInherit(SwiftInt index) const;
|
||||
BRIDGED_INLINE bool checkScope(SwiftInt index) const;
|
||||
BRIDGED_INLINE bool checkAddressable(SwiftInt index) const;
|
||||
BRIDGED_INLINE SwiftInt getTargetIndex() const;
|
||||
|
||||
BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
|
||||
|
||||
@@ -146,6 +146,7 @@ BridgedParameterInfo BridgedParameterInfoArray::at(SwiftInt parameterIndex) cons
|
||||
BridgedLifetimeDependenceInfo::BridgedLifetimeDependenceInfo(swift::LifetimeDependenceInfo info)
|
||||
: inheritLifetimeParamIndices(info.getInheritIndices()),
|
||||
scopeLifetimeParamIndices(info.getScopeIndices()),
|
||||
addressableParamIndices(info.getAddressableIndices()),
|
||||
targetIndex(info.getTargetIndex()), immortal(info.isImmortal()) {}
|
||||
|
||||
SwiftInt BridgedLifetimeDependenceInfoArray::count() const {
|
||||
@@ -172,6 +173,10 @@ bool BridgedLifetimeDependenceInfo::checkScope(SwiftInt index) const {
|
||||
scopeLifetimeParamIndices->contains(index);
|
||||
}
|
||||
|
||||
bool BridgedLifetimeDependenceInfo::checkAddressable(SwiftInt index) const {
|
||||
return addressableParamIndices && addressableParamIndices->contains(index);
|
||||
}
|
||||
|
||||
SwiftInt BridgedLifetimeDependenceInfo::getTargetIndex() const {
|
||||
return targetIndex;
|
||||
}
|
||||
|
||||
@@ -382,6 +382,9 @@ struct BridgedPassContext {
|
||||
bool enableSimplificationFor(BridgedInstruction inst) const;
|
||||
BRIDGED_INLINE bool enableWMORequiredDiagnostics() const;
|
||||
|
||||
// Temporary for AddressableParameters Bootstrapping.
|
||||
BRIDGED_INLINE bool enableAddressDependencies() const;
|
||||
|
||||
// Closure specializer
|
||||
SWIFT_IMPORT_UNSAFE BridgedFunction ClosureSpecializer_createEmptyFunctionWithSpecializedSignature(BridgedStringRef specializedName,
|
||||
const BridgedParameterInfo * _Nullable specializedBridgedParams,
|
||||
|
||||
@@ -573,6 +573,11 @@ bool BridgedPassContext::enableWMORequiredDiagnostics() const {
|
||||
return mod->getOptions().EnableWMORequiredDiagnostics;
|
||||
}
|
||||
|
||||
bool BridgedPassContext::enableAddressDependencies() const {
|
||||
swift::SILModule *mod = invocation->getPassManager()->getModule();
|
||||
return mod->getOptions().EnableAddressDependencies;
|
||||
}
|
||||
|
||||
static_assert((int)BridgedPassContext::SILStage::Raw == (int)swift::SILStage::Raw);
|
||||
static_assert((int)BridgedPassContext::SILStage::Canonical == (int)swift::SILStage::Canonical);
|
||||
static_assert((int)BridgedPassContext::SILStage::Lowered == (int)swift::SILStage::Lowered);
|
||||
|
||||
Reference in New Issue
Block a user