Skip to content

Commit 725aa5b5f broke dead code elimination #7622

@artem-anisimov-0x7f

Description

@artem-anisimov-0x7f

Commit 725aa5b has replaced the function callBackToMethodValue() with a plain modelValue.MethodByName(string(cbName)), which makes it impossible for the go linker to run dead code elimination.

The comment on callBackToMethodValue() clearly describes why that function was important for the DCE:

// This unrolling is needed to show to the compiler the exact set of methods
// that can be used on the modelType.
// Prior to go1.22 any use of MethodByName would cause the linker to
// abandon dead code elimination for the entire binary.
// As of go1.22 the compiler supports one special case of a string constant
// being passed to MethodByName. For enterprise customers or those building
// large binaries, this gives a significant reduction in binary size.
// https://github.com/golang/go/issues/62257

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions