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

Generated llvm ir triggers llvm assertions #227

Closed
jDomantas opened this issue Jun 15, 2020 · 2 comments · Fixed by #233
Closed

Generated llvm ir triggers llvm assertions #227

jDomantas opened this issue Jun 15, 2020 · 2 comments · Fixed by #233
Labels
exp: intermediate Achievable by experienced contributors, or with some guidance pri: intermediate An issue resulting in non-critical functionality loss and no significant effect on usability type: fix Bug fix or report
Milestone

Comments

@jDomantas
Copy link

So I accidentally compiled my llvm with assertions enabled, and now trying to run mun tests aborts with llvm assertion failure:

>  cargo test -p mun_codegen -- function_arguments
    Finished test [unoptimized + debuginfo] target(s) in 0.34s
     Running target\debug\deps\mun_codegen-d51557810a1e1457.exe

running 1 test
Assertion failed: V[I]->getType() == T->getTypeAtIndex(I) && "Initializer for composite element doesn't match!", file ###\lib\IR\Constants.cpp, line 951
error: test failed, to rerun pass '-p mun_codegen --lib'

Caused by:
  process didn't exit successfully: `###\target\debug\deps\mun_codegen-d51557810a1e1457.exe function_arguments` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

Looking at the ir snapshot my suspicion is that type info initializer does not match the declared type MunTypeInfo:

%struct.MunTypeInfo = type { [16 x i8], i8*, i32, i8, i8 }
                                        ^^^ declared as i8*
...

@"type_info::<core::i32>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"\17yzt\19\D62\17\D25\95C\17\88[\FA", [10 x i8]* @"type_info::<core::i32>::name", i32 32, i8 4, i8 0 }
                                                                                                                                 ^^^^^^^^^^ initializer uses [10 x i8]*

@baszalmstra
Copy link
Collaborator

Ah yes I was afraid that would bite us in the ass at some point. 😄

We use an old C trick here. I'll take a look at it to see if I can do it correctly.

@baszalmstra baszalmstra added exp: intermediate Achievable by experienced contributors, or with some guidance pri: intermediate An issue resulting in non-critical functionality loss and no significant effect on usability type: fix Bug fix or report labels Jun 19, 2020
@baszalmstra
Copy link
Collaborator

It took me quite a while (also due to compiling LLVM..) but I fixed all assertions that are thrown when running the tests (#233)

Your hunch was correct in that a [16 x i8] is not the same as an i8*. Without assertions this works fine but with assertions LLVM complains. I introduced some constraints that ensure that we properly cast these values.

@Wodann Wodann added this to the Mun v0.3.0 milestone Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp: intermediate Achievable by experienced contributors, or with some guidance pri: intermediate An issue resulting in non-critical functionality loss and no significant effect on usability type: fix Bug fix or report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants