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

Segfault using ODS llvm alloca builder #334

Closed
edg-l opened this issue Sep 29, 2023 · 0 comments · Fixed by #335
Closed

Segfault using ODS llvm alloca builder #334

edg-l opened this issue Sep 29, 2023 · 0 comments · Fixed by #335

Comments

@edg-l
Copy link
Contributor

edg-l commented Sep 29, 2023

Caused by:
  process didn't exit successfully: `/snip/melior/target/debug/deps/melior-eb2c58f5b3bbae69 compile_ods_llvm_alloca` (signal: 11, SIGSEGV: invalid memory reference)

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

        let location = Location::unknown(&context);
        let mut module = Module::new(location);
        let integer_type = IntegerType::new(&context, 64).into();
        let ptr_type = crate::dialect::llvm::r#type::opaque_pointer(&context);

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

                let alloca_size = block.argument(0).unwrap().into();

                block.append_operation(
                    llvm::AllocaOpBuilder::new(location)
                        .alignment(IntegerAttribute::new(
                            8,
                            IntegerType::new(&context, 64).into(),
                        ))
                        .array_size(alloca_size)
                        .res(ptr_type)
                        .build()
                        .into(),
                );

                block.append_operation(func::r#return(&[], location));

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

        convert_module(&context, &mut module);

        assert!(module.as_operation().verify());
        insta::assert_display_snapshot!(module.as_operation());
    }
raviqqe added a commit that referenced this issue Sep 30, 2023
this is about #334 to give you a easy branch to check that this indeed
segfaults, not meant to be merged if u dont want

feel free to push here too if needed

---------

Co-authored-by: Yota Toyama <raviqqe@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant