mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Swift SIL: escape effects for function arguments.
Store a list of argument effects in a function, which specify if and how arguments escape. Such effects can be specified in the Swift source code (for details see docs/ReferenceGuides/UnderscoredAttributes.md) or derived in an optimization pass. For details see the documentation in SwiftCompilerSources/Sources/SIL/Effects.swift.
This commit is contained in:
@@ -2944,6 +2944,36 @@ void SILFunction::print(SILPrintContext &PrintCtx) const {
|
||||
else if (getEffectsKind() == EffectsKind::ReleaseNone)
|
||||
OS << "[releasenone] ";
|
||||
|
||||
llvm::SmallVector<int, 8> definedEscapesIndices;
|
||||
llvm::SmallVector<int, 8> escapesIndices;
|
||||
visitArgEffects([&](int effectIdx, bool isDerived, ArgEffectKind kind) {
|
||||
if (kind == ArgEffectKind::Escape) {
|
||||
if (isDerived) {
|
||||
escapesIndices.push_back(effectIdx);
|
||||
} else {
|
||||
definedEscapesIndices.push_back(effectIdx);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!definedEscapesIndices.empty()) {
|
||||
OS << "[defined_escapes ";
|
||||
for (int effectIdx : definedEscapesIndices) {
|
||||
if (effectIdx > 0)
|
||||
OS << ", ";
|
||||
writeEffect(OS, effectIdx);
|
||||
}
|
||||
OS << "] ";
|
||||
}
|
||||
if (!escapesIndices.empty()) {
|
||||
OS << "[escapes ";
|
||||
for (int effectIdx : escapesIndices) {
|
||||
if (effectIdx > 0)
|
||||
OS << ", ";
|
||||
writeEffect(OS, effectIdx);
|
||||
}
|
||||
OS << "] ";
|
||||
}
|
||||
|
||||
if (auto *replacedFun = getDynamicallyReplacedFunction()) {
|
||||
OS << "[dynamic_replacement_for \"";
|
||||
OS << replacedFun->getName();
|
||||
|
||||
Reference in New Issue
Block a user