Skip to content

Commit 1a1a8ec

Browse files
committed
Make _resultDependsOnSelf available on SILFunction
1 parent d3e921d commit 1a1a8ec

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

include/swift/SIL/SILArgument.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ class SILFunctionArgument : public SILArgument {
366366
ValueOwnershipKind ownershipKind, const ValueDecl *decl = nullptr,
367367
bool isNoImplicitCopy = false,
368368
LifetimeAnnotation lifetimeAnnotation = LifetimeAnnotation::None,
369-
bool isCapture = false,
370-
bool isParameterPack = false, bool hasResultDependsOn = false)
369+
bool isCapture = false, bool isParameterPack = false,
370+
bool hasResultDependsOn = false)
371371
: SILArgument(ValueKind::SILFunctionArgument, parentBlock, type,
372372
ownershipKind, decl) {
373373
sharedUInt32().SILFunctionArgument.noImplicitCopy = isNoImplicitCopy;

include/swift/SIL/SILFunction.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ class SILFunction
443443
/// lifetime-dependence on an argument.
444444
unsigned HasUnsafeNonEscapableResult : 1;
445445

446+
unsigned HasResultDependsOnSelf : 1;
447+
446448
static void
447449
validateSubclassScope(SubclassScope scope, IsThunk_t isThunk,
448450
const GenericSpecializationInformation *genericInfo) {
@@ -727,6 +729,11 @@ class SILFunction
727729
HasUnsafeNonEscapableResult = value;
728730
}
729731

732+
bool hasResultDependsOnSelf() const { return HasResultDependsOnSelf; }
733+
734+
void setHasResultDependsOnSelf(bool flag = true) {
735+
HasResultDependsOnSelf = flag;
736+
}
730737
/// Returns true if this is a reabstraction thunk of escaping function type
731738
/// whose single argument is a potentially non-escaping closure. i.e. the
732739
/// thunks' function argument may itself have @inout_aliasable parameters.

lib/SIL/IR/SILFunction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ void SILFunction::init(
209209
this->ForceEnableLexicalLifetimes = DoNotForceEnableLexicalLifetimes;
210210
this->UseStackForPackMetadata = DoUseStackForPackMetadata;
211211
this->HasUnsafeNonEscapableResult = false;
212+
this->HasResultDependsOnSelf = false;
212213
this->stackProtection = false;
213214
this->Inlined = false;
214215
this->Zombie = false;

lib/SIL/IR/SILFunctionBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ void SILFunctionBuilder::addFunctionAttributes(
209209
F->setHasUnsafeNonEscapableResult(true);
210210
}
211211

212+
if (Attrs.hasAttribute<ResultDependsOnSelfAttr>()) {
213+
F->setHasResultDependsOnSelf();
214+
}
215+
212216
// Validate `@differentiable` attributes by calling `getParameterIndices`.
213217
// This is important for:
214218
// - Skipping invalid `@differentiable` attributes in non-primary files.

lib/SIL/IR/SILPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,10 @@ void SILFunction::print(SILPrintContext &PrintCtx) const {
34163416
if (needsStackProtection())
34173417
OS << "[stack_protection] ";
34183418

3419+
if (hasResultDependsOnSelf()) {
3420+
OS << "[_resultDependsOnSelf] ";
3421+
}
3422+
34193423
llvm::DenseMap<CanType, Identifier> sugaredTypeNames;
34203424
printSILFunctionNameAndType(OS, this, sugaredTypeNames, &PrintCtx);
34213425

0 commit comments

Comments
 (0)