mirror of
https://github.com/golang/go
synced 2024-11-18 09:34:53 -07:00
cmd/compile: fix typing of IData opcodes
The rules for extracting the interface data word don't leave the result typed correctly. If I do i.([1]*int)[0], the result should have type *int, not [1]*int. Using (IData x) for the result keeps the typing of the original top-level Value. I don't think this would ever cause a real codegen bug, bug fixing it at least makes the typing shown in ssa.html more consistent. Change-Id: I239d821c394e58347639387981b0510d13b2f7b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/204042 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
1fb7d5472e
commit
70331a31ed
@ -803,7 +803,7 @@
|
|||||||
|
|
||||||
// Putting struct{*byte} and similar into direct interfaces.
|
// Putting struct{*byte} and similar into direct interfaces.
|
||||||
(IMake typ (StructMake1 val)) -> (IMake typ val)
|
(IMake typ (StructMake1 val)) -> (IMake typ val)
|
||||||
(StructSelect [0] x:(IData _)) -> x
|
(StructSelect [0] (IData x)) -> (IData x)
|
||||||
|
|
||||||
// un-SSAable values use mem->mem copies
|
// un-SSAable values use mem->mem copies
|
||||||
(Store {t} dst (Load src mem) mem) && !fe.CanSSA(t.(*types.Type)) ->
|
(Store {t} dst (Load src mem) mem) && !fe.CanSSA(t.(*types.Type)) ->
|
||||||
@ -823,9 +823,9 @@
|
|||||||
(Store _ (ArrayMake0) mem) -> mem
|
(Store _ (ArrayMake0) mem) -> mem
|
||||||
(Store dst (ArrayMake1 e) mem) -> (Store {e.Type} dst e mem)
|
(Store dst (ArrayMake1 e) mem) -> (Store {e.Type} dst e mem)
|
||||||
|
|
||||||
// Putting [1]{*byte} and similar into direct interfaces.
|
// Putting [1]*byte and similar into direct interfaces.
|
||||||
(IMake typ (ArrayMake1 val)) -> (IMake typ val)
|
(IMake typ (ArrayMake1 val)) -> (IMake typ val)
|
||||||
(ArraySelect [0] x:(IData _)) -> x
|
(ArraySelect [0] (IData x)) -> (IData x)
|
||||||
|
|
||||||
// string ops
|
// string ops
|
||||||
// Decomposing StringMake and lowering of StringPtr and StringLen
|
// Decomposing StringMake and lowering of StringPtr and StringLen
|
||||||
|
@ -6142,18 +6142,18 @@ func rewriteValuegeneric_OpArraySelect_0(v *Value) bool {
|
|||||||
v.AddArg(x)
|
v.AddArg(x)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// match: (ArraySelect [0] x:(IData _))
|
// match: (ArraySelect [0] (IData x))
|
||||||
// result: x
|
// result: (IData x)
|
||||||
for {
|
for {
|
||||||
if v.AuxInt != 0 {
|
if v.AuxInt != 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
x := v.Args[0]
|
v_0 := v.Args[0]
|
||||||
if x.Op != OpIData {
|
if v_0.Op != OpIData {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
v.reset(OpCopy)
|
x := v_0.Args[0]
|
||||||
v.Type = x.Type
|
v.reset(OpIData)
|
||||||
v.AddArg(x)
|
v.AddArg(x)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -43502,18 +43502,18 @@ func rewriteValuegeneric_OpStructSelect_10(v *Value) bool {
|
|||||||
v0.AddArg(mem)
|
v0.AddArg(mem)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// match: (StructSelect [0] x:(IData _))
|
// match: (StructSelect [0] (IData x))
|
||||||
// result: x
|
// result: (IData x)
|
||||||
for {
|
for {
|
||||||
if v.AuxInt != 0 {
|
if v.AuxInt != 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
x := v.Args[0]
|
v_0 := v.Args[0]
|
||||||
if x.Op != OpIData {
|
if v_0.Op != OpIData {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
v.reset(OpCopy)
|
x := v_0.Args[0]
|
||||||
v.Type = x.Type
|
v.reset(OpIData)
|
||||||
v.AddArg(x)
|
v.AddArg(x)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user