fixing storing struct pointer bug
This commit is contained in:
parent
33d78fbc52
commit
b4b3bae104
|
@ -1144,3 +1144,15 @@ main := fn(): uint {
|
|||
return f
|
||||
}
|
||||
```
|
||||
|
||||
#### aliasing_overoptimization
|
||||
```hb
|
||||
Foo := struct {ptr: ^uint, rnd: uint}
|
||||
|
||||
main := fn(): uint {
|
||||
mem := &2
|
||||
stru := Foo.(mem, 0);
|
||||
*stru.ptr = 0
|
||||
return *mem
|
||||
}
|
||||
```
|
||||
|
|
|
@ -3885,5 +3885,6 @@ mod tests {
|
|||
loop_stores;
|
||||
dead_code_in_loop;
|
||||
infinite_loop_after_peephole;
|
||||
aliasing_overoptimization;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -675,7 +675,7 @@ impl<'a> Function<'a> {
|
|||
"{:?}",
|
||||
self.nodes[nid]
|
||||
);
|
||||
debug_assert_eq!(self.nodes[nid].lock_rc, 0, "{:?}", self.nodes[nid]);
|
||||
debug_assert_eq!(self.nodes[nid].lock_rc, 0, "{nid} {:?}", self.nodes[nid]);
|
||||
debug_assert!(self.nodes[nid].kind != Kind::Phi || self.nodes[nid].ty != ty::Id::VOID);
|
||||
regalloc2::VReg::new(nid as _, regalloc2::RegClass::Int)
|
||||
}
|
||||
|
@ -953,15 +953,18 @@ impl<'a> Function<'a> {
|
|||
}
|
||||
Kind::Stck | Kind::Arg
|
||||
if node.outputs.iter().all(|&n| {
|
||||
matches!(self.nodes[n].kind, Kind::Stre | Kind::Load
|
||||
if self.nodes[n].ty.loc(self.tys) == Loc::Reg)
|
||||
|| matches!(self.nodes[n].kind, Kind::BinOp { op: TokenKind::Add }
|
||||
if self.nodes.is_const(self.nodes[n].inputs[2])
|
||||
&& self.nodes[n]
|
||||
.outputs
|
||||
.iter()
|
||||
.all(|&n| matches!(self.nodes[n].kind, Kind::Stre | Kind::Load
|
||||
if self.nodes[n].ty.loc(self.tys) == Loc::Reg)))
|
||||
matches!(self.nodes[n].kind, Kind::Load
|
||||
if self.nodes[n].ty.loc(self.tys) == Loc::Reg)
|
||||
|| matches!(self.nodes[n].kind, Kind::Stre
|
||||
if self.nodes[n].ty.loc(self.tys) == Loc::Reg
|
||||
&& self.nodes[n].inputs[1] != nid)
|
||||
|| matches!(self.nodes[n].kind, Kind::BinOp { op: TokenKind::Add }
|
||||
if self.nodes.is_const(self.nodes[n].inputs[2])
|
||||
&& self.nodes[n]
|
||||
.outputs
|
||||
.iter()
|
||||
.all(|&n| matches!(self.nodes[n].kind, Kind::Stre | Kind::Load
|
||||
if self.nodes[n].ty.loc(self.tys) == Loc::Reg)))
|
||||
}) => self.nodes.lock(nid),
|
||||
Kind::Stck if self.tys.size_of(node.ty) == 0 => self.nodes.lock(nid),
|
||||
Kind::Stck => {
|
||||
|
|
0
lang/tests/son_tests_aliasing_overoptimization.txt
Normal file
0
lang/tests/son_tests_aliasing_overoptimization.txt
Normal file
Loading…
Reference in a new issue