https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105091
Ian Lance Taylor <ian at airs dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ian at airs dot com
--- Comment #8 from Ian Lance Taylor <ian at airs dot com> ---
This program should print
0
1
but when I run it on gcc112.fsffrance.org, compiling with -O2, it prints
1
824633846216
package main
func main() {
for _, test := range []struct {
x, y, want []int
}{
{[]int{}, []int{}, nil},
{[]int{0}, []int{0}, []int{0}},
} {
p := test.x
F(p)
}
}
func F(v interface{}) {
recover()
println(cap(v.([]int)))
}
This can be compiled (though not run) using a cross-compiler without building
libgo.
The code coming into 280r.dse1 seems to be indexing from the end of the array.
I see
code_label 96 126 55 4 118 (nil) [0 uses])
(note 55 96 56 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 56 55 57 4 (set (reg:DI 144)
(mult:DI (reg:DI 121 [ ivtmp_47 ])
(const_int -72 [0xffffffffffffffb8]))) "foo.go":4:2 154 {muldi3}
(nil))
(insn 57 56 59 4 (set (reg/f:DI 145)
(plus:DI (reg/f:DI 173)
(reg:DI 144))) "foo.go":4:2 66 {*adddi3}
(expr_list:REG_DEAD (reg/f:DI 173)
(expr_list:REG_DEAD (reg:DI 144)
(nil))))
where earlier I see
(insn 17 16 19 2 (set (mem/f/c:DI (plus:DI (reg/f:DI 110 sfp)
(const_int 32 [0x20])) [8 GOTMP.5[0].x.__values+0 S8 A128])
(reg/f:DI 117 [ _11 ])) "foo.go":4:23 670 {*movdi_internal64}
(expr_list:REG_DEAD (reg/f:DI 117 [ _11 ])
(nil)))
and
(insn 120 4 121 2 (set (reg/f:DI 173)
(plus:DI (reg/f:DI 110 sfp)
(const_int 32 [0x20]))) 66 {*adddi3}
(nil))
So register 173 is &GOTMP.5 although insn 120 doesn't indicate that. Then the
280r.dse1 pass drops out all the assignments to GOTMP.5, presumably because it
doesn't understand that register 173 points to it.