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

[VCLLVM] Add support for pure functions #1049

Merged
merged 5 commits into from
Jul 7, 2023
Merged

[VCLLVM] Add support for pure functions #1049

merged 5 commits into from
Jul 7, 2023

Conversation

Drevanoorschot
Copy link
Contributor

This PR adds support to declare pure functions in LLVM IR named metadata nodes.
For example:

!VC.global = !{!0}
!0 = !{!"pure i32 @add_func(i32 %y, i32 %x) = add(%y, %x);"}

define i32 @add(i32 %a1, i32 %a2)
!VC.pure !{i1 true}
{
    %res = add i32 %a1, %a2
    ret i32 %res
}

define i32 @addCaller(i32 %a1, i32 %a2)
!VC.contract !{
    !"ensures icmp(eq, \result, call @add(%a1, %a2));",
    !"ensures icmp(eq, \result, call @add_func(%a1, %a2));"
    }
{
    %res = call i32 @add(i32 %a1, i32 %a2)
    ret i32 %res
}

Might add some more function constructs such as implications, recursion, and what not later, but the current implementation compiles and works so can be merged already.

Copy link
Member

@pieter-bos pieter-bos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have a look at the formatting changes again? It's polluting the blame quite a bit. Otherwise looks good!

@Drevanoorschot
Copy link
Contributor Author

The blames should be fixed now. My bad for that, just a force of habit to spam the formatting key across files 🙈. I also discovered a bug in the findCallable function of the LLVM resolver. That should be fixed now too.

pieter-bos
pieter-bos previously approved these changes Jul 7, 2023
@pieter-bos pieter-bos merged commit 66fb5c6 into dev Jul 7, 2023
@pieter-bos pieter-bos deleted the vcllvm_globals branch July 7, 2023 13:21
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 this pull request may close these issues.

2 participants