Member-only story
COW2LLVM: The isKnownUniquelyReferenced Deep-Dive
Demystify the Swift Compiler, the engine behind copy-on-write
I mostly post to Substack these days. Subscribe now to receive non-paywalled, ludicrously in-depth articles on iOS, Swift, and indie projects every 2 weeks.
The copy-on-write (a.k.a. CoW or 🐮) optimisation is the quintessential under-the-hood interview question for iOS engineers.
Today, we’re going on a quest to discover how this optimisation really works. I’m taking you on a journey deep into the enigmatic source code of the Swift compiler.
And, of course, I’m going to be referring to copy-on-write as 🐮 throughout.
Roadmap
- What is 🐮?
- Implementing 🐮
- The Swift Standard Library
- Builtins
- (Interlude) The Swift Compiler
- The Abstract Syntax Tree
- Swift Intermediate Language
- LLVM Intermediate Representation
- The Swift Runtime
- SwiftShims
- The
isKnownUniquelyReferencedMeme - Conclusion

