Skip to content

cmd/compile: stack offsets should not need spilling #22947

@mdempsky

Description

@mdempsky

Compiling the function below currently produces a register spill:

package p

type T [100]int

func f(p *T) {
    if g() {
            h(0, *p)
    } else {
            g()
            h(1, *p)
    }
}

func g() bool
func h(int, T)

This is because h(1, *p) is compiled to OINDREGSP(8) = *p, which is represented in SSA as Move(OffPtr(8, SP), p).

OffPtr(8, SP) is trivially rematerialized on x86 with LEA $8(SP), but we're currently lowering OffPtr to ADDQconst, which is marked as non-rematerializeable because it clobbers flags (unlike LEAQ).

Distilled from #22558.

/cc @randall77

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions