diff options
| author | limeidan <limeidan@loongson.cn> | 2024-01-17 17:49:37 +0800 |
|---|---|---|
| committer | abner chenc <chenguoqi@loongson.cn> | 2024-08-01 00:51:41 +0000 |
| commit | 01ab9a016afe7239ed7b43cdd820103ec91aba09 (patch) | |
| tree | aaf6827c763fb436185bc432239369581c0e793f /src/cmd | |
| parent | 864513dda9d96dfd0fbdbe4c2b68ebbfa3d34bc7 (diff) | |
| download | go-01ab9a016afe7239ed7b43cdd820103ec91aba09.tar.xz | |
cmd/internal/obj/loong64: optimize the code logic of jump instructions
If p.To.Sym is nil, that means we can get the target offset from
p.To.Target().pc - c.pc,only when p.To.Sym is not nil, we need relocation
to get the true address of target symbol.
Change-Id: Ied52f675c6aa6e8fb8d972b7699f5cadd1ecb268
Reviewed-on: https://go-review.googlesource.com/c/go/+/565627
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/internal/obj/loong64/asm.go | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go index 2f2caa8b6d..1e4dd111f1 100644 --- a/src/cmd/internal/obj/loong64/asm.go +++ b/src/cmd/internal/obj/loong64/asm.go @@ -1401,19 +1401,14 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) { v = int32(p.To.Target().Pc-p.Pc) >> 2 } o1 = OP_B_BL(c.opirr(p.As), uint32(v)) - if p.To.Sym == nil { - if p.As == AJMP { - break - } - p.To.Sym = c.cursym.Func().Text.From.Sym - p.To.Offset = p.To.Target().Pc + if p.To.Sym != nil { + rel := obj.Addrel(c.cursym) + rel.Off = int32(c.pc) + rel.Siz = 4 + rel.Sym = p.To.Sym + rel.Add = p.To.Offset + rel.Type = objabi.R_CALLLOONG64 } - rel := obj.Addrel(c.cursym) - rel.Off = int32(c.pc) - rel.Siz = 4 - rel.Sym = p.To.Sym - rel.Add = p.To.Offset - rel.Type = objabi.R_CALLLOONG64 case 12: // movbs r,r // NOTE: this case does not use REGTMP. If it ever does, |
