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

Implement variable lifetimes #569

Open
sapir opened this issue Oct 18, 2024 · 3 comments
Open

Implement variable lifetimes #569

sapir opened this issue Oct 18, 2024 · 3 comments

Comments

@sapir
Copy link
Contributor

sapir commented Oct 18, 2024

I mean the BuilderMethods::lifetime_start and lifetime_end methods which would be implemented here:

fn lifetime_start(&mut self, _ptr: RValue<'gcc>, _size: Size) {
// TODO(antoyo)
}
fn lifetime_end(&mut self, _ptr: RValue<'gcc>, _size: Size) {
// TODO(antoyo)
}

If I understand correctly, this would allow reusing variable stack space.

How could this be done? Could the variable lifetimes be mapped to gcc blocks?

@antoyo
Copy link
Contributor

antoyo commented Oct 18, 2024

I am not sure. I asked on IRC and they mentionned CLOBBER_OBJECT_BEGIN, but that it is not equivalent.

@sapir
Copy link
Contributor Author

sapir commented Oct 19, 2024

I didn't know that existed. How is it different? I found this mail with an explanation that does sound similar

https://gcc.gnu.org/pipermail/gcc/2024-February/243353.html

@antoyo
Copy link
Contributor

antoyo commented Oct 24, 2024

I do not know. Here's what people said about it on IRC the other day:

to get exactly the same .. I suppose we’d have to introduce a new internal fn or so .. and wire it up in some way to indicate that object initialization was complete .. seems like moderately heavy lifting.
(or maybe we could have some flag on a VAR_DECL .. that the init code sets .. dunno)

the tree clobbers are used for optimisation (especially that the lifetime has ended - and therefore the object is not longer usable / memory can be reused) .. but not I can’t really answer whether the start-of-lifetime would be more useful than the start of the CTOR .. (and I’ve not been amongst the LLVM middle end for like 8 years .. so it’s likely all changed :) )
you’d need ME folks to answer whether the lifetime start is poentially useful (although maybe the idea has been discussed)

You might need to ask on IRC or the mailing list to get a proper answer.

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

No branches or pull requests

2 participants