Thursday, May 26, 2022 [Tweets] [Favorites]

Swift @_assemblyVision

Karl (via Ron Avitzur):

There is a super-hidden feature in the compiler which gives you insight in to all kinds of optimisation decisions: such as the cost-benefit calculations for inlining, where exclusivity is enforced, where ARC operations happen, which generic specialisations get generated and which calls get devirtualised.

[…]

To use it, add the @_assemblyVision attribute to a function, and build in release mode (or @_semantics("optremark") on a pre-5.6 compiler.

Michael_Gottesman:

The first is called opt remarks. “opt remarks” shows the decisions the optimizer is making (e.x.: did I specialize this, did I inline this/etc).

The second is something that I invented called “Assembly Vision”. This is the thing that is telling you where the ARC/exclusivity checks/runtime casts. Assembly Vision also enables the other form of normal opt-remarks since that information can be useful when determining where/why ARC is there. The idea is to make it so that instead of having to read the assembly, one can have vision on approximately where these calls are so you don’t have to read the assembly yourself.

[…]

The concept came from me trying to automate how I optimize Swift code as a compiler engineer so that other engineers who aren’t compiler people can be just as effective.

This looks incredibly useful.

Previously:

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment