]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: enable address folding for global symbols of shared library
authorerifan01 <eric.fang@arm.com>
Tue, 25 Oct 2022 04:08:05 +0000 (12:08 +0800)
committerEric Fang <eric.fang@arm.com>
Sat, 29 Oct 2022 04:48:07 +0000 (04:48 +0000)
commite09bbaec69a8ff960110e13eabb3bef5331ecb0c
tree87cb47a464ae27caf59c463547ed55f1b92e146a
parent8a9e2d9d49a9d5234b52a0360ed6a0f91753c291
cmd/compile: enable address folding for global symbols of shared library

Address folding is disabled in CL42172, the commit message of which
said that "In shared library, load/store of global is rewritten to
using GOT and temp register, which conflicts with the use of temp
register for assembling large offset.". Actually this doesn't happen
because the sequence of instructions when rewritten to use Got looks
like this:
  MOVD $sym, Rx becomes
  MOVD sym@GOT, Rx
If there is an offset off, there will be one more instruction:
  ADD $off, Rx, Rx

And MOVD sym, Rx becomes
  MOVD sym@GOT, REGTMP
  MOVx (REGTMP), Ry

If there is a small offset off, it becomes:
  MOVD sym@GOT, REGTMP
  MOVx (REGTMP)off, Ry

If off is very large, it becomes:
  MOVD sym@GOT, REGTMP
  MOVD $off, Rt
  ADD  Rt, REGTMP
  MOVx (REGTMP), Ry

We can see that the address can be calculated correctly, and testing
on darwin/arm64 confirms this.

Removing this restriction is beneficial to further optimize the sequence
of "ADRP+ADD+LD/ST" to "ADRP+LD/ST(offset), so this CL removes it.

Change-Id: I0e9f7bc1723e0a027f32cf0ae2c41cd6df49defe
Reviewed-on: https://go-review.googlesource.com/c/go/+/445535
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/ssa/_gen/ARM64.rules
src/cmd/compile/internal/ssa/rewriteARM64.go