preventing deduplication to cause bugs
This commit is contained in:
parent
c657084451
commit
823c78bf74
|
@ -612,6 +612,30 @@ main := fn(): uint {
|
|||
|
||||
### Purely Testing Examples
|
||||
|
||||
#### scheduling_block_did_dirty
|
||||
```hb
|
||||
Struct := struct {
|
||||
pad: uint,
|
||||
pad2: uint,
|
||||
}
|
||||
|
||||
file := [u8].(255)
|
||||
|
||||
opaque := fn(x: uint): uint {
|
||||
return file[x]
|
||||
}
|
||||
|
||||
constructor := fn(x: uint): Struct {
|
||||
a := opaque(x)
|
||||
return .(a, a)
|
||||
}
|
||||
|
||||
main := fn(): void {
|
||||
something := constructor(0)
|
||||
return
|
||||
}
|
||||
```
|
||||
|
||||
#### null_check_returning_small_global
|
||||
```hb
|
||||
MAGIC := 127
|
||||
|
|
|
@ -4079,9 +4079,10 @@ impl<'a> Codegen<'a> {
|
|||
self.pool.push_ci(file, Some(sig.ret), 0, &mut self.ci);
|
||||
let prev_err_len = self.errors.borrow().len();
|
||||
|
||||
let &Expr::Closure { body, args, .. } = expr else {
|
||||
let &Expr::Closure { body, args, pos, .. } = expr else {
|
||||
unreachable!("{}", self.ast_display(expr))
|
||||
};
|
||||
self.ci.pos.push(pos);
|
||||
|
||||
let mut tys = sig.args.args();
|
||||
let mut args = args.iter();
|
||||
|
@ -4142,6 +4143,7 @@ impl<'a> Codegen<'a> {
|
|||
backend.emit_body(id, &mut self.ci.nodes, self.tys, self.files);
|
||||
}
|
||||
|
||||
self.ci.pos.pop();
|
||||
self.pool.pop_ci(&mut self.ci);
|
||||
}
|
||||
|
||||
|
@ -4646,6 +4648,7 @@ mod tests {
|
|||
fb_driver;
|
||||
|
||||
// Purely Testing Examples;
|
||||
scheduling_block_did_dirty;
|
||||
null_check_returning_small_global;
|
||||
null_check_in_the_loop;
|
||||
stack_provenance;
|
||||
|
|
|
@ -10,7 +10,7 @@ use {
|
|||
Offset, PLoc, Reloc, Sig, TypedReloc, Types,
|
||||
},
|
||||
alloc::{borrow::ToOwned, vec::Vec},
|
||||
core::{mem, ops::Range, u32, usize},
|
||||
core::{mem, ops::Range},
|
||||
hbbytecode::{self as instrs},
|
||||
};
|
||||
|
||||
|
|
|
@ -855,6 +855,7 @@ impl<'a> Function<'a> {
|
|||
}
|
||||
|
||||
fn reschedule_block(&mut self, from: Nid, outputs: &mut Vc) {
|
||||
// NOTE: this code is horible
|
||||
let from = Some(&from);
|
||||
let mut buf = Vec::with_capacity(outputs.len());
|
||||
let mut seen = BitSet::default();
|
||||
|
@ -878,7 +879,9 @@ impl<'a> Function<'a> {
|
|||
.all(|&o| self.nodes[o].inputs.first() != from || seen.get(o))
|
||||
&& seen.set(i)
|
||||
{
|
||||
buf.push(i);
|
||||
for &o in outputs.iter().filter(|&&n| n == i) {
|
||||
buf.push(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor += 1;
|
||||
|
@ -890,7 +893,9 @@ impl<'a> Function<'a> {
|
|||
continue;
|
||||
}
|
||||
let mut cursor = buf.len();
|
||||
for &o in outputs.iter().filter(|&&n| n == o) {
|
||||
buf.push(o);
|
||||
}
|
||||
while let Some(&n) = buf.get(cursor) {
|
||||
for &i in &self.nodes[n].inputs[1..] {
|
||||
if from == self.nodes[i].inputs.first()
|
||||
|
@ -900,22 +905,17 @@ impl<'a> Function<'a> {
|
|||
.all(|&o| self.nodes[o].inputs.first() != from || seen.get(o))
|
||||
&& seen.set(i)
|
||||
{
|
||||
buf.push(i);
|
||||
for &o in outputs.iter().filter(|&&n| n == i) {
|
||||
buf.push(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
cursor += 1;
|
||||
}
|
||||
}
|
||||
|
||||
debug_assert!(
|
||||
outputs.len() == buf.len() || outputs.len() == buf.len() + 1,
|
||||
"{:?} {:?}",
|
||||
outputs,
|
||||
buf
|
||||
);
|
||||
|
||||
if buf.len() + 1 == outputs.len() {
|
||||
outputs.remove(outputs.len() - 1);
|
||||
if outputs.len() != buf.len() {
|
||||
panic!("{:?} {:?}", outputs, buf);
|
||||
}
|
||||
outputs.copy_from_slice(&buf);
|
||||
}
|
||||
|
|
31
lang/tests/son_tests_scheduling_block_did_dirty.txt
Normal file
31
lang/tests/son_tests_scheduling_block_did_dirty.txt
Normal file
|
@ -0,0 +1,31 @@
|
|||
constructor:
|
||||
ADDI64 r254, r254, -32d
|
||||
ST r31, r254, 16a, 16h
|
||||
CP r2, r3
|
||||
JAL r31, r0, :opaque
|
||||
ADDI64 r32, r254, 0d
|
||||
ST r1, r254, 0a, 8h
|
||||
ST r1, r254, 8a, 8h
|
||||
LD r1, r32, 0a, 16h
|
||||
LD r31, r254, 16a, 16h
|
||||
ADDI64 r254, r254, 32d
|
||||
JALA r0, r31, 0a
|
||||
main:
|
||||
ADDI64 r254, r254, -32d
|
||||
ST r31, r254, 16a, 16h
|
||||
ADDI64 r32, r254, 0d
|
||||
LI64 r3, 0d
|
||||
JAL r31, r0, :constructor
|
||||
ST r1, r254, 0a, 16h
|
||||
LD r31, r254, 16a, 16h
|
||||
ADDI64 r254, r254, 32d
|
||||
JALA r0, r31, 0a
|
||||
opaque:
|
||||
LRA r3, r0, :file
|
||||
ADD64 r5, r3, r2
|
||||
LD r7, r5, 0a, 1h
|
||||
ANDI r1, r7, 255d
|
||||
JALA r0, r31, 0a
|
||||
code size: 274
|
||||
ret: 255
|
||||
status: Ok(())
|
Loading…
Reference in a new issue