DenialAdams / roland

Roland programming language
https://www.brick.codes/roland
Apache License 2.0
48 stars 0 forks source link

Our liveness analysis is overly conservative #103

Closed DenialAdams closed 1 year ago

DenialAdams commented 1 year ago

For example, variables are assumed to live as long as any enclosing loop

DenialAdams commented 1 year ago
proc main() {
   loop {
      let x: u8 = 10;
      use(x);
      let y: u8 = 20;
      use(y);
      // y and x can coalesce
   }
}
DenialAdams commented 1 year ago

Also everything is dead after infinite loop

DenialAdams commented 1 year ago

Also everything is dead after infinite loop

This is probably better resolved by a DCE pass

Recent change i made was unsound:

proc use(x: u8) {
   println(uint_to_string(x as u64));
}

proc main() {
   let i: u32 = 0;
   let x: u8 = ___;
   loop {
      loop {
         break;
         x = 10;
      }
      use(x);
      let y = 20;
      use(y);
      i = i + 1;
      if i > 1 {
         break;
      }
   }
}

Hard to find an unsoundness example that doesn't use uninitialized memory though...

DenialAdams commented 1 year ago

Implemented in c2fc4b9c4eb36c094d17cc523f5029d334bfc1f2

Created https://github.com/DenialAdams/roland/issues/109 for soundness concerns