https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64876
Alan Modra <amodra at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Component|go |target Assignee|ian at airs dot com |amodra at gmail dot com --- Comment #5 from Alan Modra <amodra at gmail dot com> --- Oh yeah, this is really an rs6000 backend bug, not a go bug. In 185.r.expand I see ;; _12 = _11 (); [static-chain: _9] (insn 78 77 79 (set (reg:DI 11 11) (reg/f:DI 181 [ D.1382 ])) /home/amodra/src/gcc-virgin/gcc/testsuite/go.test/test/escape.go:155 -1 (nil)) So there's the static chain being loaded. Trouble is, indirect calls on ELFv1 load r11 from the function descriptor so the proper value is overwritten.. (insn 79 78 80 (set (mem/v/c:DI (plus:DI (reg/f:DI 1 1) (const_int 40 [0x28])) [28 S8 A8]) (reg:DI 2 2)) /home/amodra/src/gcc-virgin/gcc/testsuite/go.test/test/escape.go:155 -1 (nil)) (insn 80 79 81 (set (reg:DI 198) (mem:DI (reg/f:DI 182 [ D.1381 ]) [0 S8 A8])) /home/amodra/src/gcc-virgin/gcc/testsuite/go.test/test/escape.go:155 -1 (nil)) (insn 81 80 82 (set (reg:DI 11 11) (mem:DI (plus:DI (reg/f:DI 182 [ D.1381 ]) (const_int 16 [0x10])) [0 S8 A8])) /home/amodra/src/gcc-virgin/gcc/testsuite/go.test/test/escape.go:155 -1 (nil)) ..above. (call_insn 82 81 83 (parallel [ (set (reg:DI 3 3) (call (mem:SI (reg:DI 198) [0 *_11 S4 A8]) (const_int 64 [0x40]))) (use (mem:DI (plus:DI (reg/f:DI 182 [ D.1381 ]) (const_int 8 [0x8])) [0 S8 A8])) (set (reg:DI 2 2) (unspec:DI [ (const_int 40 [0x28]) ] UNSPEC_TOCSLOT)) (clobber (reg:DI 65 lr)) ]) /home/amodra/src/gcc-virgin/gcc/testsuite/go.test/test/escape.go:155 -1 (expr_list:REG_CALL_DECL (nil) (nil)) (expr_list (use (reg:DI 11 11)) (expr_list (use (reg:DI 11 11)) (nil)))) Thus the patch to clear TARGET_POINTERS_TO_NESTED_FUNCTIONS which turns off loading of r11 from function descriptors.