Compilation GCC_GENERATE_DEBUGGING_SYMBOLS The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all
Source Optimization In-Out Parameters –Swift Programming Language “An inout parameter has a value that is passed in to the function, is modified by the function, and is passed back out of the function to replace the original value.” func core(block: inout Array)
Source Optimization Inlining • Automatic inlining (SIL, LLVM) • Inline all the things with @inline(__always) • Force inlining with @_transparent • Public interface @_inlineable
Source Optimization Inlining • Automatic inlining (SIL, LLVM) • Inline all the things with @inline(__always) • Force inlining with @_transparent • Public interface @_inlineable • Be careful with ABI and public API
–who knows “Generic code enables you to write flexible, reusable functions and types that can work with any type, subject to requirements that you define.”
Generics & Optimization • Automatic specialization • in the same module • otherwise use @_specialize(exported: true, where T == Int) • Whole Module Optimization won’t help
Generics & Optimization • Automatic specialization • in the same module • otherwise use @_specialize(exported: true, where T == Int) • Whole Module Optimization won’t help • Sometimes it won’t optimize for the same module
Generics & Optimization • Automatic specialization • in the same module • otherwise use @_specialize(exported: true, where T == Int) • Whole Module Optimization won’t help • Sometimes it won’t optimize for the same module • Avoid generics in public API