Golang defer in ASM (2025-09-02)

This is the beginning of an exploration of what Golang’s defer keyword does to the final ASM produced by our Go compiler. We are using Godbolt.org for this.

Without defer:

package p
import "fmt"

func square(x int) int {
    fmt.Println("Good Bye!")
    return x * x
}

With defer

package p
import "fmt"

func square(x int) int {
    defer fmt.Println("Good Bye!")
    return x * x
}