Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small batch of Bril/Rust fixes #258

Merged
merged 6 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ jobs:
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
if: matrix.path == 'bril-rs/brillvm/Cargo.toml'
with:
version: "15.0"
version: "16.0"

- name: cargo check
run: cargo check --manifest-path ${{ matrix.path }} --all-targets
Expand Down
2 changes: 1 addition & 1 deletion bril-rs/bril2json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords = ["compiler", "bril", "parser", "data-structures", "language"]
[dependencies]
clap = { version = "4.3", features = ["derive"] }
lalrpop-util = { version = "0.20", features = ["lexer"] }
regex = "1.8"
regex = "1.9"

# Add a build-time dependency on the lalrpop library:
[build-dependencies]
Expand Down
1 change: 0 additions & 1 deletion bril-rs/bril2json/src/bril_grammar.lalrpop
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(clippy::needless_lifetimes)]
#![allow(clippy::just_underscores_and_digits)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::deprecated_cfg_attr)]
#![allow(clippy::no_effect_underscore_binding)]
#![allow(clippy::unnested_or_patterns)]
Expand Down
2 changes: 0 additions & 2 deletions bril-rs/brild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
#![allow(clippy::module_name_repetitions)]
// todo until multiple versions of some really far down dependency are fixed
#![allow(clippy::multiple_crate_versions)]

#[doc(hidden)]
pub mod cli;
Expand Down
6 changes: 3 additions & 3 deletions bril-rs/brillvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ default-run = "main"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.3", features = ["derive"] }
inkwell = { version = "0.2", features = ["llvm15-0"] }
libc-print = "0.1"
clap = { version = "4.3", features = ["derive"] }
inkwell = { version = "0.2", features = ["llvm16-0"] }
libc-print = "0.1"

# For overriding parking_lot_core to latest version from 0.9.7
# To pull in the removal of `window-sys` which was causing duplicate dependencies
Expand Down
5 changes: 2 additions & 3 deletions bril-rs/brillvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ TESTS := ../../test/interp/core/*.bril \
../../test/interp/mem/*.bril \
../../test/interp/mixed/*[^r].bril # A hack to exclude store-char.bril by excluding any file ending in r.bril

# Currently ignoring the Cholesky benchmark because of (probably) a floating point rounding bug.
BENCHMARKS := ../../benchmarks/core/*.bril \
../../benchmarks/float/*.bril \
../../benchmarks/mem/*.bril \
../../benchmarks/mixed/[^c]*.bril # A hack to exclude cholesky.bril by excluding any file starting in c.
../../benchmarks/mixed/*.bril

clean:
cargo clean
Expand All @@ -20,7 +19,7 @@ rt:
cargo rustc --bin rt --release -- --emit=llvm-bc && mv target/release/deps/rt-*.bc rt.bc

example:
bril2json < ../../benchmarks/mem/sieve.bril | cargo run -- -i 100
# bril2json < ../../benchmarks/mem/sieve.bril | cargo run -- -i 100
bril2json < ../../benchmarks/mixed/cholesky.bril | cargo run -- -i

.PHONY: test
Expand Down
4 changes: 2 additions & 2 deletions bril-rs/brillvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Valid Bril programs are assumed as input with no attempt at error handling. Each

### Floating Point values

There is a known issue where some floating point values are off by a small epsilon.
Be careful which execution engine you are using which may enable some kind of fast math mode behind your back. This can cause some floating point values to be off by a small epsilon.

### Missing LLVM

Expand All @@ -34,4 +34,4 @@ This tool relies on the `llvm-sys` crate to find the correct version of LLVM to

```shell
LLVM_SYS_150_PREFIX="/opt/homebrew/Cellar/llvm/15.0.7_1/"
```
```
2 changes: 1 addition & 1 deletion bril-rs/brillvm/src/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ pub fn create_module_from_program<'a>(
(llvm_func, instrs, block, heap)
},
)
.collect(); // Important to collect, can't be done lazily because we need all functions to ne loaded in before a call instruction of a function is processed.
.collect(); // Important to collect, can't be done lazily because we need all functions to be loaded in before a call instruction of a function is processed.

// Now actually build each function
funcs
Expand Down
8 changes: 5 additions & 3 deletions bril-rs/brillvm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use brillvm::{cli::Cli, llvm::create_module_from_program};
use clap::Parser;
use inkwell::{
context::Context,
execution_engine::ExecutionEngine,
module::Module,
targets::{InitializationConfig, Target},
};
Expand Down Expand Up @@ -35,8 +34,11 @@ fn main() {
if args.interpreter {
Target::initialize_native(&InitializationConfig::default())
.expect("Failed to initialize native target");
ExecutionEngine::link_in_interpreter();
let engine = llvm_prog.create_execution_engine().unwrap();

let engine = llvm_prog
.create_jit_execution_engine(inkwell::OptimizationLevel::None)
.unwrap();

let mut args: Vec<&str> = args.args.iter().map(|s| s.as_ref()).collect();
args.insert(0, "bril_prog");
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions bril-rs/rs2bril/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ fn array_init_helper(
op: ConstOps::Const,
pos: None,
const_type: Type::Int,
value: Literal::Int(vars.len() as i64),
value: Literal::Int(i64::try_from(vars.len()).unwrap()),
}));
code.push(Code::Instruction(Instruction::Value {
args: vec![size],
Expand All @@ -423,7 +423,7 @@ fn array_init_helper(
op: ConstOps::Const,
pos: None,
const_type: Type::Int,
value: Literal::Int(i as i64),
value: Literal::Int(i64::try_from(i).unwrap()),
}));
let index_pointer = state.fresh_var(op_type.clone());
code.push(Code::Instruction(Instruction::Value {
Expand Down