]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj: fix inline marker issue on s390x
authorMichael Munday <mike.munday@ibm.com>
Mon, 10 Aug 2020 15:01:21 +0000 (08:01 -0700)
committerMichael Munday <mike.munday@ibm.com>
Fri, 14 Aug 2020 08:25:40 +0000 (08:25 +0000)
The optimization that replaces inline markers with pre-existing
instructions assumes that 'Prog' values produced by the compiler are
still reachable after the assembler has run. This was not true on
s390x where the assembler was removing NOP instructions from the
linked list of 'Prog' values. This led to broken inlining data
which in turn caused an infinite loop in the runtime traceback code.

Fix this by stopping the s390x assembler backend removing NOP
values. It does not make any difference to the output of the
assembler because NOP instructions are 0 bytes long anyway.

Fixes #40473.

Change-Id: Ib4fabadd1de8adb80421f75950ee9aad2111147a
Reviewed-on: https://go-review.googlesource.com/c/go/+/247697
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/internal/obj/pcln.go
src/cmd/internal/obj/s390x/objz.go

index 1f7ccf47effcf28c15ff3497802094c53d6705b7..bffeda041dc9e00f0aa29fe68d0d89c901606125 100644 (file)
@@ -278,6 +278,21 @@ func linkpcln(ctxt *Link, cursym *LSym) {
        funcpctab(ctxt, &pcln.Pcfile, cursym, "pctofile", pctofileline, pcln)
        funcpctab(ctxt, &pcln.Pcline, cursym, "pctoline", pctofileline, nil)
 
+       // Check that all the Progs used as inline markers are still reachable.
+       // See issue #40473.
+       inlMarkProgs := make(map[*Prog]struct{}, len(cursym.Func.InlMarks))
+       for _, inlMark := range cursym.Func.InlMarks {
+               inlMarkProgs[inlMark.p] = struct{}{}
+       }
+       for p := cursym.Func.Text; p != nil; p = p.Link {
+               if _, ok := inlMarkProgs[p]; ok {
+                       delete(inlMarkProgs, p)
+               }
+       }
+       if len(inlMarkProgs) > 0 {
+               ctxt.Diag("one or more instructions used as inline markers are no longer reachable")
+       }
+
        pcinlineState := new(pcinlineState)
        funcpctab(ctxt, &pcln.Pcinline, cursym, "pctoinline", pcinlineState.pctoinline, nil)
        for _, inlMark := range cursym.Func.InlMarks {
index b14dc810fadfb4ff3743875e86934baa2c55656c..ef6335d8492d1d958e3867d6b98182197cd38af8 100644 (file)
@@ -283,17 +283,6 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
                        ACMPUBNE:
                        q = p
                        p.Mark |= BRANCH
-                       if p.Pcond != nil {
-                               q := p.Pcond
-                               for q.As == obj.ANOP {
-                                       q = q.Link
-                                       p.Pcond = q
-                               }
-                       }
-
-               case obj.ANOP:
-                       q.Link = p.Link /* q is non-nop */
-                       p.Link.Mark |= p.Mark
 
                default:
                        q = p