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:
Erik Eckstein
2021-09-24 10:22:31 +02:00
parent 72fc4e3c95
commit f09dfc93a9
21 changed files with 836 additions and 35 deletions

View File

@@ -150,8 +150,9 @@ class SILFunction
: public llvm::ilist_node<SILFunction>, public SILAllocated<SILFunction>,
public SwiftObjectHeader {
static SwiftMetatype registeredMetatype;
private:
void *libswiftSpecificData[1];
public:
using BlockListType = llvm::iplist<SILBasicBlock>;
@@ -418,10 +419,6 @@ private:
void setHasOwnership(bool newValue) { HasOwnership = newValue; }
public:
static void registerBridgedMetatype(SwiftMetatype metatype) {
registeredMetatype = metatype;
}
~SILFunction();
SILModule &getModule() const { return Module; }
@@ -943,6 +940,19 @@ public:
EffectsKindAttr = unsigned(E);
}
enum class ArgEffectKind {
Unknown,
Escape
};
std::pair<const char *, int> parseEffects(StringRef attrs, bool fromSIL,
bool isDerived,
ArrayRef<StringRef> paramNames);
void writeEffect(llvm::raw_ostream &OS, int effectIdx) const;
void copyEffects(SILFunction *from);
bool hasArgumentEffects() const;
void visitArgEffects(std::function<void(int, bool, ArgEffectKind)> c) const;
Purpose getSpecialPurpose() const { return specialPurpose; }
/// Get this function's global_init attribute.