Skip to content

cmd/compile: //go:norace should prohibit inlining into functions that will be instrumented #24651

@mdempsky

Description

@mdempsky

Currently, compiling this package:

package p

func F(p *int) { g(p) }

//go:norace
func g(p *int) { *p = 0 }

with "-S -race" shows that g is inlined into F, and the pointer assignment is instrumented with a race detector call, which seemingly defeats the intention of adding //go:norace.

Probably the easiest solution is that when instrumenting, we should treat //go:norace functions as non-inlinable.

Even better would be to avoid inlining //go:norace function calls only into instrumented functions (similar to how CL 102815 still allows inlining runtime calls within package runtime even during instrumented builds), but that would require tracking the //go:norace pragma across compilation units, which is a bit more involved.

/cc @cherrymui

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions