Skip to content

cmd/compile: match Aux/AuxInt more strictly in rewriting rules #44824

Open
@cherrymui

Description

@cherrymui

Currently, in a rewriting rule, on the LHS if a value's Aux or AuxInt is not specified, it is ignored by the rule matcher. This is error-prone. One example is a rule introduced in CL https://go-review.googlesource.com/c/go/+/280456, where the ignored Aux/AuxInt causes miscompilation (#44823).

To make it less error-prone, maybe we want the rule matcher to require Aux/AuxInt to be always specified on the LHS (using _ to explicitly ignore)? Or maybe we want it to match the zero value if not specified?

Discussion from CL https://go-review.googlesource.com/c/go/+/299289:
@randall77 :

maybe we want the rule matcher require Aux/AuxInt to be always specified on the LHS

Yes please. Now with strongly typed rules it should be fairly straightforward.

Speaking of which, I was hoping at some point to get rid of the distinction between Aux and AuxInt. Now that everything is typed, we can just have Aux types for everything, and some of them might be {Sym, int32} pairs or whatever. Value.Aux and Value.AuxInt would just be the storage for those aux values.
(Which should be great for rewrite rules. I'm not sure how great/terrible it would be for other compiler passes.)

@josharian :

the value of auxint is that it avoids an alloc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions