diff --git a/bril-rs/brillvm/README.md b/bril-rs/brillvm/README.md index cc9ea5af..ba2e840c 100644 --- a/bril-rs/brillvm/README.md +++ b/bril-rs/brillvm/README.md @@ -9,7 +9,8 @@ be updated as Inkwell gets new support, within the constraints of the rust compi ## Runtime -You must have a linkable runtime library available in the LLVM bc format. You can get this by calling `make rt` +You must have a linkable runtime library available in the LLVM bc format. +You can get this by calling `make rt`. ## Usage @@ -38,6 +39,12 @@ the LLVM `mem2reg` pass will be sufficient if that is needed) but if you choose to supply Bril code with `phi` operations, Brillvm will assume that they follow LLVM's additional constraints. +### Limitations + +- Rust and Bril both allow variables to be re-declared with different types. Brillvm + does not yet support this and assumes that a given variable will only have one + type within a function. + ## TroubleShooting ### Floating Point values diff --git a/bril-rs/brillvm/src/llvm.rs b/bril-rs/brillvm/src/llvm.rs index 77769b5a..dcd85596 100644 --- a/bril-rs/brillvm/src/llvm.rs +++ b/bril-rs/brillvm/src/llvm.rs @@ -96,10 +96,15 @@ impl<'a, 'b> Heap<'a, 'b> { name: &'b String, ty: &Type, ) -> WrappedPointer<'a> { - self.map + let result = self.map .entry(name) .or_insert_with(|| WrappedPointer::new(builder, context, name, ty)) - .clone() + .clone(); + if result.ty != *ty { + println!("`{}` had type `{}` but is now being assigned type `{}`", name, result.ty, ty); + unimplemented!("brillvm does not currently support variables within a function having different types. Implementing this might require a control flow analysis? Feel free to try and implement this.") + } + result } fn get(&self, name: &String) -> WrappedPointer<'a> {