SILGen: Implement 'complete' unavailable decl optimization.

Avoid SIL lowering for declarations marked unavailable when
`-unavailable-decl-optimiation=complete` is specified.

Part of rdar://106674022
This commit is contained in:
Allan Shortlidge
2023-03-09 23:52:43 -08:00
parent 7d1d7a35bb
commit ada0f09615
7 changed files with 268 additions and 4 deletions

View File

@@ -1078,8 +1078,22 @@ namespace Lowering {
/// Determine whether the given class will be allocated/deallocated using the
/// Objective-C runtime, i.e., +alloc and -dealloc.
LLVM_LIBRARY_VISIBILITY bool usesObjCAllocator(ClassDecl *theClass);
/// Returns true if SIL/IR lowering for the given declaration should be skipped.
/// A declaration may not require lowering if, for example, it is annotated as
/// unavailable and optimization settings allow it to be omitted.
LLVM_LIBRARY_VISIBILITY bool shouldSkipLowering(Decl *D);
} // namespace Lowering
/// Apply the given function to each ABI member of \c D skipping the members
/// that should be skipped according to \c shouldSkipLowering()
template <typename F>
void forEachMemberToLower(IterableDeclContext *D, F &&f) {
for (auto *member : D->getABIMembers()) {
if (!Lowering::shouldSkipLowering(member))
f(member);
}
}
} // namespace swift
#endif