Performance annotations: add attributes @_noLocks and @_noAllocation

This commit is contained in:
Erik Eckstein
2021-10-21 22:04:27 +02:00
parent 60f3d61031
commit 8229b374b1
16 changed files with 113 additions and 11 deletions

View File

@@ -105,6 +105,12 @@ void SILFunctionBuilder::addFunctionAttributes(
if (Attrs.hasAttribute<SILGenNameAttr>() || Attrs.hasAttribute<CDeclAttr>())
F->setHasCReferences(true);
if (Attrs.hasAttribute<NoLocksAttr>()) {
F->setPerfConstraints(PerformanceConstraints::NoLocks);
} else if (Attrs.hasAttribute<NoAllocationAttr>()) {
F->setPerfConstraints(PerformanceConstraints::NoAllocation);
}
// Validate `@differentiable` attributes by calling `getParameterIndices`.
// This is important for:
// - Skipping invalid `@differentiable` attributes in non-primary files.