PSA: Compiler optimisation remarks

You are actually looking at two different features.

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 proper way to invoke this is to put the @_assemblyVision attribute on a nominal type or a function. I believe that it is on trunk/5.6 (it might be in 5.5, I don't remember).

The reason why I haven't made a bigger deal about it is I want to extend it further and make it more powerful before I really shouted about it.

I hope it is useful for you! 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. The best way to see it in practice is look at the test cases that I have committed into tree (I posted some links to it below). Another thing to keep in mind is that -O gives worse remarks due to function signature optimization messing with some stuff. -Osize though works really well.

16 Likes