-
Notifications
You must be signed in to change notification settings - Fork 7
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
Assert that all promotion data has been consumed. #1454
Conversation
Good idea! |
This is interesting:
That suggests we already have a test case where we aren't consuming all promotions as we would expect to. @ptersilie I think this is one for you when you're back. |
I might have an idea what's going on here, though I haven't confirmed this yet. From what I understand, we collect a list of all constants promoted during tracing and then this check makes sure we use all promotions when constructing the trace. What I believe this is forgetting is that we don't process everything we see during tracing. For example if there's a function containing a loop that also contains promotions, we will later outline that function and thus not process those promotions during trace building. I will try constructing a test using this information to confirm. |
Right, this is my guess too: but notice that we should still be advancing So I think the assert should always be true, because what it says is "we got to the end of the promotion data" (which, I now realise, isn't quite the same as "we consumed all the promotion data" implies). |
This means that even when outlining functions/blocks, we will need to iterate through them to find promotions and advance |
I must admit that I'm slightly surprised we do get a So one way of thinking of this in the short term is to say "if we haven't got to the end of the promotion data, the user should change their interpreter to make sure |
This LGTM but I think @vext01 needs to take over reviewing now. |
And I suggest before merge we squash the two commits into one, so we don't leave a "this breaks" commit in history. Lukas can do a |
aot_ir::Ty::Integer(it) => it.num_bits(), | ||
_ => unreachable!(), | ||
}; | ||
let width_bytes = usize::try_from(width_bits).unwrap() / 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oopsy. An i1
would report a byte size of 0! I know we can't promote an i1
, but still.
See this jit ir routine for inspiration.
Every time we are tempted to divide a bit size by 8, an alarm bell should ring :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied this from handle_operand
. We should fix it there too, but I'm not sure this PR is the right place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, please follow this PR up with the fix. It'll surely bite us later (again).
Seems good, modulo that one comment. |
Fixes #1440. |
Uh, yeah. |
I need to squash first. |
please squash. |
502a1f7
to
1bc2891
Compare
Squashed. |
I realised that the handle_operand bit doesn't have the same issue since it matches the bits. So decided to make this change in this PR after all. Ok to squash? |
go ahead. |
fcd97bc
to
f216359
Compare
Squashed. |
You can force push the clippy fix. |
One thing that I realised is that if we didn't consume all promotion data -- e.g. because we forgot to consume it when we're outlining -- weird things would happen. This assert always succeeds on my tests, but I think it's worth having in. Co-authored-by: Lukas Diekmann <lukas.diekmann@gmail.com>
f216359
to
43b346b
Compare
Ready. |
Huh. I thought I fixed that. |
@ptersilie I thought we'd got rid of this code: let root_ctr = match &hl.kind {
HotLocationKind::Compiled(root_ctr) => Arc::clone(root_ctr)
.as_any()
.downcast::<X64CompiledTrace>()
.unwrap(),
HotLocationKind::SideTracing { root_ctr, .. } => Arc::clone(root_ctr)
.as_any()
.downcast::<X64CompiledTrace>()
.unwrap(),
_ => panic!("Unexpected HotLocationKind"),
}; but obviously we didn't! Do we even need it? There's no way of making this code correct AFAICS: it's broken. |
After offline discussion we realised this is a bit of code duplication. |
One thing that I realised is that if we didn't consume all promotion data -- e.g. because we forgot to consume it when we're outlining -- weird things would happen. This assert always succeeds on my tests, but I think it's worth having in.