Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed May 4, 2024
1 parent 1f41f57 commit 579bc8d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
36 changes: 36 additions & 0 deletions melior/src/dialect/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,42 @@ mod tests {
insta::assert_snapshot!(module.as_operation());
}

#[test]
fn compile_null_ptr() {
let context = create_test_context();

let location = Location::unknown(&context);
let mut module = Module::new(location);
let ptr_type = r#type::pointer(&context, 0);

module.body().append_operation(func::func(
&context,
StringAttribute::new(&context, "foo"),
TypeAttribute::new(FunctionType::new(&context, &[], &[ptr_type]).into()),
{
let block = Block::new(&[]);

let operation = block.append_operation(zero(ptr_type, location));

block.append_operation(func::r#return(
&[operation.result(0).unwrap().into()],
location,
));

let region = Region::new();
region.append_block(block);
region
},
&[],
location,
));

convert_module(&context, &mut module);

assert!(module.as_operation().verify());
insta::assert_snapshot!(module.as_operation());
}

#[test]
fn compile_undefined() {
let context = create_test_context();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: melior/src/dialect/llvm.rs
expression: module.as_operation()
---
module {
llvm.func @foo() -> i64 {
%0 = llvm.mlir.zero : i64
llvm.return %0 : i64
}
}

0 comments on commit 579bc8d

Please sign in to comment.