Inlining of runtime/internal/atomic.Cas

80 views
Skip to first unread message

Timur Celik

unread,
Oct 4, 2023, 8:36:19 AM10/4/23
to golan...@googlegroups.com
Why is it that changes in the runtime package's atomic.Cas don't land in
my build? I suspect it has something to do with inlining of the
function, but even with `-gcflags=-l` the atomic.Cas original
implementation seems to get inlined. Functions that aren't inlined,
like atomic.Or have my changes incorporated. I tried deleting all
caches and rebuilt the compiler without success.

Thank you.

Ian Lance Taylor

unread,
Oct 4, 2023, 12:06:05 PM10/4/23
to Timur Celik, golan...@googlegroups.com
It's because in general the compiler internally implements all the
functions that appear in runtime/internal/atomic. The implementations
in that package are not normally used at all, though they may be used
when optimizations are disabled (-gcflags=-N). For the internal
compiler implementations you can start by looking for
OpAtomicCompareAndSwap32 in cmd/compile/internal/ssa.

Ian

Timur Celik

unread,
Oct 4, 2023, 1:20:44 PM10/4/23
to Ian Lance Taylor, golan...@googlegroups.com
Thank you so much, this solves my issue. Really appreciate your work for the Go project, Ian. Cheers
Reply all
Reply to author
Forward
0 new messages