]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile,cmd/link: fix and re-enable open-coded defers on riscv64
authorJoel Sing <joel@sing.id.au>
Wed, 29 Jan 2020 09:06:54 +0000 (20:06 +1100)
committerJoel Sing <joel@sing.id.au>
Wed, 29 Jan 2020 16:34:44 +0000 (16:34 +0000)
The R_CALLRISCV relocation marker is on the JALR instruction, however the actual
relocation is currently two instructions previous for the AUIPC+ADDI sequence.
Adjust the platform dependent offset accordingly and re-enable open-coded defers.

Fixes #36786.

Change-Id: I71597c193c447930fbe94ce44b7355e89ae877bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/216797
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/ssa.go
src/cmd/link/internal/ld/pcln.go
test/live.go

index 24cb200175c863740b3d7ce6c99fc34cb80f9f59..b8e99f08c547a7d9c7ddd0a27d6eb8371201fde8 100644 (file)
@@ -347,10 +347,6 @@ func buildssa(fn *Node, worker int) *ssa.Func {
                // preceding the deferreturn/ret code that is generated by gencallret()
                // that we don't track correctly.
                s.hasOpenDefers = false
-       case thearch.LinkArch.Name == "riscv64":
-               // The use of open-coded defers is currently broken on riscv64,
-               // hence disable it for now - see issue golang.org/issue/36786
-               s.hasOpenDefers = false
        }
        if s.hasOpenDefers && s.curfn.Func.Exit.Len() > 0 {
                // Skip doing open defers if there is any extra exit code (likely
index ab703e94ee3b5223b51c70a8ddb0ce70d5305cdb..7cba9bde6d1eb904921504bde836746e54c05f1b 100644 (file)
@@ -266,8 +266,13 @@ func (ctxt *Link) pclntab() {
                                        switch ctxt.Arch.Family {
                                        case sys.AMD64, sys.I386:
                                                deferreturn--
-                                       case sys.PPC64, sys.ARM, sys.ARM64, sys.MIPS, sys.MIPS64, sys.RISCV64:
+                                       case sys.PPC64, sys.ARM, sys.ARM64, sys.MIPS, sys.MIPS64:
                                                // no change
+                                       case sys.RISCV64:
+                                               // TODO(jsing): The JALR instruction is marked with
+                                               // R_CALLRISCV, whereas the actual reloc is currently
+                                               // two instructions earlier for the AUIPC+AADI sequence.
+                                               deferreturn -= 8
                                        case sys.S390X:
                                                deferreturn -= 2
                                        default:
index 02e0fd51e524b33f819e6ebe21e66b7f2ece46c8..3df7ab01af47f693885bc05bdfe08873ffdbed8c 100644 (file)
@@ -1,13 +1,9 @@
 // errorcheckwithauto -0 -l -live -wb=0 -d=ssa/insert_resched_checks/off
-// +build !ppc64,!ppc64le,!riscv64
+// +build !ppc64,!ppc64le
 
 // ppc64 needs a better tighten pass to make f18 pass
 // rescheduling checks need to be turned off because there are some live variables across the inserted check call
 
-// TODO(jsing): these tests assume that open-coded defers are enabled,
-// which is not currently the case on riscv64. Re-enable this test once
-// open-coded defers are available - golang.org/issues/36786.
-
 // Copyright 2014 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.