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

Infer nsw/nuw/etc attributes in tgt #966

Open
nunoplopes opened this issue Nov 17, 2023 · 2 comments
Open

Infer nsw/nuw/etc attributes in tgt #966

nunoplopes opened this issue Nov 17, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@nunoplopes
Copy link
Member

nunoplopes commented Nov 17, 2023

#962 is a simple implementation that does 1 query per flag.
It should be implemented in a more generic way, with some abstraction for instructions to advertise the flags they support so we can have a generic flag inference machinery.

cc @dtcxzyw

@nunoplopes nunoplopes added the enhancement New feature or request label Nov 17, 2023
@dtcxzyw
Copy link
Contributor

dtcxzyw commented Nov 17, 2023

Thank you for the comment!
I believe it is a useful feature for LLVM developers to reduce information loss during transformations.
I am willing to implement it. Could you please explain further about how to do it in a "more generic" way?

I used to add a virtual member function to the Instr class and gather SMT expressions they were interested in. But I don't know how to prove them with Z3 :(

TODO list:

BTW, I think it is also useful to drop some constraints in the src function (e.g., removing noundef attributes). Could you please open an issue for it?

@nunoplopes
Copy link
Member Author

Well, that''s a looong wishlist 😅
Some of those things (like replacing and/or operations) may not be in the realm of Alive itself. They probably should go in a separate tool. Maybe that's what we should do anyway.

The least invasive way of doing this is to add a new operation to all Instr to fetch the supported flags / variations of the instruction. Then we can have a thing on top that calls toSMT() once per flag (modifying the instruction in place). Then that loop on top can create an SMT variable to case split on the which value to use.
It's not as efficient as if toSMT() could itself return all options, but that would require a lot more work. And it's only vcgen time, solving time it would still be optimal.

TL;DR: I think Instr can have a new method that either returns applicable flags, returns an iterator with fresh instructions, or something in between. But the flags thing should be expressive enough to cover most cases you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants