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

fix[docs]: fix venom examples #4475

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

fix[docs]: fix venom examples #4475

wants to merge 4 commits into from

Conversation

2xic
Copy link

@2xic 2xic commented Feb 13, 2025

What I did

I was playing around with the venom IR parser and ran into issues when using some of the instructions per the README. The current docs has swapped the usage of labels and the vars a few places.

How I did it

I got a error message which hinted at the issue

  File "/Users/brage/Downloads/vyper/vyper/venom/analysis/liveness.py", line 90, in input_vars_from
    for label, var in inst.phi_operands:
  File "/Users/brage/Downloads/vyper/vyper/venom/basicblock.py", line 374, in phi_operands
    assert isinstance(label, IRLabel), "phi operand must be a label"
AssertionError: phi operand must be a label

Then I ran the following on a Vyper file which would use the phi function to find a reference

 vyper --experimental-codegen -f bb_runtime 

It gave out

%ret_size:3 = phi @8_then, %ret_size:5, @9_else, %ret_size:4

How to verify it

Per the docs, this should compile, but it doesn't

function global {
  global:
    jnz 1, @1_then, @2_then
  1_then:
    %1 = 1
    jmp @3_phi
  2_then:
    %2 = 2
    jmp @3_phi
  3_phi:
    %3 = phi %1, @1_then, %2, @2_then
    return 0,%3
}

With my suggested fix it does compile

function global {
  global:
    jnz 1, @1_then, @2_then
  1_then:
    %1 = 1
    jmp @3_phi
  2_then:
    %2 = 2
    jmp @3_phi
  3_phi:
    %3 = phi %1, @1_then, %2, @2_then
    return 0,%3
}

Using python3 -m vyper.cli.venom_main [file] to verify. Same is true for jnz and the example code.

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Fix operands order for venom instruction in README example  

The README incorrectly swapped the arguments for the phi instruction  
example. This fix updates the documentation to match the correct  
instruction usage.  

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@2xic 2xic marked this pull request as draft February 13, 2025 22:21
@2xic 2xic changed the title [docs]: Fix incorrect phi instruction usage example [docs]: Fix incorrect venom instruction usage example Feb 13, 2025
@charles-cooper charles-cooper marked this pull request as ready for review February 16, 2025 20:08
@charles-cooper
Copy link
Member

@2xic is this ready for review?

Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.12%. Comparing base (c75a2da) to head (33e9e3c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4475   +/-   ##
=======================================
  Coverage   92.12%   92.12%           
=======================================
  Files         119      119           
  Lines       16967    16967           
  Branches     2872     2872           
=======================================
  Hits        15631    15631           
  Misses        918      918           
  Partials      418      418           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@charles-cooper charles-cooper changed the title [docs]: Fix incorrect venom instruction usage example fix[docs]: fix venom examples Feb 18, 2025
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