fixing storing struct pointer bug
This commit is contained in:
parent
33d78fbc52
commit
b4b3bae104
|
@ -1144,3 +1144,15 @@ main := fn(): uint {
|
||||||
return f
|
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;
|
loop_stores;
|
||||||
dead_code_in_loop;
|
dead_code_in_loop;
|
||||||
infinite_loop_after_peephole;
|
infinite_loop_after_peephole;
|
||||||
|
aliasing_overoptimization;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,7 +675,7 @@ impl<'a> Function<'a> {
|
||||||
"{:?}",
|
"{:?}",
|
||||||
self.nodes[nid]
|
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);
|
debug_assert!(self.nodes[nid].kind != Kind::Phi || self.nodes[nid].ty != ty::Id::VOID);
|
||||||
regalloc2::VReg::new(nid as _, regalloc2::RegClass::Int)
|
regalloc2::VReg::new(nid as _, regalloc2::RegClass::Int)
|
||||||
}
|
}
|
||||||
|
@ -953,15 +953,18 @@ impl<'a> Function<'a> {
|
||||||
}
|
}
|
||||||
Kind::Stck | Kind::Arg
|
Kind::Stck | Kind::Arg
|
||||||
if node.outputs.iter().all(|&n| {
|
if node.outputs.iter().all(|&n| {
|
||||||
matches!(self.nodes[n].kind, Kind::Stre | Kind::Load
|
matches!(self.nodes[n].kind, Kind::Load
|
||||||
if self.nodes[n].ty.loc(self.tys) == Loc::Reg)
|
if self.nodes[n].ty.loc(self.tys) == Loc::Reg)
|
||||||
|| matches!(self.nodes[n].kind, Kind::BinOp { op: TokenKind::Add }
|
|| matches!(self.nodes[n].kind, Kind::Stre
|
||||||
if self.nodes.is_const(self.nodes[n].inputs[2])
|
if self.nodes[n].ty.loc(self.tys) == Loc::Reg
|
||||||
&& self.nodes[n]
|
&& self.nodes[n].inputs[1] != nid)
|
||||||
.outputs
|
|| matches!(self.nodes[n].kind, Kind::BinOp { op: TokenKind::Add }
|
||||||
.iter()
|
if self.nodes.is_const(self.nodes[n].inputs[2])
|
||||||
.all(|&n| matches!(self.nodes[n].kind, Kind::Stre | Kind::Load
|
&& self.nodes[n]
|
||||||
if self.nodes[n].ty.loc(self.tys) == Loc::Reg)))
|
.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),
|
}) => self.nodes.lock(nid),
|
||||||
Kind::Stck if self.tys.size_of(node.ty) == 0 => self.nodes.lock(nid),
|
Kind::Stck if self.tys.size_of(node.ty) == 0 => self.nodes.lock(nid),
|
||||||
Kind::Stck => {
|
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