mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILFunction: add getMemoryBehavior
This retrieves the side effect information from the function effects.
This commit is contained in:
@@ -146,6 +146,7 @@ static FunctionWriteFn writeFunction = nullptr;
|
||||
static FunctionParseFn parseFunction = nullptr;
|
||||
static FunctionCopyEffectsFn copyEffectsFunction = nullptr;
|
||||
static FunctionGetEffectInfoFn getEffectInfoFunction = nullptr;
|
||||
static FunctionGetMemBehviorFn getMemBehvaiorFunction = nullptr;
|
||||
|
||||
SILFunction::SILFunction(
|
||||
SILModule &Module, SILLinkage Linkage, StringRef Name,
|
||||
@@ -932,7 +933,8 @@ void Function_register(SwiftMetatype metatype,
|
||||
FunctionRegisterFn initFn, FunctionRegisterFn destroyFn,
|
||||
FunctionWriteFn writeFn, FunctionParseFn parseFn,
|
||||
FunctionCopyEffectsFn copyEffectsFn,
|
||||
FunctionGetEffectInfoFn effectInfoFn) {
|
||||
FunctionGetEffectInfoFn effectInfoFn,
|
||||
FunctionGetMemBehviorFn memBehaviorFn) {
|
||||
functionMetatype = metatype;
|
||||
initFunction = initFn;
|
||||
destroyFunction = destroyFn;
|
||||
@@ -940,6 +942,7 @@ void Function_register(SwiftMetatype metatype,
|
||||
parseFunction = parseFn;
|
||||
copyEffectsFunction = copyEffectsFn;
|
||||
getEffectInfoFunction = effectInfoFn;
|
||||
getMemBehvaiorFunction = memBehaviorFn;
|
||||
}
|
||||
|
||||
std::pair<const char *, int> SILFunction::
|
||||
@@ -1020,6 +1023,14 @@ visitArgEffects(std::function<void(int, int, bool)> c) const {
|
||||
}
|
||||
}
|
||||
|
||||
SILInstruction::MemoryBehavior SILFunction::getMemoryBehavior(bool observeRetains) {
|
||||
if (!getMemBehvaiorFunction)
|
||||
return SILInstruction::MemoryBehavior::MayHaveSideEffects;
|
||||
|
||||
auto b = getMemBehvaiorFunction({this}, observeRetains);
|
||||
return (SILInstruction::MemoryBehavior)b;
|
||||
}
|
||||
|
||||
SILFunction *SILFunction::getFunction(SILDeclRef ref, SILModule &M) {
|
||||
swift::Lowering::SILGenModule SILGenModule(M, ref.getModuleContext());
|
||||
return SILGenModule.getFunction(ref, swift::NotForDefinition);
|
||||
|
||||
Reference in New Issue
Block a user